From 9ef6ad576c01444e35b91dfee8d05b39ec911d45 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 20 Jul 2009 18:39:31 -0400 Subject: Cleaned up some outdated libbe.settings_object.EMPTY cruft. From back before commit wking@drexel.edu-20090619184215-nfx205yaj02sqrqx cleaned up the versioned_property implementation. Also a few style fixes and typos. --- libbe/bug.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libbe/bug.py') diff --git a/libbe/bug.py b/libbe/bug.py index f5f479c..8be6010 100644 --- a/libbe/bug.py +++ b/libbe/bug.py @@ -177,7 +177,7 @@ class Bug(settings_object.SavedSettingsObject): def time_string(): return {} def _get_time(self): - if self.time_string in [None, settings_object.EMPTY]: + if self.time_string == None: return None return utility.str_to_time(self.time_string) def _set_time(self, value): @@ -254,10 +254,9 @@ class Bug(settings_object.SavedSettingsObject): def _setting_attr_string(self, setting): value = getattr(self, setting) - if value in [None, settings_object.EMPTY]: + if value == None: return "" - else: - return str(value) + return str(value) def xml(self, show_comments=False): if self.bugdir == None: -- cgit From 4c7a9d837a268480e61124bba84b5fb01ec3728f Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 21 Jul 2009 07:28:26 -0400 Subject: Cleaned up saving/sync_with_disk. Got rid of a whole bunch of redundant .save() calls when sync_with_disk==True. Fixed up the "File-system access" portion of the BugDir docstring so we can all remember how things are supposed to work ;). Note that some .save() calls are still required. For example in becommands/merge.py, the copied comments have their .bug changed, but that is not a versioned property, so it doesn't trigger an automatic save, and we have to force the .save() by hand. libbe.rcs.RCS.mkdir() is now recursive by default, but you can set check_parents==False if you want it to fail in the case of missing parents. Because of the recursion, we removed the .update() call on preexisting directories, since there will be at least one of these occurrences for every .mkdir(check_parents=True) call, and I don't know of any VCS that actually needs them... Also stripped trailing whitespace from some files... --- libbe/bug.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'libbe/bug.py') diff --git a/libbe/bug.py b/libbe/bug.py index 8be6010..e3dc1e0 100644 --- a/libbe/bug.py +++ b/libbe/bug.py @@ -252,6 +252,11 @@ class Bug(settings_object.SavedSettingsObject): def __repr__(self): return "Bug(uuid=%r)" % self.uuid + def set_sync_with_disk(self, value): + self.sync_with_disk = value + for comment in self.comments(): + comment.set_sync_with_disk(value) + def _setting_attr_string(self, setting): value = getattr(self, setting) if value == None: @@ -371,10 +376,17 @@ class Bug(settings_object.SavedSettingsObject): mapfile.map_save(self.rcs, path, self._get_saved_settings()) def save(self): + """ + Save any loaded contents to disk. Because of lazy loading of + comments, this is actually not too inefficient. + + However, if self.sync_with_disk = True, then any changes are + automatically written to disk as soon as they happen, so + calling this method will just waste time (unless something + else has been messing with your on-disk files). + """ self.save_settings() - if len(self.comment_root) > 0: - self.rcs.mkdir(self.get_path("comments")) comment.saveComments(self) def remove(self): -- cgit From 257df923b9657a03d7a394d7862a449c2cd342dc Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 21 Jul 2009 16:19:02 -0400 Subject: Bug._extra_strings_check_fn() guts now utility.iterable_full_of_strings(). --- libbe/bug.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'libbe/bug.py') diff --git a/libbe/bug.py b/libbe/bug.py index e3dc1e0..f3448e2 100644 --- a/libbe/bug.py +++ b/libbe/bug.py @@ -187,15 +187,8 @@ class Bug(settings_object.SavedSettingsObject): doc="An integer version of .time_string") def _extra_strings_check_fn(value): - "Require an iterable full of strings" - if value == settings_object.EMPTY: - return True - elif not hasattr(value, "__iter__"): - return False - for x in value: - if type(x) not in types.StringTypes: - return False - return True + return utility.iterable_full_of_strings(value, \ + alternative=settings_object.EMPTY) def _extra_strings_change_hook(self, old, new): self.extra_strings.sort() # to make merging easier self._prop_save_settings(old, new) -- cgit