← Back to team overview

configglue team mailing list archive

[Merge] lp:~ricardokirkner/configglue/refactor-options-pep8 into lp:configglue

 

Ricardo Kirkner has proposed merging lp:~ricardokirkner/configglue/refactor-options-pep8 into lp:configglue.

Requested reviews:
  Configglue developers (configglue)

For more details, see:
https://code.launchpad.net/~ricardokirkner/configglue/refactor-options-pep8/+merge/64405

Applied suggestions from running pep8 as a baseline for the refactoring.
-- 
https://code.launchpad.net/~ricardokirkner/configglue/refactor-options-pep8/+merge/64405
Your team Configglue developers is requested to review the proposed merge of lp:~ricardokirkner/configglue/refactor-options-pep8 into lp:configglue.
=== modified file 'configglue/__init__.py'
--- configglue/__init__.py	2011-04-29 19:47:41 +0000
+++ configglue/__init__.py	2011-06-13 13:44:12 +0000
@@ -1,18 +1,18 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 __version__ = '0.10'

=== modified file 'configglue/inischema/__init__.py'
--- configglue/inischema/__init__.py	2010-07-31 01:15:59 +0000
+++ configglue/inischema/__init__.py	2011-06-13 13:44:12 +0000
@@ -1,18 +1,18 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 """configglue -- glue for your apps' configuration
@@ -69,3 +69,10 @@
 from .typed import TypedConfigParser
 from .attributed import AttributedConfigParser
 from .glue import configglue
+
+
+__all__ = [
+    'TypedConfigParser',
+    'AttributedConfigParser',
+    'configglue',
+]

=== modified file 'configglue/inischema/attributed.py'
--- configglue/inischema/attributed.py	2010-07-31 01:15:59 +0000
+++ configglue/inischema/attributed.py	2011-06-13 13:44:12 +0000
@@ -1,18 +1,18 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 """
@@ -21,7 +21,10 @@
 import re
 from ConfigParser import RawConfigParser
 
+
 marker = object()
+
+
 class ValueWithAttrs(object):
     """The values returned by AttributtedConfigParser are instances of this.
     """
@@ -38,6 +41,7 @@
         """
         return self.value is marker
 
+
 class AttributedConfigParser(RawConfigParser, object):
     """Handle attributed ini-style configuration files
     """
@@ -74,5 +78,5 @@
         self.set(section, option, value)
         for opt, val in self.items(section)[:]:
             if opt.startswith(option + '.'):
-                value.attrs[opt[len(option)+1:]] = val
+                value.attrs[opt[len(option) + 1:]] = val
                 self.remove_option(section, opt)

=== modified file 'configglue/inischema/glue.py'
--- configglue/inischema/glue.py	2011-03-06 17:28:14 +0000
+++ configglue/inischema/glue.py	2011-06-13 13:44:12 +0000
@@ -1,18 +1,18 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 """configglue lives here

=== modified file 'configglue/inischema/parsers.py'
--- configglue/inischema/parsers.py	2010-07-31 01:15:59 +0000
+++ configglue/inischema/parsers.py	2011-06-13 13:44:12 +0000
@@ -1,23 +1,24 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 """Parsers used by TypedConfigParser live here
 """
 
+
 def lines(value):
     """ Split a string on its newlines
 
@@ -33,6 +34,8 @@
 
 _true_values = frozenset(('true', '1', 'on', 'yes'))
 _false_values = frozenset(('false', '0', 'off', 'no'))
+
+
 def bool_parser(value):
     """Take a string representation of a boolean and return its boolosity
 

=== modified file 'configglue/inischema/typed.py'
--- configglue/inischema/typed.py	2010-07-31 01:15:59 +0000
+++ configglue/inischema/typed.py	2011-06-13 13:44:12 +0000
@@ -1,18 +1,18 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 """ TypedConfigParser lives here """
@@ -23,6 +23,7 @@
 from . import parsers
 from .attributed import AttributedConfigParser
 
+
 class TypedConfigParser(AttributedConfigParser):
     """Building on AttributedConfigParser, handle the idea of having a
     configuration file that knows what type its options are.
@@ -78,7 +79,7 @@
 
         if value.is_empty:
             if 'default' in value.attrs:
-                value.value =  value.attrs['default']
+                value.value = value.attrs['default']
             else:
                 value.value = None
 

=== modified file 'configglue/pyschema/__init__.py'
--- configglue/pyschema/__init__.py	2011-04-29 19:43:12 +0000
+++ configglue/pyschema/__init__.py	2011-06-13 13:44:12 +0000
@@ -1,18 +1,18 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 from .glue import *

=== modified file 'configglue/pyschema/glue.py'
--- configglue/pyschema/glue.py	2011-06-07 21:16:16 +0000
+++ configglue/pyschema/glue.py	2011-06-13 13:44:12 +0000
@@ -1,18 +1,18 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 import sys
@@ -34,7 +34,7 @@
 
 def schemaconfigglue(parser, op=None, argv=None):
     """Glue an OptionParser with a SchemaConfigParser.
-    
+
     The OptionParser is populated with options and defaults taken from the
     SchemaConfigParser.
 

=== modified file 'configglue/pyschema/parser.py'
--- configglue/pyschema/parser.py	2011-06-07 21:16:16 +0000
+++ configglue/pyschema/parser.py	2011-06-13 13:44:12 +0000
@@ -1,18 +1,18 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 import codecs
@@ -365,8 +365,8 @@
         If any options are omitted from the config file, provide the
         default value from the schema.
 
-        In the case of an NoSectionError or NoOptionError, raise it if the option
-        has *fatal* set to *True*.
+        In the case of an NoSectionError or NoOptionError, raise it if the
+        option has *fatal* set to *True*.
 
         """
         for section in self.schema.sections():
@@ -578,4 +578,3 @@
                     os.rename(filename, "%s.old" % filename)
                 # rename new file
                 os.rename("%s.new" % filename, filename)
-

=== modified file 'configglue/pyschema/schema.py'
--- configglue/pyschema/schema.py	2011-06-07 21:16:16 +0000
+++ configglue/pyschema/schema.py	2011-06-13 13:44:12 +0000
@@ -1,18 +1,18 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 from copy import deepcopy
@@ -95,7 +95,8 @@
 
     def _add_option(self, name, option):
         """Add a top-level option to the schema."""
-        section = self._sections.setdefault('__main__', ConfigSection(name='__main__'))
+        section = self._sections.setdefault('__main__',
+            ConfigSection(name='__main__'))
         option.section = section
         setattr(section, name, option)
 
@@ -225,8 +226,8 @@
 
     require_parser = False
 
-    def __init__(self, name='', raw=False, default=NO_DEFAULT, fatal=False, help='',
-                 section=None, action='store'):
+    def __init__(self, name='', raw=False, default=NO_DEFAULT, fatal=False,
+                 help='', section=None, action='store'):
         self.name = name
         self.raw = raw
         self.fatal = fatal
@@ -457,7 +458,8 @@
             if len(parts) == self.length:
                 result = tuple(parts)
             else:
-                raise ValueError("Tuples need to be %d items long" % self.length)
+                raise ValueError(
+                    "Tuples need to be %d items long" % self.length)
         else:
             result = tuple(parts)
             # length is 0, so no length validation

=== modified file 'setup.py'
--- setup.py	2011-02-20 21:52:07 +0000
+++ setup.py	2011-06-13 13:44:12 +0000
@@ -1,18 +1,18 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 

=== modified file 'tests/__init__.py'
--- tests/__init__.py	2010-07-31 01:15:59 +0000
+++ tests/__init__.py	2011-06-13 13:44:12 +0000
@@ -1,17 +1,16 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
-

=== modified file 'tests/inischema/__init__.py'
--- tests/inischema/__init__.py	2011-01-10 12:50:01 +0000
+++ tests/inischema/__init__.py	2011-06-13 13:44:12 +0000
@@ -1,18 +1,18 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 """Tests! Who woulda said"""

=== modified file 'tests/inischema/test_attributed.py'
--- tests/inischema/test_attributed.py	2010-07-31 01:15:59 +0000
+++ tests/inischema/test_attributed.py	2011-06-13 13:44:12 +0000
@@ -1,18 +1,18 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 # in testfiles, putting docstrings on methods messes up with the
@@ -24,6 +24,7 @@
 
 from configglue.inischema.attributed import AttributedConfigParser
 
+
 class BaseTest(unittest.TestCase):
     """ Base class to keep common set-up """
     def setUp(self):
@@ -39,6 +40,7 @@
         self.config = AttributedConfigParser()
         self.config.readfp(StringIO(self.config_string))
 
+
 class TestAttributed(BaseTest):
     """ pretty basic tests of AttributedConfigParser """
     def test_config_before_parsing_is_plain(self):
@@ -48,6 +50,7 @@
                           for section in self.config.sections()],
                          [(section, sorted(rawConfig.items(section)))
                           for section in rawConfig.sections()])
+
     def test_config_after_parsing_is_attributed(self):
         self.config.parse_all()
         self.assertEqual(self.config.get('xyzzy',

=== modified file 'tests/inischema/test_glue.py'
--- tests/inischema/test_glue.py	2010-08-04 21:00:09 +0000
+++ tests/inischema/test_glue.py	2011-06-13 13:44:12 +0000
@@ -1,18 +1,18 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 # in testfiles, putting docstrings on methods messes up with the
@@ -24,6 +24,7 @@
 
 from configglue.inischema.glue import configglue
 
+
 class TestBase(unittest.TestCase):
     """ Base class to keep common set-up """
     def setUp(self):
@@ -34,6 +35,7 @@
     def tearDown(self):
         sys.argv = self.old_sys_argv
 
+
 class TestGlue(TestBase):
     ini = '''
 [blah]
@@ -57,6 +59,7 @@
                                            args=['', self.arg + '=5'])
         self.assertEqual(vars(options),
                          {self.opt: '5'})
+
     def test_help_is_displayed(self):
         sys.stdout = StringIO()
         try:
@@ -66,6 +69,7 @@
             sys.stdout = sys.__stdout__
         self.assertTrue('yadda yadda yadda yadda' in output)
 
+
 class TestCrazyGlue(TestGlue):
     ini = '''
 [bl-ah]
@@ -79,6 +83,7 @@
     arg = '--bl-ah_foo'
     opt = 'bl_ah_foo'
 
+
 class TestNoValue(TestGlue):
     ini = '''
 [blah]
@@ -90,14 +95,18 @@
 '''
     val = 3
 
+
 class TestGlue2(TestBase):
     ini = '[__main__]\na=1\n'
+
     def test_main(self):
         parser, options, args = configglue(self.file)
         self.assertEqual(options.a, '1')
 
+
 class TestGlue3(TestBase):
     ini = '[x]\na.help=hi\n'
+
     def test_empty(self):
         parser, options, args = configglue(self.file)
         self.assertEqual(options.x_a, '')
@@ -107,6 +116,7 @@
                                            args=['', '--x_a=1'])
         self.assertEqual(options.x_a, '1')
 
+
 class TestGlueBool(TestBase):
     ini = '''[__main__]
 foo.parser=bool
@@ -116,6 +126,7 @@
 bar.parser = bool
 bar.action = store_false
 '''
+
     def test_store_true(self):
         parser, options, args = configglue(self.file, args=['', '--foo'])
         self.assertEqual(options.foo, True)
@@ -135,6 +146,7 @@
 bar.parser = lines
 bar.action = append
 '''
+
     def test_nothing(self):
         parser, options, args = configglue(self.file)
         self.assertEqual(options.foo, [])
@@ -150,4 +162,3 @@
     def test_append(self):
         parser, options, args = configglue(self.file, args=['', '--bar=x'])
         self.assertEqual(options.bar, ['a', 'b', 'x'])
-

=== modified file 'tests/inischema/test_glue2glue.py'
--- tests/inischema/test_glue2glue.py	2011-01-10 12:45:09 +0000
+++ tests/inischema/test_glue2glue.py	2011-06-13 13:44:12 +0000
@@ -1,22 +1,23 @@
 # -*- coding: utf-8 -*-
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 import sys
+import textwrap
 import unittest
 from StringIO import StringIO
 
@@ -64,7 +65,12 @@
         self.assertEqual(vars(cg), vars(sg))
 
     def test_parser_unicode(self):
-        s = "[__main__]\nbar = zátrapa\nbar.parser = unicode\nbar.parser.args = utf-8"
+        s = textwrap.dedent("""
+            [__main__]
+            bar = zátrapa
+            bar.parser = unicode
+            bar.parser.args = utf-8
+        """)
         _, cg, _ = configglue(StringIO(s))
         _, sg, _ = schemaconfigglue(ini2schema(StringIO(s)))
         self.assertEqual(vars(cg), vars(sg))

=== modified file 'tests/inischema/test_parsers.py'
--- tests/inischema/test_parsers.py	2010-08-05 02:59:16 +0000
+++ tests/inischema/test_parsers.py	2011-06-13 13:44:12 +0000
@@ -1,18 +1,18 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 # in testfiles, putting docstrings on methods messes up with the
@@ -22,6 +22,7 @@
 
 from configglue.inischema import parsers
 
+
 class TestParsers(unittest.TestCase):
     def test_bool(self):
         for value in ('true', '1', 'on', 'yes',
@@ -44,4 +45,3 @@
 
     def test_lines_not_string(self):
         self.assertEqual(parsers.lines(42), 42)
-

=== modified file 'tests/inischema/test_typed.py'
--- tests/inischema/test_typed.py	2010-08-05 12:59:11 +0000
+++ tests/inischema/test_typed.py	2011-06-13 13:44:12 +0000
@@ -1,18 +1,18 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 # in testfiles, putting docstrings on methods messes up with the
@@ -24,13 +24,17 @@
 
 from configglue.inischema.typed import TypedConfigParser
 
+
 marker = object()
+
+
 def some_parser(value):
     if value == 'marker':
         return marker
     else:
         return None
 
+
 class BaseTest(unittest.TestCase):
     """ Base class to keep common set-up """
     def setUp(self):
@@ -67,6 +71,7 @@
         self.config = TypedConfigParser()
         self.config.readfp(StringIO(self.config_string))
 
+
 class TestBackwardsCompat(BaseTest):
     """ rather basic backwards compatibility checker
     """
@@ -78,26 +83,32 @@
                          [(section, sorted(rawConfig.items(section)))
                           for section in rawConfig.sections()])
 
+
 class TestParserd(BaseTest):
     """Test the different parsing situations"""
     def test_some_builtin_parser(self):
         self.config.parse('xyzzy', 'bar')
         self.assertEqual(self.config.get('xyzzy', 'bar').value, 2)
+
     def test_add_second_custom_parser_fails(self):
         self.config.add_parser('some.parser', some_parser)
         self.assertRaises(ValueError, self.config.add_parser,
                           'some.parser', some_parser)
+
     def test_custom_parser(self):
         self.config.add_parser('some.parser', some_parser)
         self.config.parse('xyzzy', 'baz')
         self.assertEqual(self.config.get('xyzzy', 'baz').value, marker)
+
     def test_value_is_default_if_empty(self):
         self.config.parse('xyzzy', 'foo')
         self.assertEqual(self.config.get('xyzzy', 'foo').value, 1j)
+
     def test_parse_default_parser(self):
         self.config.add_parser('some.parser', some_parser)
         self.config.parse('xyzzy', 'woof')
         self.assertTrue(self.config.get('xyzzy', 'woof').value)
+
     def test_parse_all_parses_all(self):
         self.config.add_parser('some.parser', some_parser)
         self.config.add_parser('more.parser', some_parser)
@@ -115,6 +126,7 @@
                                      ('thud', None),
                                      ('woof', True),
                                      ])])
+
     def test_add_multiple_parsers(self):
         self.config.add_parsers(('some.parser', some_parser),
                                 ('more.parser', some_parser))
@@ -122,11 +134,13 @@
         self.config.parse('xyzzy', 'baz2')
         self.assertEqual(self.config.get('xyzzy', 'baz').value, marker)
         self.assertEqual(self.config.get('xyzzy', 'baz2').value, None)
+
     def test_add_mutliple_with_repeat_without_clobber(self):
         self.assertRaises(ValueError,
                           self.config.add_parsers,
                           ('some.parser', some_parser),
                           ('some.parser', some_parser))
+
     def test_add_multiple_with_repeat_with_clobber(self):
         self.config.add_parsers(('some.parser', some_parser),
                                 ('some.parser', bool, True))

=== modified file 'tests/pyschema/__init__.py'
--- tests/pyschema/__init__.py	2010-08-04 12:42:29 +0000
+++ tests/pyschema/__init__.py	2011-06-13 13:44:12 +0000
@@ -1,16 +1,16 @@
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################

=== modified file 'tests/pyschema/test_parser.py'
--- tests/pyschema/test_parser.py	2011-06-07 21:16:16 +0000
+++ tests/pyschema/test_parser.py	2011-06-13 13:44:12 +0000
@@ -1,24 +1,25 @@
 # -*- coding: utf-8 -*-
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 import os
 import shutil
 import tempfile
+import textwrap
 import unittest
 from ConfigParser import (
     DEFAULTSECT,
@@ -148,7 +149,8 @@
             f.write("[__main__]\nbaz=3")
             f.close()
 
-            config = StringIO("[__main__]\nfoo=4\nincludes=%s/first.cfg" % folder)
+            config = StringIO(
+                "[__main__]\nfoo=4\nincludes=%s/first.cfg" % folder)
             return config, folder
 
         class MySchema(Schema):
@@ -220,8 +222,8 @@
         rawval = '%(bar)'
         vars = {'foo': '%(bar)s', 'bar': 'pepe'}
         parser = SchemaConfigParser(MySchema())
-        self.assertRaises(InterpolationSyntaxError, parser._interpolate, section, option,
-                          rawval, vars)
+        self.assertRaises(InterpolationSyntaxError, parser._interpolate,
+            section, option, rawval, vars)
 
     def test_interpolate_across_sections(self):
         class MySchema(Schema):
@@ -309,7 +311,8 @@
     def test_get_interpolation_keys_tuple_lines(self):
         class MySchema(Schema):
             foo = LinesConfigOption(item=TupleConfigOption(2))
-        config = StringIO("[__main__]\nfoo=%(bar)s,%(bar)s\n    %(baz)s,%(baz)s")
+        config = StringIO(
+            "[__main__]\nfoo=%(bar)s,%(bar)s\n    %(baz)s,%(baz)s")
         expected = ('%(bar)s,%(bar)s\n%(baz)s,%(baz)s',
                     set(['bar', 'baz']))
 
@@ -321,7 +324,14 @@
     def test_get_interpolation_keys_dict(self):
         class MySchema(Schema):
             foo = DictConfigOption(spec={'a': IntConfigOption()})
-        config = StringIO("[__noschema__]\nbar=4\n[__main__]\nfoo=mydict\n[mydict]\na=%(bar)s")
+        config = StringIO(textwrap.dedent("""
+            [__noschema__]
+            bar=4
+            [__main__]
+            foo=mydict
+            [mydict]
+            a=%(bar)s
+            """))
         expected = ('mydict', set([]))
 
         parser = SchemaConfigParser(MySchema())
@@ -332,7 +342,8 @@
     def test_interpolate_value_duplicate_key(self):
         class MySchema(Schema):
             foo = TupleConfigOption(2)
-        config = StringIO("[__noschema__]\nbar=4\n[__main__]\nfoo=%(bar)s,%(bar)s")
+        config = StringIO(
+            "[__noschema__]\nbar=4\n[__main__]\nfoo=%(bar)s,%(bar)s")
         expected_value = '4,4'
 
         parser = SchemaConfigParser(MySchema())
@@ -366,7 +377,6 @@
             value = parser._interpolate_value('__main__', 'foo')
             self.assertEqual(value, None)
 
-
     def test_get_with_raw_value(self):
         class MySchema(Schema):
             foo = StringConfigOption(raw=True)
@@ -381,7 +391,14 @@
     def test_interpolate_parse_dict(self):
         class MySchema(Schema):
             foo = DictConfigOption(spec={'a': IntConfigOption()})
-        config = StringIO("[__noschema__]\nbar=4\n[__main__]\nfoo=mydict\n[mydict]\na=%(bar)s")
+        config = StringIO(textwrap.dedent("""
+            [__noschema__]
+            bar=4
+            [__main__]
+            foo=mydict
+            [mydict]
+            a=%(bar)s
+            """))
         expected = {'__main__': {'foo': {'a': 4}}}
 
         parser = SchemaConfigParser(MySchema())
@@ -512,14 +529,17 @@
         self.assertEqual(value, expected_value)
 
     def test_parse_invalid_section(self):
-        self.assertRaises(NoSectionError, self.parser.parse, 'bar', 'baz', '1')
+        self.assertRaises(NoSectionError, self.parser.parse,
+            'bar', 'baz', '1')
 
     def test_default_values(self):
         class MySchema(Schema):
             foo = BoolConfigOption(default=True)
+
             class bar(ConfigSection):
                 baz = IntConfigOption()
                 bla = StringConfigOption(default='hello')
+
         schema = MySchema()
         config = StringIO("[bar]\nbaz=123")
         expected_values = {'__main__': {'foo': True},
@@ -529,7 +549,9 @@
         self.assertEquals(expected_values, parser.values())
 
         config = StringIO("[bar]\nbla=123")
-        expected = {'__main__': {'foo': True}, 'bar': {'baz': 0, 'bla': '123'}}
+        expected = {
+            '__main__': {'foo': True},
+            'bar': {'baz': 0, 'bla': '123'}}
         parser = SchemaConfigParser(schema)
         parser.readfp(config)
         self.assertEquals(expected, parser.values())
@@ -698,7 +720,8 @@
             f.close()
 
             self.parser.read(filename)
-            self.assertEqual(self.parser.values(), {'__main__': {'foo': u'€'}})
+            self.assertEqual(self.parser.values(),
+                {'__main__': {'foo': u'€'}})
         finally:
             # destroy config file
             os.remove(filename)
@@ -742,10 +765,13 @@
     def test_write(self):
         class MySchema(Schema):
             foo = StringConfigOption()
+
             class DEFAULTSECT(ConfigSection):
                 pass
+
         parser = SchemaConfigParser(MySchema())
-        expected = u"[{0}]\nbaz = 2\n\n[__main__]\nfoo = bar".format(DEFAULTSECT)
+        expected = u"[{0}]\nbaz = 2\n\n[__main__]\nfoo = bar".format(
+            DEFAULTSECT)
         config = StringIO(expected)
         parser.readfp(config)
 
@@ -873,7 +899,8 @@
             foo = IntConfigOption()
 
         config = StringIO("[__main__]\nfoo=5\nbar=6")
-        errors = ["Configuration includes invalid options for section '__main__': bar"]
+        errors = ["Configuration includes invalid options for "
+                  "section '__main__': bar"]
         expected = (False, errors)
 
         parser = SchemaConfigParser(MySchema())
@@ -972,7 +999,8 @@
 
     def test_extra_sections_with_nested_dicts_strict(self):
         class MySchema(Schema):
-            foo = DictConfigOption(spec={'bar': DictConfigOption()}, strict=True)
+            foo = DictConfigOption(spec={'bar': DictConfigOption()},
+                strict=True)
 
         config = StringIO("""
 [__main__]
@@ -1015,8 +1043,7 @@
         self.assertEqual(parser.values(),
             {'__main__': {'foo': [
                 {'bar': {'wham': '1'}},
-                {'baz': {'whaz': '2'}}
-            ]}})
+                {'baz': {'whaz': '2'}}]}})
         self.assertTrue(parser.is_valid())
 
     def test_extra_sections_when_dict_with_nested_lines_dicts(self):
@@ -1075,8 +1102,7 @@
         self.assertEqual(parser.values(),
             {'__main__': {'foo': [
                 {'bar': [{'wham': '1'}, {'whaz': '2'}]},
-                {'baz': [{'whoosh': '3'}, {'swoosh': '4'}]}
-            ]}})
+                {'baz': [{'whoosh': '3'}, {'swoosh': '4'}]}]}})
         self.assertTrue(parser.is_valid())
 
     def test_multiple_extra_sections(self):
@@ -1093,7 +1119,8 @@
         self.assertTrue(parser.is_valid())
 
     def test_noschema_section(self):
-        config = StringIO("[__main__]\nfoo=%(bar)s\n[__noschema__]\nbar=hello")
+        config = StringIO(
+            "[__main__]\nfoo=%(bar)s\n[__noschema__]\nbar=hello")
         parser = SchemaConfigParser(self.schema)
         parser.readfp(config)
         parser.parse_all()

=== modified file 'tests/pyschema/test_schema.py'
--- tests/pyschema/test_schema.py	2011-06-07 21:16:16 +0000
+++ tests/pyschema/test_schema.py	2011-06-13 13:44:12 +0000
@@ -1,19 +1,19 @@
 # -*- coding: utf-8 -*-
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 import unittest
@@ -42,11 +42,13 @@
         class MyOtherSchema(Schema):
             class web(ConfigSection):
                 bar = IntConfigOption()
+
             class froo(ConfigSection):
                 twaddle = LinesConfigOption(item=BoolConfigOption())
 
         class MyThirdSchema(Schema):
             bar = IntConfigOption()
+
             class froo(ConfigSection):
                 twaddle = LinesConfigOption(item=BoolConfigOption())
 
@@ -80,6 +82,7 @@
     def test_names(self):
         class MySchema(Schema):
             foo = BoolConfigOption()
+
             class bar(ConfigSection):
                 baz = IntConfigOption()
 
@@ -93,6 +96,7 @@
     def test_options(self):
         class MySchema(Schema):
             foo = BoolConfigOption()
+
             class bar(ConfigSection):
                 baz = IntConfigOption()
 
@@ -111,6 +115,7 @@
     def test_equal(self):
         class MySchema(Schema):
             foo = IntConfigOption()
+
         class OtherSchema(Schema):
             bar = IntConfigOption()
 
@@ -122,8 +127,10 @@
     def test_get_config_objects(self):
         class MySchema(Schema):
             foo = IntConfigOption()
+
             class one(ConfigSection):
                 bar = IntConfigOption()
+
             two = ConfigSection()
             two.bam = IntConfigOption()
 
@@ -179,9 +186,11 @@
         class SchemaA(Schema):
             class foo(ConfigSection):
                 bar = IntConfigOption()
+
         class SchemaB(SchemaA):
             class baz(ConfigSection):
                 wham = IntConfigOption()
+
         class SchemaC(SchemaA):
             class bar(ConfigSection):
                 woof = IntConfigOption()
@@ -217,6 +226,7 @@
         class SchemaA(Schema):
             class foo(ConfigSection):
                 bar = IntConfigOption()
+
             bar = IntConfigOption()
 
         class SchemaB(SchemaA):
@@ -305,6 +315,7 @@
     def test_parse_int(self):
         class MySchema(Schema):
             foo = IntConfigOption()
+
         config = StringIO("[__main__]\nfoo = 42")
         expected_values = {'__main__': {'foo': 42}}
         schema = MySchema()
@@ -339,6 +350,7 @@
     def test_parse_bool(self):
         class MySchema(Schema):
             foo = BoolConfigOption()
+
         config = StringIO("[__main__]\nfoo = Yes")
         expected_values = {'__main__': {'foo': True}}
         schema = MySchema()
@@ -389,6 +401,7 @@
     def test_parse_bool_lines(self):
         class MySchema(Schema):
             foo = LinesConfigOption(item=BoolConfigOption())
+
         schema = MySchema()
         config = StringIO("[__main__]\nfoo = tRuE\n No\n 0\n 1")
         expected_values = {'__main__': {'foo': [True, False, False, True]}}
@@ -399,6 +412,7 @@
     def test_parse_bool_empty_lines(self):
         class MySchema(Schema):
             foo = LinesConfigOption(item=BoolConfigOption())
+
         schema = MySchema()
         config = StringIO("[__main__]\nfoo =")
         parser = SchemaConfigParser(schema)
@@ -409,6 +423,7 @@
     def test_parse_bool_invalid_lines(self):
         class MySchema(Schema):
             foo = LinesConfigOption(item=BoolConfigOption())
+
         schema = MySchema()
         config = StringIO("[__main__]\nfoo = bla")
         parser = SchemaConfigParser(schema)
@@ -428,6 +443,7 @@
         class MySchema(Schema):
             foo = LinesConfigOption(item=StringConfigOption(),
                                     remove_duplicates=True)
+
         schema = MySchema()
         config = StringIO("[__main__]\nfoo = bla\n blah\n bla")
         parser = SchemaConfigParser(schema)
@@ -439,6 +455,7 @@
         class MyOtherSchema(Schema):
             foo = LinesConfigOption(item=DictConfigOption(),
                                     remove_duplicates=True)
+
         schema = MyOtherSchema()
         config = StringIO("[__main__]\nfoo = bla\n bla\n[bla]\nbar = baz")
         parser = SchemaConfigParser(schema)
@@ -478,6 +495,7 @@
     def test_parse_tuple(self):
         class MySchema(Schema):
             foo = TupleConfigOption(length=4)
+
         config = StringIO('[__main__]\nfoo = 1, 2, 3, 4')
         expected_values = {'__main__': {'foo': ('1', '2', '3', '4')}}
         schema = MySchema()
@@ -550,6 +568,7 @@
                 'baz': IntConfigOption(),
                 'bla': BoolConfigOption(),
             })
+
         config = StringIO("""[__main__]
 foo = mydict
 [mydict]
@@ -559,9 +578,7 @@
 """)
         expected_values = {
             '__main__': {
-                'foo': {'bar': 'baz', 'baz': 42, 'bla': True}
-            }
-        }
+                'foo': {'bar': 'baz', 'baz': 42, 'bla': True}}}
 
         schema = MySchema()
         parser = SchemaConfigParser(schema)
@@ -575,6 +592,7 @@
                 'baz': IntConfigOption(),
                 'bla': BoolConfigOption(),
             })
+
         config = StringIO("""[__main__]
 foo = mydict
 [mydict]
@@ -702,6 +720,7 @@
                     'baz': IntConfigOption(),
                     'bla': BoolConfigOption(),
                 }))
+
         config = StringIO("""[__main__]
 foo = mylist0
       mylist1
@@ -734,8 +753,10 @@
         spec = {'name': StringConfigOption(),
                 'size': IntConfigOption(),
                 'options': DictConfigOption(spec=innerspec)}
+
         class MySchema(Schema):
             foo = DictConfigOption(spec=spec)
+
         config = StringIO("""[__main__]
 foo = outerdict
 [outerdict]
@@ -758,6 +779,7 @@
     def setUp(self):
         class MySchema(Schema):
             foo = LinesConfigOption(item=TupleConfigOption(length=3))
+
         schema = MySchema()
         self.parser = SchemaConfigParser(schema)
 
@@ -778,4 +800,3 @@
         expected_values = {'__main__': {'foo': [()]}}
         self.parser.readfp(config)
         self.assertEqual(self.parser.values(), expected_values)
-

=== modified file 'tests/pyschema/test_schemaconfig.py'
--- tests/pyschema/test_schemaconfig.py	2011-05-19 08:44:58 +0000
+++ tests/pyschema/test_schemaconfig.py	2011-06-13 13:44:12 +0000
@@ -1,19 +1,19 @@
 # -*- coding: utf-8 -*-
 ###############################################################################
-# 
+#
 # configglue -- glue for your apps' configuration
-# 
+#
 # A library for simple, DRY configuration of applications
-# 
+#
 # (C) 2009--2010 by Canonical Ltd.
 # originally by John R. Lenton <john.lenton@xxxxxxxxxxxxx>
 # incorporating schemaconfig as configglue.pyschema
 # schemaconfig originally by Ricardo Kirkner <ricardo.kirkner@xxxxxxxxxxxxx>
-# 
+#
 # Released under the BSD License (see the file LICENSE)
-# 
+#
 # For bug reports, support, and new releases: http://launchpad.net/configglue
-# 
+#
 ###############################################################################
 
 import unittest
@@ -206,7 +206,8 @@
 class ConfigglueTestCase(unittest.TestCase):
     @patch('configglue.pyschema.glue.SchemaConfigParser')
     @patch('configglue.pyschema.glue.schemaconfigglue')
-    def test_configglue_no_errors(self, mock_schemaconfigglue, mock_schema_parser):
+    def test_configglue_no_errors(self, mock_schemaconfigglue,
+        mock_schema_parser):
         # prepare mocks
         expected_schema_parser = Mock()
         expected_schema_parser.is_valid.return_value = (True, None)
@@ -232,14 +233,16 @@
         mock_schema_parser.assert_called_with(MySchema())
         mock_schema_parser.return_value.read.assert_called_with(configs)
         # the other attributes are the result of calling schemaconfigglue
-        mock_schemaconfigglue.assert_called_with(expected_schema_parser, op=None)
+        mock_schemaconfigglue.assert_called_with(expected_schema_parser,
+            op=None)
         self.assertEqual(glue.option_parser, expected_option_parser)
         self.assertEqual(glue.options, expected_options)
         self.assertEqual(glue.args, expected_args)
 
     @patch('configglue.pyschema.glue.SchemaConfigParser')
     @patch('configglue.pyschema.glue.schemaconfigglue')
-    def test_configglue_with_errors(self, mock_schemaconfigglue, mock_schema_parser):
+    def test_configglue_with_errors(self, mock_schemaconfigglue,
+        mock_schema_parser):
         # prepare mocks
         expected_schema_parser = Mock()
         expected_schema_parser.is_valid.return_value = (False, ['some error'])
@@ -265,7 +268,8 @@
         mock_schema_parser.assert_called_with(MySchema())
         mock_schema_parser.return_value.read.assert_called_with(configs)
         # the other attributes are the result of calling schemaconfigglue
-        mock_schemaconfigglue.assert_called_with(expected_schema_parser, op=None)
+        mock_schemaconfigglue.assert_called_with(expected_schema_parser,
+            op=None)
         self.assertEqual(glue.option_parser, expected_option_parser)
         expected_option_parser.error.assert_called_with('some error')
         self.assertEqual(glue.options, expected_options)
@@ -282,8 +286,8 @@
         expected_option_parser = mock_option_parser.return_value
         expected_options = Mock()
         expected_args = Mock()
-        mock_schemaconfigglue.return_value = (expected_option_parser, expected_options,
-            expected_args)
+        mock_schemaconfigglue.return_value = (expected_option_parser,
+            expected_options, expected_args)
         mock_schema_parser.return_value = expected_schema_parser
 
         # define the inputs
@@ -307,4 +311,3 @@
         self.assertEqual(glue.option_parser, expected_option_parser)
         self.assertEqual(glue.options, expected_options)
         self.assertEqual(glue.args, expected_args)
-


Follow ups