diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-15 19:49:04 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-15 19:49:04 +0000 |
commit | b0ec8fe551bc5f454aa1babeab31a424fd8c9abe (patch) | |
tree | 29cab05901d1aff75540d06bb4777efc1bf565c7 | |
parent | 99450358af821b269d46581750d20730fb5c9e9f (diff) | |
download | freeipa-b0ec8fe551bc5f454aa1babeab31a424fd8c9abe.tar.gz freeipa-b0ec8fe551bc5f454aa1babeab31a424fd8c9abe.tar.xz freeipa-b0ec8fe551bc5f454aa1babeab31a424fd8c9abe.zip |
182: Renamed plublic.cmd base class to Command
-rw-r--r-- | ipalib/cli.py | 8 | ||||
-rw-r--r-- | ipalib/plugins/example.py | 4 | ||||
-rw-r--r-- | ipalib/public.py | 12 | ||||
-rw-r--r-- | ipalib/tests/test_cli.py | 12 | ||||
-rw-r--r-- | ipalib/tests/test_public.py | 36 |
5 files changed, 38 insertions, 34 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py index 8f09e90ce..1ad53058e 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -43,10 +43,10 @@ def from_cli(cli_name): return str(cli_name).replace('-', '_') -class help(public.cmd): +class help(public.Command): 'display help on command' def __call__(self, key): - if from_cli(key) not in self.api.cmd: + if from_cli(key) not in self.api.Command: print 'help: no such command %r' % key sys.exit(2) print 'Help on command %r:' % key @@ -65,7 +65,7 @@ class CLI(object): def print_commands(self): print 'Available Commands:' - for cmd in self.api.cmd(): + for cmd in self.api.Command(): print ' %s %s' % ( to_cli(cmd.name).ljust(self.mcl), cmd.doc, @@ -84,7 +84,7 @@ class CLI(object): api.register(help) api.finalize() def d_iter(): - for cmd in api.cmd(): + for cmd in api.Command(): yield (to_cli(cmd.name), cmd) self.__d = dict(d_iter()) diff --git a/ipalib/plugins/example.py b/ipalib/plugins/example.py index 3350e2b9f..8a89ca436 100644 --- a/ipalib/plugins/example.py +++ b/ipalib/plugins/example.py @@ -27,11 +27,11 @@ from ipalib.api import api # Hypothetical functional commands (not associated with any object): -class krbtest(public.cmd): +class krbtest(public.Command): 'Test your Kerberos ticket' api.register(krbtest) -class discover(public.cmd): +class discover(public.Command): 'Discover IPA servers on network' api.register(discover) diff --git a/ipalib/public.py b/ipalib/public.py index 9a6c02ef6..ff8bd8b02 100644 --- a/ipalib/public.py +++ b/ipalib/public.py @@ -127,7 +127,7 @@ class option(plugable.Plugin): return None -class cmd(plugable.Plugin): +class Command(plugable.Plugin): __public__ = frozenset(( 'normalize', 'default', @@ -167,7 +167,7 @@ class cmd(plugable.Plugin): Returns the NameSpace containing the option proxy objects. """ if self.__options is None: - object.__setattr__(self, '_cmd__options', + object.__setattr__(self, '_Command__options', plugable.NameSpace(self.get_options()), ) return self.__options @@ -294,11 +294,11 @@ class attr(plugable.Plugin): self.__obj = api.obj[self.obj_name] -class mthd(attr, cmd): - __public__ = attr.__public__.union(cmd.__public__) +class mthd(attr, Command): + __public__ = attr.__public__.union(Command.__public__) def get_options(self): - for proxy in cmd.get_options(self): + for proxy in Command.get_options(self): yield proxy if self.obj is not None and self.obj.prop is not None: for proxy in self.obj.prop(): @@ -314,4 +314,4 @@ class prop(attr, option): class PublicAPI(plugable.API): def __init__(self): - super(PublicAPI, self).__init__(cmd, obj, mthd, prop) + super(PublicAPI, self).__init__(Command, obj, mthd, prop) diff --git a/ipalib/tests/test_cli.py b/ipalib/tests/test_cli.py index a5ee8a940..2c65bd06f 100644 --- a/ipalib/tests/test_cli.py +++ b/ipalib/tests/test_cli.py @@ -46,7 +46,7 @@ def test_from_cli(): def get_cmd_name(i): return 'cmd_%d' % i -class DummyCmd(object): +class DummyCommand(object): def __init__(self, name): self.__name = name @@ -60,11 +60,11 @@ class DummyAPI(object): def __get_cmd(self): return self.__cmd - cmd = property(__get_cmd) + Command = property(__get_cmd) def __cmd_iter(self, cnt): for i in xrange(cnt): - yield DummyCmd(get_cmd_name(i)) + yield DummyCommand(get_cmd_name(i)) def finalize(self): pass @@ -114,7 +114,7 @@ class test_CLI(ClassChecker): """ cnt = 100 api = DummyAPI(cnt) - len(api.cmd) == cnt + len(api.Command) == cnt o = self.cls(api) assert o.mcl is None o.finalize() @@ -126,10 +126,10 @@ class test_CLI(ClassChecker): """ cnt = 25 api = DummyAPI(cnt) - assert len(api.cmd) == cnt + assert len(api.Command) == cnt o = self.cls(api) o.finalize() - for cmd in api.cmd(): + for cmd in api.Command(): key = cli.to_cli(cmd.name) assert key in o assert o[key] is cmd diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py index 968e067f9..d053081dc 100644 --- a/ipalib/tests/test_public.py +++ b/ipalib/tests/test_public.py @@ -159,9 +159,9 @@ class test_option(ClassChecker): class test_cmd(ClassChecker): """ - Tests the `public.cmd` class. + Tests the `public.Command` class. """ - _cls = public.cmd + _cls = public.Command def get_subcls(self): class my_option(public.option): @@ -188,7 +188,7 @@ class test_cmd(ClassChecker): def test_get_options(self): """ - Tests the `public.cmd.get_options` method. + Tests the `public.Command.get_options` method. """ assert list(self.cls().get_options()) == [] sub = self.subcls() @@ -200,7 +200,7 @@ class test_cmd(ClassChecker): def test_options(self): """ - Tests the `public.cmd.options` property. + Tests the `public.Command.options` property. """ assert 'options' in self.cls.__public__ # Public sub = self.subcls() @@ -216,7 +216,7 @@ class test_cmd(ClassChecker): def test_normalize(self): """ - Tests the `public.cmd.normalize` method. + Tests the `public.Command.normalize` method. """ assert 'normalize' in self.cls.__public__ # Public kw = dict( @@ -230,7 +230,7 @@ class test_cmd(ClassChecker): def test_default(self): """ - Tests the `public.cmd.default` method. + Tests the `public.Command.default` method. """ assert 'default' in self.cls.__public__ # Public no_fill = dict( @@ -251,7 +251,7 @@ class test_cmd(ClassChecker): def test_validate(self): """ - Tests the `public.cmd.validate` method. + Tests the `public.Command.validate` method. """ assert 'validate' in self.cls.__public__ # Public @@ -281,7 +281,7 @@ class test_cmd(ClassChecker): def test_execute(self): """ - Tests the `public.cmd.execute` method. + Tests the `public.Command.execute` method. """ assert 'execute' in self.cls.__public__ # Public @@ -322,8 +322,8 @@ class test_mthd(ClassChecker): _cls = public.mthd def test_class(self): - assert self.cls.__bases__ == (public.attr, public.cmd) - assert self.cls.implements(public.cmd) + assert self.cls.__bases__ == (public.attr, public.Command) + assert self.cls.implements(public.Command) def get_subcls(self): class option0(public.option): @@ -338,10 +338,14 @@ class test_mthd(ClassChecker): __prop = None def __get_prop(self): if self.__prop is None: - self.__prop = ( - plugable.PluginProxy(public.prop, example_prop0(), 'attr_name'), - plugable.PluginProxy(public.prop, example_prop1(), 'attr_name'), - ) + self.__prop = plugable.NameSpace([ + plugable.PluginProxy( + public.prop, example_prop0(), 'attr_name' + ), + plugable.PluginProxy( + public.prop, example_prop1(), 'attr_name' + ), + ]) return self.__prop prop = property(__get_prop) class noun_verb(self.cls): @@ -377,11 +381,11 @@ def test_PublicAPI(): api = cls() - class cmd1(public.cmd): + class cmd1(public.Command): pass api.register(cmd1) - class cmd2(public.cmd): + class cmd2(public.Command): pass api.register(cmd2) |