diff options
Diffstat (limited to 'libbe/storage/util/settings_object.py')
-rw-r--r-- | libbe/storage/util/settings_object.py | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/libbe/storage/util/settings_object.py b/libbe/storage/util/settings_object.py index d872f49..8981e35 100644 --- a/libbe/storage/util/settings_object.py +++ b/libbe/storage/util/settings_object.py @@ -57,7 +57,7 @@ class EMPTY (_Token): def prop_save_settings(self, old, new): """The default action undertaken when a property changes. """ - if self.storage != None and self.storage.is_writeable(): + if self.storage is not None and self.storage.is_writeable(): self.save_settings() def prop_load_settings(self): @@ -68,7 +68,7 @@ def prop_load_settings(self): `._setup_saved_settings()` internally. If `.storage` is inaccessible, don't do anything. """ - if self.storage != None and self.storage.is_readable(): + if self.storage is not None and self.storage.is_readable(): self.load_settings() # Some name-mangling routines for pretty printing setting names @@ -160,18 +160,18 @@ def versioned_property(name, doc, required_saved_properties.append(name) def decorator(funcs): fulldoc = doc - if default != None or generator == None: + if default is not None or generator is None: defaulting = defaulting_property(default=default, null=EMPTY, mutable_default=mutable) fulldoc += "\n\nThis property defaults to %s." % default - if generator != None: + if generator is not None: cached = cached_property(generator=generator, initVal=EMPTY, mutable=mutable) fulldoc += "\n\nThis property is generated with %s." % generator - if check_fn != None: + if check_fn is not None: fn_checked = fn_checked_property(value_allowed_fn=check_fn) fulldoc += "\n\nThis property is checked with %s." % check_fn - if allowed != None: + if allowed is not None: checked = checked_property(allowed=allowed) fulldoc += "\n\nThe allowed values for this property are: %s." \ % (', '.join(allowed)) @@ -182,13 +182,13 @@ def versioned_property(name, doc, settings = settings_property(name=name, null=UNPRIMED) docp = doc_property(doc=fulldoc) deco = hooked(primed(settings(docp(funcs)))) - if default != None or generator == None: + if default is not None or generator is None: deco = defaulting(deco) - if generator != None: + if generator is not None: deco = cached(deco) - if check_fn != None: + if check_fn is not None: deco = fn_checked(deco) - if allowed != None: + if allowed is not None: deco = checked(deco) return Property(deco) return decorator @@ -233,7 +233,7 @@ class SavedSettingsObject(object): Sets up a settings dict loaded from storage. Fills in all missing settings entries with EMPTY. """ - if settings == None: + if settings is None: settings = {} for property in self.settings_properties: if property not in self.settings \ @@ -274,7 +274,7 @@ class SavedSettingsObject(object): def clear_cached_setting(self, setting=None): "If setting=None, clear *all* cached settings" - if setting != None: + if setting is not None: if hasattr(self, "_%s_cached_value" % setting): delattr(self, "_%s_cached_value" % setting) else: @@ -342,20 +342,20 @@ if libbe.TESTING == True: # accessing t.content_type triggers the priming, but # t.storage.is_readable() == False, so nothing happens. t.storage.readable = False - self.assertTrue(t.content_type == None, t.content_type) + self.assertTrue(t.content_type is None, t.content_type) self.assertTrue(t.settings == {}, t.settings) self.assertTrue(len(t.settings) == 0, len(t.settings)) - self.assertTrue(t.content_type == None, t.content_type) + self.assertTrue(t.content_type is None, t.content_type) # accessing t.content_type triggers the priming again, and # now that t.storage.is_readable() == True, this fills out # t.settings with EMPTY data. At this point there should # be one load and no saves. t.storage.readable = True - self.assertTrue(t.content_type == None, t.content_type) + self.assertTrue(t.content_type is None, t.content_type) self.assertTrue(len(t.settings) == 1, len(t.settings)) self.assertTrue(t.settings["Content-type"] == EMPTY, t.settings["Content-type"]) - self.assertTrue(t.content_type == None, t.content_type) + self.assertTrue(t.content_type is None, t.content_type) self.assertTrue(t.load_count == 1, t.load_count) self.assertTrue(len(t.storage) == 0, len(t.storage)) # an explicit call to load settings forces a reload, @@ -364,7 +364,7 @@ if libbe.TESTING == True: self.assertTrue(len(t.settings) == 1, len(t.settings)) self.assertTrue(t.settings["Content-type"] == EMPTY, t.settings["Content-type"]) - self.assertTrue(t.content_type == None, t.content_type) + self.assertTrue(t.content_type is None, t.content_type) self.assertTrue(t.load_count == 2, t.load_count) self.assertTrue(len(t.storage) == 0, len(t.storage)) # now we set a value @@ -400,7 +400,7 @@ if libbe.TESTING == True: t.content_type = EMPTY self.assertTrue(t.settings["Content-type"] == EMPTY, t.settings["Content-type"]) - self.assertTrue(t.content_type == None, t.content_type) + self.assertTrue(t.content_type is None, t.content_type) self.assertTrue(len(t.settings) == 1, len(t.settings)) self.assertTrue(t.settings["Content-type"] == EMPTY, t.settings["Content-type"]) @@ -592,7 +592,7 @@ if libbe.TESTING == True: def list_type(): return {} t = Test() self.assertTrue(len(t.storage) == 0, len(t.storage)) - self.assertTrue(t.list_type == None, t.list_type) + self.assertTrue(t.list_type is None, t.list_type) self.assertTrue(len(t.storage) == 0, len(t.storage)) self.assertTrue(t.settings["List-type"]==EMPTY, t.settings["List-type"]) @@ -614,6 +614,6 @@ if libbe.TESTING == True: {'List-type':[5]}], t.storage) - unitsuite = unittest.TestLoader().loadTestsFromTestCase( \ + unitsuite = unittest.TestLoader().loadTestsFromTestCase( SavedSettingsObjectTests) suite = unittest.TestSuite([unitsuite, doctest.DocTestSuite()]) |