190: Renamed public.option class to public.Option

This commit is contained in:
Jason Gerard DeRose 2008-08-25 22:10:23 +00:00
parent 0d4adb958b
commit 513bbb32b9
2 changed files with 23 additions and 23 deletions

View File

@ -60,9 +60,9 @@ class DefaultFrom(plugable.ReadOnly):
return None
class option(plugable.Plugin):
class Option(plugable.Plugin):
"""
The option class represents a kw argument from a command.
The Option class represents a kw argument from a `Command`.
"""
__public__ = frozenset((
@ -118,7 +118,7 @@ class option(plugable.Plugin):
self.__rules_iter(),
key=lambda f: getattr(f, '__name__'),
))
object.__setattr__(self, '_option__rules', rules)
object.__setattr__(self, '_Option__rules', rules)
return self.__rules
rules = property(__get_rules)
@ -138,11 +138,11 @@ class option(plugable.Plugin):
def default(self, **kw):
"""
Returns a default or auto-completed value for this option. If no
Returns a default or auto-completed value for this Option. If no
default is available, this method should return None.
All the keywords are passed so it's possible to build an
auto-completed value from other options values, e.g., build 'initials'
auto-completed value from other Options values, e.g., build 'initials'
from 'givenname' + 'sn'.
"""
return None
@ -181,7 +181,7 @@ class Command(plugable.Plugin):
assert inspect.isclass(cls)
o = cls()
o.__lock__()
yield plugable.PluginProxy(option, o)
yield plugable.PluginProxy(Option, o)
def __get_options(self):
"""
@ -329,8 +329,8 @@ class Method(Attribute, Command):
yield proxy
class Property(Attribute, option):
__public__ = Attribute.__public__.union(option.__public__)
class Property(Attribute, Option):
__public__ = Attribute.__public__.union(Option.__public__)
def get_doc(self, _):
return _('Property doc')

View File

@ -98,11 +98,11 @@ class test_DefaltFrom(ClassChecker):
assert o(**kw_copy) is None
class test_option(ClassChecker):
class test_Option(ClassChecker):
"""
Tests the `public.option` class.
Tests the `public.Option` class.
"""
_cls = public.option
_cls = public.Option
def get_subcls(self):
rule = public.rule
@ -131,7 +131,7 @@ class test_option(ClassChecker):
def test_normalize(self):
"""
Tests the `public.option.normalize` method.
Tests the `public.Option.normalize` method.
"""
assert 'normalize' in self.cls.__public__
o = self.subcls()
@ -163,7 +163,7 @@ class test_option(ClassChecker):
def test_validate(self):
"""
Tests the `public.option.validate` method.
Tests the `public.Option.validate` method.
"""
assert 'validate' in self.cls.__public__
o = self.subcls()
@ -175,7 +175,7 @@ class test_option(ClassChecker):
def test_rules(self):
"""
Tests the `public.option.rules` property.
Tests the `public.Option.rules` property.
"""
o = self.subcls()
assert len(o.rules) == 3
@ -186,20 +186,20 @@ class test_option(ClassChecker):
def test_default(self):
"""
Tests the `public.option.default` method.
Tests the `public.Option.default` method.
"""
assert 'default' in self.cls.__public__
assert self.cls().default() is None
class test_cmd(ClassChecker):
class test_Command(ClassChecker):
"""
Tests the `public.Command` class.
"""
_cls = public.Command
def get_subcls(self):
class my_option(public.option):
class my_option(public.Option):
def normalize(self, value):
return super(my_option, self).normalize(value).lower()
@public.rule
@ -230,7 +230,7 @@ class test_cmd(ClassChecker):
for (i, proxy) in enumerate(sub.get_options()):
assert isinstance(proxy, plugable.PluginProxy)
assert read_only(proxy, 'name') == 'option%d' % i
assert proxy.implements(public.option)
assert proxy.implements(public.Option)
assert i == 1
def test_options(self):
@ -448,9 +448,9 @@ class test_Method(ClassChecker):
assert self.cls.implements(public.Command)
def get_subcls(self):
class option0(public.option):
class option0(public.Option):
pass
class option1(public.option):
class option1(public.Option):
pass
class example_prop0(public.Property):
pass
@ -486,15 +486,15 @@ class test_Method(ClassChecker):
for (i, proxy) in enumerate(proxies):
assert proxy.name == names[i]
assert isinstance(proxy, plugable.PluginProxy)
assert proxy.implements(public.option)
assert proxy.implements(public.Option)
class test_prop(ClassChecker):
_cls = public.Property
def test_class(self):
assert self.cls.__bases__ == (public.Attribute, public.option)
assert self.cls.implements(public.option)
assert self.cls.__bases__ == (public.Attribute, public.Option)
assert self.cls.implements(public.Option)
def test_PublicAPI():