diff options
author | Andrew Shadura <andrewsh@debian.org> | 2015-08-21 21:06:36 +0200 |
---|---|---|
committer | Andrew Shadura <andrewsh@debian.org> | 2015-08-21 21:51:11 +0200 |
commit | fef9b4532a1a6a03aab82711f52ebde3f2d131d7 (patch) | |
tree | a2dc839d368388f8b6eda5cc0af76fb4031f9061 /iniparse/ini.py | |
parent | 5a73ce28856b1663d5afeb252df053e644e54c94 (diff) |
Add Python 3 support.debian/0.4-2.2
Diffstat (limited to 'iniparse/ini.py')
-rw-r--r-- | iniparse/ini.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/iniparse/ini.py b/iniparse/ini.py index 408354d..052d9e9 100644 --- a/iniparse/ini.py +++ b/iniparse/ini.py @@ -7,7 +7,7 @@ Example: - >>> from StringIO import StringIO + >>> from six import StringIO >>> sio = StringIO('''# configure foo-application ... [foo] ... bar1 = qualia @@ -16,14 +16,14 @@ Example: ... special = 1''') >>> cfg = INIConfig(sio) - >>> print cfg.foo.bar1 + >>> print(cfg.foo.bar1) qualia - >>> print cfg['foo-ext'].special + >>> print(cfg['foo-ext'].special) 1 >>> cfg.foo.newopt = 'hi!' >>> cfg.baz.enabled = 0 - >>> print cfg + >>> print(cfg) # configure foo-application [foo] bar1 = qualia @@ -42,9 +42,11 @@ Example: # Backward-compatiable with ConfigParser import re -from ConfigParser import DEFAULTSECT, ParsingError, MissingSectionHeaderError +from .configparser import DEFAULTSECT, ParsingError, MissingSectionHeaderError -import config +import six + +from . import config class LineType(object): line = None @@ -278,6 +280,8 @@ class LineContainer(object): value = property(get_value, set_value) def __str__(self): + for c in self.contents: + pass#print(c.__str__()) s = [x.__str__() for x in self.contents] return '\n'.join(s) @@ -465,7 +469,7 @@ class INIConfig(config.ConfigNamespace): self._sections = {} if defaults is None: defaults = {} self._defaults = INISection(LineContainer(), optionxformsource=self) - for name, value in defaults.iteritems(): + for name, value in defaults.items(): self._defaults[name] = value if fp is not None: self._readfp(fp) @@ -551,7 +555,7 @@ class INIConfig(config.ConfigNamespace): for line in readline_iterator(fp): # Check for BOM on first line - if linecount == 0 and isinstance(line, unicode): + if linecount == 0 and isinstance(line, six.text_type): if line[0] == u'\ufeff': line = line[1:] self._bom = True |