summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2018-09-28 06:41:08 -0500
committerJason Madden <jamadden@gmail.com>2018-09-28 06:41:08 -0500
commite313ece59efb2bc4c5928377376b170ff4ba3f94 (patch)
treec310c6b4fd73737ff127f479ee7725d142656ceb
parent8da1212e684d9fa799420d756458ea055da1e384 (diff)
downloadzope-configuration-e313ece59efb2bc4c5928377376b170ff4ba3f94.tar.gz
Docstring cleanups from review.
-rw-r--r--src/zope/configuration/config.py16
-rw-r--r--src/zope/configuration/fields.py52
-rw-r--r--src/zope/configuration/tests/test_docs.py3
-rw-r--r--src/zope/configuration/xmlconfig.py8
4 files changed, 39 insertions, 40 deletions
diff --git a/src/zope/configuration/config.py b/src/zope/configuration/config.py
index 2089ace..e7ba289 100644
--- a/src/zope/configuration/config.py
+++ b/src/zope/configuration/config.py
@@ -360,7 +360,7 @@ class ConfigurationContext(object):
>>> d = os.path.dirname(zope.configuration.__file__)
>>> c.processFile('bar.zcml')
True
- >>> c.processFile('bar.zcml')
+ >>> c.processFile(os.path.join(d, 'bar.zcml'))
False
"""
path = self.path(filename)
@@ -397,7 +397,7 @@ class ConfigurationContext(object):
>>> from zope.configuration.tests.directives import f
>>> c.action(1, f, (1, ), {'x': 1})
>>> from pprint import PrettyPrinter
- >>> pprint=PrettyPrinter(width=60).pprint
+ >>> pprint = PrettyPrinter(width=60).pprint
>>> pprint(c.actions)
[{'args': (1,),
'callable': f,
@@ -550,7 +550,7 @@ class ConfigurationAdapterRegistry(object):
>>> from zope.configuration.config import ConfigurationMachine
>>> r = ConfigurationAdapterRegistry()
>>> c = ConfigurationMachine()
- >>> r.factory(c, ('http://www.zope.com','xxx'))
+ >>> r.factory(c, ('http://www.zope.com', 'xxx'))
Traceback (most recent call last):
...
ConfigurationError: ('Unknown directive', 'http://www.zope.com', 'xxx')
@@ -558,14 +558,14 @@ class ConfigurationAdapterRegistry(object):
... pass
>>> r.register(IConfigurationContext, ('http://www.zope.com', 'xxx'), f)
- >>> r.factory(c, ('http://www.zope.com','xxx')) is f
+ >>> r.factory(c, ('http://www.zope.com', 'xxx')) is f
True
- >>> r.factory(c, ('http://www.zope.com','yyy')) is f
+ >>> r.factory(c, ('http://www.zope.com', 'yyy')) is f
Traceback (most recent call last):
...
ConfigurationError: ('Unknown directive', 'http://www.zope.com', 'yyy')
>>> r.register(IConfigurationContext, 'yyy', f)
- >>> r.factory(c, ('http://www.zope.com','yyy')) is f
+ >>> r.factory(c, ('http://www.zope.com', 'yyy')) is f
True
Test the documentation feature:
@@ -714,7 +714,7 @@ class ConfigurationMachine(ConfigurationAdapterRegistry, ConfigurationContext):
>>> from zope.configuration.config import ConfigurationMachine
>>> output = []
- >>> def f(*a, **k): #* syntax highlighting
+ >>> def f(*a, **k):
... output.append(('f', a, k))
>>> context = ConfigurationMachine()
>>> context.actions = [
@@ -1580,7 +1580,7 @@ def toargs(context, schema, data):
>>> context = ConfigurationMachine()
>>> from pprint import PrettyPrinter
- >>> pprint=PrettyPrinter(width=50).pprint
+ >>> pprint = PrettyPrinter(width=50).pprint
>>> pprint(toargs(context, schema,
... {'in': u'1', 'f': u'1.2', 'n': u'bob', 'x': u'x.y.z',
diff --git a/src/zope/configuration/fields.py b/src/zope/configuration/fields.py
index 85a5ff7..c4af0ad 100644
--- a/src/zope/configuration/fields.py
+++ b/src/zope/configuration/fields.py
@@ -44,7 +44,7 @@ __all__ = [
class PythonIdentifier(schema_PythonIdentifier):
- """
+ r"""
This class is like `zope.schema.PythonIdentifier`.
@@ -70,14 +70,14 @@ class PythonIdentifier(schema_PythonIdentifier):
>>> for value in (u'foo', u'foo3', u'foo_', u'_foo3', u'foo_3', u'foo3_'):
... _ = field.fromUnicode(value)
>>> from zope.schema import ValidationError
- >>> for value in (u'3foo', u'foo:', u'\\\\', u''):
+ >>> for value in (u'3foo', u'foo:', u'\\', u''):
... try:
... field.fromUnicode(value)
... except ValidationError:
... print('Validation Error ' + repr(value))
Validation Error '3foo'
Validation Error 'foo:'
- Validation Error '\\\\'
+ Validation Error '\\'
Validation Error ''
.. versionchanged:: 4.2.0
@@ -112,7 +112,7 @@ class GlobalObject(Field):
self.value_type.validate(value)
def fromUnicode(self, value):
- """
+ r"""
Find and return the module global at the path *value*.
>>> d = {'x': 1, 'y': 42, 'z': 'zope'}
@@ -127,7 +127,7 @@ class GlobalObject(Field):
>>> gg = g.bind(fake)
>>> gg.fromUnicode("x")
1
- >>> gg.fromUnicode(" x \\n ")
+ >>> gg.fromUnicode(" x \n ")
1
>>> gg.fromUnicode("y")
42
@@ -222,7 +222,7 @@ class Tokens(List):
"""
def fromUnicode(self, value):
- """
+ r"""
Split the input string and convert it to *value_type*.
Consider GlobalObject tokens:
@@ -239,7 +239,7 @@ class Tokens(List):
>>> from zope.configuration.fields import GlobalObject
>>> g = Tokens(value_type=GlobalObject())
>>> gg = g.bind(fake)
- >>> gg.fromUnicode(" \\n x y z \\n")
+ >>> gg.fromUnicode(" \n x y z \n")
[1, 42, 'zope']
>>> from zope.schema import Int
@@ -306,7 +306,7 @@ class Path(Text):
"""
def fromUnicode(self, value):
- """
+ r"""
Convert the input path to a normalized, absolute path.
Let's look at an example:
@@ -314,7 +314,7 @@ class Path(Text):
First, we need a "context" for the field that has a path
function for converting relative path to an absolute path.
- We'll be careful to do this in an os-independent fashion.
+ We'll be careful to do this in an operating system independent fashion.
>>> from zope.configuration.fields import Path
>>> class FauxContext(object):
@@ -333,7 +333,7 @@ class Path(Text):
This should also work with extra spaces around the path:
- >>> p = " \\n %s \\n\\n " % p
+ >>> p = " \n %s \n\n " % p
>>> n = field.fromUnicode(p)
>>> n.split(os.sep)
['', 'a', 'b']
@@ -393,7 +393,7 @@ class Bool(schema_Bool):
Do not confuse this with :class:`zope.schema.Bool`.
That class will only parse ``"True"`` and ``"true"`` as
`True` values. Any other value will silently be accepted as
- `False`. This class raises a validation error for unrecognized
+ `False`. This class raises a validation error for unrecognized
input.
"""
@@ -404,19 +404,19 @@ class Bool(schema_Bool):
Example:
- >>> from zope.configuration.fields import Bool
- >>> Bool().fromUnicode(u"yes")
- True
- >>> Bool().fromUnicode(u"y")
- True
- >>> Bool().fromUnicode(u"true")
- True
- >>> Bool().fromUnicode(u"no")
- False
- >>> Bool().fromUnicode(u"surprise")
- Traceback (most recent call last):
- ...
- zope.schema._bootstrapinterfaces.InvalidValue
+ >>> from zope.configuration.fields import Bool
+ >>> Bool().fromUnicode(u"yes")
+ True
+ >>> Bool().fromUnicode(u"y")
+ True
+ >>> Bool().fromUnicode(u"true")
+ True
+ >>> Bool().fromUnicode(u"no")
+ False
+ >>> Bool().fromUnicode(u"surprise")
+ Traceback (most recent call last):
+ ...
+ zope.schema._bootstrapinterfaces.InvalidValue
"""
value = value.lower()
if value in ('1', 'true', 'yes', 't', 'y'):
@@ -459,7 +459,7 @@ class MessageID(Text):
has been issued
>>> warned = None
- >>> def fakewarn(*args, **kw): #* syntax highlighting
+ >>> def fakewarn(*args, **kw):
... global warned
... warned = args
@@ -529,7 +529,7 @@ class MessageID(Text):
domain = 'untranslated'
warnings.warn(
"You did not specify an i18n translation domain for the "\
- "'%s' field in %s" % (self.getName(), context.info.file )
+ "'%s' field in %s" % (self.getName(), context.info.file)
)
if not isinstance(domain, str):
# IZopeConfigure specifies i18n_domain as a BytesLine, but that's
diff --git a/src/zope/configuration/tests/test_docs.py b/src/zope/configuration/tests/test_docs.py
index e51a095..3452e3b 100644
--- a/src/zope/configuration/tests/test_docs.py
+++ b/src/zope/configuration/tests/test_docs.py
@@ -99,10 +99,9 @@ def test_suite():
for mod_name in api_to_test:
mod_name = 'zope.configuration.' + mod_name
- __import__(mod_name)
suite.addTest(
doctest.DocTestSuite(
- sys.modules[mod_name],
+ mod_name,
checker=checker,
optionflags=optionflags
)
diff --git a/src/zope/configuration/xmlconfig.py b/src/zope/configuration/xmlconfig.py
index 18f731f..e979e13 100644
--- a/src/zope/configuration/xmlconfig.py
+++ b/src/zope/configuration/xmlconfig.py
@@ -117,7 +117,7 @@ class ZopeSAXParseException(ConfigurationError):
return str(v)
class ParserInfo(object):
- """
+ r"""
Information about a directive based on parser data
This includes the directive location, as well as text data
@@ -133,10 +133,10 @@ class ParserInfo(object):
>>> print(info)
File "tests//sample.zcml", line 1.0
- >>> info.characters("blah\\n")
+ >>> info.characters("blah\n")
>>> info.characters("blah")
>>> info.text
- 'blah\\nblah'
+ 'blah\nblah'
>>> info.end(7, 0)
>>> info
@@ -221,7 +221,7 @@ class ParserInfo(object):
class ConfigurationHandler(ContentHandler):
"""
- Interface to the xml parser
+ Interface to the XML parser
Translate parser events into calls into the configuration system.
"""