rename API add_owner -> addowner

This commit is contained in:
gwen 2013-08-27 16:12:53 +02:00
parent b341844450
commit a894a5e27b
4 changed files with 8 additions and 8 deletions

View File

@ -7,7 +7,7 @@
#from tiramisu.option import IntOption, OptionDescription #from tiramisu.option import IntOption, OptionDescription
#from tiramisu.error import ConfigError #from tiramisu.error import ConfigError
#owners.add_owner('meta') #owners.addowner('meta')
#def make_description(): #def make_description():

View File

@ -40,13 +40,13 @@ def test_default_owner():
assert cfg.getowner(gcdummy) == owners.user assert cfg.getowner(gcdummy) == owners.user
def test_add_owner(): def test_addowner():
gcdummy = BoolOption('dummy', 'dummy', default=False) gcdummy = BoolOption('dummy', 'dummy', default=False)
descr = OptionDescription('tiramisu', '', [gcdummy]) descr = OptionDescription('tiramisu', '', [gcdummy])
cfg = Config(descr) cfg = Config(descr)
assert cfg.dummy is False assert cfg.dummy is False
assert cfg.getowner(gcdummy) == 'default' assert cfg.getowner(gcdummy) == 'default'
owners.add_owner("gen_config") owners.addowner("gen_config")
cfg.cfgimpl_get_settings().setowner(owners.gen_config) cfg.cfgimpl_get_settings().setowner(owners.gen_config)
cfg.dummy = True cfg.dummy = True
assert cfg.getowner(gcdummy) == owners.gen_config assert cfg.getowner(gcdummy) == owners.gen_config
@ -79,7 +79,7 @@ def test_setowner_for_value():
cfg = Config(descr) cfg = Config(descr)
assert cfg.dummy is False assert cfg.dummy is False
assert cfg.getowner(gcdummy) == 'default' assert cfg.getowner(gcdummy) == 'default'
owners.add_owner("new") owners.addowner("new")
raises(ConfigError, "cfg.cfgimpl_get_values().setowner(gcdummy, owners.new)") raises(ConfigError, "cfg.cfgimpl_get_values().setowner(gcdummy, owners.new)")
cfg.dummy = False cfg.dummy = False
assert cfg.getowner(gcdummy) == owners.user assert cfg.getowner(gcdummy) == owners.user

View File

@ -132,12 +132,12 @@ def populate_owners():
setattr(owners, 'default', owners.DefaultOwner('default')) setattr(owners, 'default', owners.DefaultOwner('default'))
setattr(owners, 'user', owners.Owner('user')) setattr(owners, 'user', owners.Owner('user'))
def add_owner(name): def addowner(name):
""" """
:param name: the name of the new owner :param name: the name of the new owner
""" """
setattr(owners, name, owners.Owner(name)) setattr(owners, name, owners.Owner(name))
setattr(owners, 'add_owner', add_owner) setattr(owners, 'addowner', addowner)
# names are in the module now # names are in the module now
populate_owners() populate_owners()

View File

@ -37,7 +37,7 @@ class Values(Cache):
try: try:
getattr(owners, owner[0]) getattr(owners, owner[0])
except AttributeError: except AttributeError:
owners.add_owner(owner[0]) owners.addowner(owner[0])
# sqlite # sqlite
def _sqlite_select(self, path): def _sqlite_select(self, path):
@ -112,5 +112,5 @@ class Values(Cache):
try: try:
return getattr(owners, owner) return getattr(owners, owner)
except AttributeError: except AttributeError:
owners.add_owner(owner) owners.addowner(owner)
return getattr(owners, owner) return getattr(owners, owner)