Compare commits

..

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
26e6c41e3c
!18 [sync] PR-16: fix test with python 3.11
From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
2025-02-08 03:52:49 +00:00
Funda Wang
86eb77a55c fix test with python 3.11
(cherry picked from commit d4fcaab0388b48e77e23dd9544fd31fac97cfe9e)
2025-02-06 11:20:27 +08:00
openeuler-ci-bot
a494a65431
!15 [sync] PR-11: [sync] PR-10: License compliance rectification
From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
2024-12-06 08:18:14 +00:00
wangjiang
7ba435fb41 License compliance rectification
(cherry picked from commit c61c2a7a1aa6049ee65d0be6704a9d78cd2e636d)
(cherry picked from commit 2a8db2f320c5bfcd60014e2d5cb3321e4fade60f)
2024-12-06 10:08:58 +08:00
openeuler-ci-bot
c0d88e30a6
!13 [sync] PR-12: fix bug in classifiers
From: @openeuler-sync-bot 
Reviewed-by: @jack0240, @gaoruoshu 
Signed-off-by: @gaoruoshu
2024-11-19 08:54:19 +00:00
x30004928
0110b35a32 fix bug in classifiers
(cherry picked from commit 66f9126d883e4dace1299787c9c04ea4a434e672)
2024-11-19 16:36:51 +08:00
openeuler-ci-bot
43fbb21ccf !4 update release to 0.5
Merge pull request !4 from tianwei/master
2020-07-30 18:31:29 +08:00
zhanliwen
42f94a7821 update to 0.5 2020-07-30 14:38:10 +08:00
openeuler-ci-bot
bd099f734a !3 add yaml file in package
Merge pull request !3 from Markeryang/master
2020-06-28 11:42:36 +08:00
Markeryang
b25668c753 add python-iniparse.yaml. 2020-06-13 11:49:47 +08:00
10 changed files with 191 additions and 671 deletions

View File

@ -0,0 +1,96 @@
From d9a083bafaa2df338a3176ee9f1433718b3a1090 Mon Sep 17 00:00:00 2001
From: Jiri Hnidek <jhnidek@redhat.com>
Date: Wed, 11 May 2022 14:29:27 +0200
Subject: [PATCH 06/13] Fix compatibility issues with Python 3.11
* Fixes: https://github.com/candlepin/python-iniparse/issues/23
* BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2019017
* Replaced few deprecated methods with new methods
---
tests/test_compat.py | 20 ++++++++++----------
tests/test_fuzz.py | 2 +-
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/tests/test_compat.py b/tests/test_compat.py
index ad36683..c8e6aca 100644
--- a/tests/test_compat.py
+++ b/tests/test_compat.py
@@ -96,16 +96,16 @@ class TestCaseBase(unittest.TestCase):
eq(cf.get('Spaces', 'key with spaces'), 'value')
eq(cf.get('Spaces', 'another with spaces'), 'splat!')
- self.failIf('__name__' in cf.options("Foo Bar"),
+ self.assertFalse('__name__' in cf.options("Foo Bar"),
'__name__ "option" should not be exposed by the API!')
# Make sure the right things happen for remove_option();
# added to include check for SourceForge bug #123324:
- self.failUnless(cf.remove_option('Foo Bar', 'foo'),
+ self.assertTrue(cf.remove_option('Foo Bar', 'foo'),
"remove_option() failed to report existance of option")
- self.failIf(cf.has_option('Foo Bar', 'foo'),
+ self.assertFalse(cf.has_option('Foo Bar', 'foo'),
"remove_option() failed to remove option")
- self.failIf(cf.remove_option('Foo Bar', 'foo'),
+ self.assertFalse(cf.remove_option('Foo Bar', 'foo'),
"remove_option() failed to report non-existance of option"
" that was removed")
@@ -127,10 +127,10 @@ class TestCaseBase(unittest.TestCase):
eq(cf.options("a"), ["b"])
eq(cf.get("a", "b"), "value",
"could not locate option, expecting case-insensitive option names")
- self.failUnless(cf.has_option("a", "b"))
+ self.assertTrue(cf.has_option("a", "b"))
cf.set("A", "A-B", "A-B value")
for opt in ("a-b", "A-b", "a-B", "A-B"):
- self.failUnless(
+ self.assertTrue(
cf.has_option("A", opt),
"has_option() returned false for option which should exist")
eq(cf.options("A"), ["a-b"])
@@ -147,7 +147,7 @@ class TestCaseBase(unittest.TestCase):
# SF bug #561822:
cf = self.fromstring("[section]\nnekey=nevalue\n",
defaults={"key":"value"})
- self.failUnless(cf.has_option("section", "Key"))
+ self.assertTrue(cf.has_option("section", "Key"))
def test_default_case_sensitivity(self):
cf = self.newconfig({"foo": "Bar"})
@@ -182,7 +182,7 @@ class TestCaseBase(unittest.TestCase):
cf = self.newconfig()
self.assertEqual(cf.sections(), [],
"new ConfigParser should have no defined sections")
- self.failIf(cf.has_section("Foo"),
+ self.assertFalse(cf.has_section("Foo"),
"new ConfigParser should have no acknowledged sections")
self.assertRaises(ConfigParser.NoSectionError,
cf.options, "Foo")
@@ -221,8 +221,8 @@ class TestCaseBase(unittest.TestCase):
"E5=FALSE AND MORE"
)
for x in range(1, 5):
- self.failUnless(cf.getboolean('BOOLTEST', 't%d' % x))
- self.failIf(cf.getboolean('BOOLTEST', 'f%d' % x))
+ self.assertTrue(cf.getboolean('BOOLTEST', 't%d' % x))
+ self.assertFalse(cf.getboolean('BOOLTEST', 'f%d' % x))
self.assertRaises(ValueError,
cf.getboolean, 'BOOLTEST', 'e%d' % x)
diff --git a/tests/test_fuzz.py b/tests/test_fuzz.py
index df568bb..874ef2e 100644
--- a/tests/test_fuzz.py
+++ b/tests/test_fuzz.py
@@ -102,7 +102,7 @@ class TestFuzz(unittest.TestCase):
cc = compat.RawConfigParser()
cc.readfp(StringIO(s))
cc_py = configparser.RawConfigParser()
- cc_py.readfp(StringIO(s))
+ cc_py.read_file(StringIO(s))
# compare the two configparsers
self.assertEqualConfig(cc_py, cc)
# check that tidy does not change semantics
--
2.41.0

View File

@ -0,0 +1,29 @@
From 033c0aa3e1a51cb70a97762252059e70cc2f671c Mon Sep 17 00:00:00 2001
From: Daniel Garcia Moreno <daniel.garcia@suse.com>
Date: Wed, 20 Dec 2023 12:40:14 +0100
Subject: [PATCH] Fix tests with python 3.11.7
---
Backported to 0.5 (s/six/io/ below)
tests/test_compat.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tests/test_compat.py b/tests/test_compat.py
index 8d7c785..86d0524 100644
--- a/tests/test_compat.py
+++ b/tests/test_compat.py
@@ -1,3 +1,4 @@
+import os
from iniparse import compat as ConfigParser
from six import StringIO
try:
@@ -263,6 +264,8 @@ class mystr(str):
def test_read_returns_file_list(self):
file1 = test_support.findfile("cfgparser.1")
+ if not os.path.exists(file1):
+ file1 = test_support.findfile("configdata/cfgparser.1")
# check when we pass a mix of readable and non-readable files:
cf = self.newconfig()
parsed_files = cf.read([file1, "nonexistant-file"])

View File

@ -0,0 +1,29 @@
From fdc577c9471b801040ded53b379ae8e56c43699e Mon Sep 17 00:00:00 2001
From: Jiri Hnidek <jhnidek@redhat.com>
Date: Wed, 29 Jan 2020 15:34:46 +0100
Subject: [PATCH] Fix bug in classifiers.
---
setup.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/setup.py b/setup.py
index 92a0761..ff567a2 100644
--- a/setup.py
+++ b/setup.py
@@ -28,8 +28,10 @@ use.''',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.3',
- 'Programming Language :: Python :: 3.4',
+ 'Programming Language :: Python :: 3.5',
+ 'Programming Language :: Python :: 3.6',
+ 'Programming Language :: Python :: 3.7',
+ 'Programming Language :: Python :: 3.8',
'Topic :: Software Development :: Libraries :: Python Modules',
],
packages = ['iniparse'],
--
2.27.0

View File

@ -1,26 +0,0 @@
From 7483d7f92ea59458c11506999a5895ed87bf8d6b Mon Sep 17 00:00:00 2001
From: Jiri Hnidek <jhnidek@redhat.com>
Date: Fri, 18 May 2018 13:31:31 +0200
Subject: [PATCH] First patch from Fedora Project.
---
tests/test_ini.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tests/test_ini.py b/tests/test_ini.py
index 6a76edb..78b2b3c 100644
--- a/tests/test_ini.py
+++ b/tests/test_ini.py
@@ -144,8 +144,7 @@ class test_comment_line(unittest.TestCase):
'#this is a comment',
';; this is also a comment',
'; so is this ',
- 'Rem and this',
- 'remthis too!'
+ 'Rem and this'
]
def test_parsing(self):
for l in self.lines:
--
2.19.1

Binary file not shown.

BIN
iniparse-0.5.tar.gz Normal file

Binary file not shown.

View File

@ -1,23 +1,17 @@
#spec for tarball
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
Name: python-iniparse
Version: 0.4
Release: 36
Version: 0.5
Release: 4
Summary: Python Module for Accessing and Modifying Configuration Data in INI files
License: MIT and PSF
URL: http://code.google.com/p/iniparse/
Source0: http://iniparse.googlecode.com/files/iniparse-%{version}.tar.gz
License: MIT AND Python-2.0
URL: https://github.com/candlepin/python-iniparse
Source0: https://files.pythonhosted.org/packages/source/i/iniparse/iniparse-%{version}.tar.gz
Patch0: backport-fix-bug-in-classifiers.patch
Patch1: backport-Fix-compatibility-issues-with-Python-3.11.patch
Patch2: backport-Fix-tests-with-python-3.12.1.patch
BuildArch: noarch
# PATCH-FIX-UPSTREAM
Patch0: fix-handle-REMXXXX-is-not-comment.patch
# PATCH-FIX-UPSTREAM
Patch1: python3-compat.patch
# PATCH-FIX-UPSTREAM
Patch2: setup-fixes.patch
%description
iniparse is an INI parser for Python which is API compatible
with the standard library's ConfigParser, preserves structure of INI
@ -25,15 +19,6 @@ files (order of sections & options, indentation, comments, and blank
lines are preserved when data is updated), and is more convenient to
use.
%package -n python2-iniparse
Summary: Python 2 version of python-iniparse
%{?python_provide:%python_provide python2-iniparse}
BuildRequires: python2-devel python2-setuptools python2-six python2-test
Requires: python2-six
%description -n python2-iniparse
This package is the python2 version of python-iniparse.
%package -n python3-iniparse
Summary: Python 3 version of python-iniparse
@ -49,36 +34,47 @@ This package is the python3 version of python-iniparse.
%prep
%autosetup -n iniparse-%{version} -p1
%build
%py2_build
%py3_build
%install
%py2_install
%py3_install
rm -fr %{buildroot}%{_datadir}/doc
%check
%{__python2} runtests.py
export PYTHONPATH=%{buildroot}%{python3_sitelib}
%{__python3} runtests.py
%files -n python2-iniparse
%defattr(-,root,root,-)
%license LICENSE LICENSE-PSF
%{python2_sitelib}/iniparse
%{python2_sitelib}/iniparse-%{version}-py*.egg-info
%files -n python3-iniparse
%defattr(-,root,root,-)
%license LICENSE LICENSE-PSF
%{python3_sitelib}/iniparse
%{python3_sitelib}/iniparse-%{version}-py*.egg-info
%files help
%doc README Changelog html/
%exclude %{_docdir}/iniparse-%{version}/
%doc Changelog html/
%changelog
* Thu Jan 23 2025 Funda Wang <fundawang@yeah.net> - 0.5-4
- fix test with python 3.11
* Wed Aug 14 2024 wangjiang <wangjiang37@h-partners.com> - 0.5-3
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:License compliance rectification
* Tue Nov 19 2024 xiangyuning<xiangyuning@huawei.com> - 0.5-2
- ID:NA
- SUG:NA
- DESC:fix bug in classifiers
* Wed Jul 29 2020 tianwei<tianwei12@huawei.com> - 0.5-1
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:update release to 0.5
* Fri Sep 27 2019 shenyangyang<shenyangyang4@huawei.com> - 0.4-36
- Type:enhancement
- ID:NA

4
python-iniparse.yaml Normal file
View File

@ -0,0 +1,4 @@
version_control: pypi
src_repo: iniparse
tag_prefix:
separator: .

View File

@ -1,547 +0,0 @@
From 9ea31e4d1267dd620814eceffabb5b7457ea9fae Mon Sep 17 00:00:00 2001
From: Jiri Hnidek <jhnidek@redhat.com>
Date: Fri, 18 May 2018 13:44:39 +0200
Subject: [PATCH] Third patch from Fedora Project (Python3).
---
iniparse/__init__.py | 20 ++++++++++----------
iniparse/compat.py | 30 ++++++++++++++++--------------
iniparse/config.py | 16 ++++++++--------
iniparse/configparser.py | 7 +++++++
iniparse/ini.py | 20 ++++++++++++--------
iniparse/utils.py | 4 ++--
tests/__init__.py | 14 +++++++-------
tests/test_compat.py | 23 +++++++++++++++--------
tests/test_fuzz.py | 18 +++++++++---------
tests/test_ini.py | 8 ++++----
tests/test_misc.py | 4 ++--
tests/test_tidy.py | 2 +-
tests/test_unicode.py | 10 +++++-----
13 files changed, 98 insertions(+), 78 deletions(-)
create mode 100644 iniparse/configparser.py
diff --git a/iniparse/__init__.py b/iniparse/__init__.py
index 8de756f..7193f92 100644
--- a/iniparse/__init__.py
+++ b/iniparse/__init__.py
@@ -3,17 +3,17 @@
# Copyright (c) 2007 Tim Lauridsen <tla@rasmil.dk>
# All Rights Reserved. See LICENSE-PSF & LICENSE for details.
-from ini import INIConfig, change_comment_syntax
-from config import BasicConfig, ConfigNamespace
-from compat import RawConfigParser, ConfigParser, SafeConfigParser
-from utils import tidy
+from .ini import INIConfig, change_comment_syntax
+from .config import BasicConfig, ConfigNamespace
+from .compat import RawConfigParser, ConfigParser, SafeConfigParser
+from .utils import tidy
-from ConfigParser import DuplicateSectionError, \
- NoSectionError, NoOptionError, \
- InterpolationMissingOptionError, \
- InterpolationDepthError, \
- InterpolationSyntaxError, \
- DEFAULTSECT, MAX_INTERPOLATION_DEPTH
+from .configparser import DuplicateSectionError, \
+ NoSectionError, NoOptionError, \
+ InterpolationMissingOptionError, \
+ InterpolationDepthError, \
+ InterpolationSyntaxError, \
+ DEFAULTSECT, MAX_INTERPOLATION_DEPTH
__all__ = [
'BasicConfig', 'ConfigNamespace',
diff --git a/iniparse/compat.py b/iniparse/compat.py
index db89ed8..f95c25c 100644
--- a/iniparse/compat.py
+++ b/iniparse/compat.py
@@ -12,19 +12,21 @@ The underlying INIConfig object can be accessed as cfg.data
"""
import re
-from ConfigParser import DuplicateSectionError, \
- NoSectionError, NoOptionError, \
- InterpolationMissingOptionError, \
- InterpolationDepthError, \
- InterpolationSyntaxError, \
- DEFAULTSECT, MAX_INTERPOLATION_DEPTH
+from .configparser import DuplicateSectionError, \
+ NoSectionError, NoOptionError, \
+ InterpolationMissingOptionError, \
+ InterpolationDepthError, \
+ InterpolationSyntaxError, \
+ DEFAULTSECT, MAX_INTERPOLATION_DEPTH
# These are imported only for compatiability.
# The code below does not reference them directly.
-from ConfigParser import Error, InterpolationError, \
- MissingSectionHeaderError, ParsingError
+from .configparser import Error, InterpolationError, \
+ MissingSectionHeaderError, ParsingError
-import ini
+import six
+
+from . import ini
class RawConfigParser(object):
def __init__(self, defaults=None, dict_type=dict):
@@ -56,7 +58,7 @@ class RawConfigParser(object):
# The default section is the only one that gets the case-insensitive
# treatment - so it is special-cased here.
if section.lower() == "default":
- raise ValueError, 'Invalid section name: %s' % section
+ raise ValueError('Invalid section name: %s' % section)
if self.has_section(section):
raise DuplicateSectionError(section)
@@ -88,7 +90,7 @@ class RawConfigParser(object):
filename may also be given.
"""
files_read = []
- if isinstance(filenames, basestring):
+ if isinstance(filenames, six.string_types):
filenames = [filenames]
for filename in filenames:
try:
@@ -143,7 +145,7 @@ class RawConfigParser(object):
def getboolean(self, section, option):
v = self.get(section, option)
if v.lower() not in self._boolean_states:
- raise ValueError, 'Not a boolean: %s' % v
+ raise ValueError('Not a boolean: %s' % v)
return self._boolean_states[v.lower()]
def has_option(self, section, option):
@@ -234,7 +236,7 @@ class ConfigParser(RawConfigParser):
if "%(" in value:
try:
value = value % vars
- except KeyError, e:
+ except KeyError as e:
raise InterpolationMissingOptionError(
option, section, rawval, e.args[0])
else:
@@ -283,7 +285,7 @@ class SafeConfigParser(ConfigParser):
_badpercent_re = re.compile(r"%[^%]|%$")
def set(self, section, option, value):
- if not isinstance(value, basestring):
+ if not isinstance(value, six.string_types):
raise TypeError("option values must be strings")
# check for bad percent signs:
# first, replace all "good" interpolations
diff --git a/iniparse/config.py b/iniparse/config.py
index 5cfa2ea..3b28549 100644
--- a/iniparse/config.py
+++ b/iniparse/config.py
@@ -143,7 +143,7 @@ class BasicConfig(ConfigNamespace):
>>> n.aaa = 42
>>> del n.x
- >>> print n
+ >>> print(n)
aaa = 42
name.first = paramjit
name.last = oberoi
@@ -152,7 +152,7 @@ class BasicConfig(ConfigNamespace):
>>> isinstance(n.name, ConfigNamespace)
True
- >>> print n.name
+ >>> print(n.name)
first = paramjit
last = oberoi
>>> sorted(list(n.name))
@@ -160,7 +160,7 @@ class BasicConfig(ConfigNamespace):
Finally, values can be read from a file as follows:
- >>> from StringIO import StringIO
+ >>> from six import StringIO
>>> sio = StringIO('''
... # comment
... ui.height = 100
@@ -171,7 +171,7 @@ class BasicConfig(ConfigNamespace):
... ''')
>>> n = BasicConfig()
>>> n._readfp(sio)
- >>> print n
+ >>> print(n)
complexity = medium
data.secret.password = goodness=gracious me
have_python
@@ -199,7 +199,7 @@ class BasicConfig(ConfigNamespace):
def __str__(self, prefix=''):
lines = []
- keys = self._data.keys()
+ keys = list(self._data.keys())
keys.sort()
for name in keys:
value = self._data[name]
@@ -258,7 +258,7 @@ def update_config(target, source):
>>> n.ui.display_clock = True
>>> n.ui.display_qlength = True
>>> n.ui.width = 150
- >>> print n
+ >>> print(n)
playlist.expand_playlist = True
ui.display_clock = True
ui.display_qlength = True
@@ -267,7 +267,7 @@ def update_config(target, source):
>>> from iniparse import ini
>>> i = ini.INIConfig()
>>> update_config(i, n)
- >>> print i
+ >>> print(i)
[playlist]
expand_playlist = True
<BLANKLINE>
@@ -277,7 +277,7 @@ def update_config(target, source):
width = 150
"""
- for name in source:
+ for name in sorted(source):
value = source[name]
if isinstance(value, ConfigNamespace):
if name in target:
diff --git a/iniparse/configparser.py b/iniparse/configparser.py
new file mode 100644
index 0000000..c543d50
--- /dev/null
+++ b/iniparse/configparser.py
@@ -0,0 +1,7 @@
+try:
+ from ConfigParser import *
+ # not all objects get imported with __all__
+ from ConfigParser import Error, InterpolationMissingOptionError
+except ImportError:
+ from configparser import *
+ from configparser import Error, InterpolationMissingOptionError
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
diff --git a/iniparse/utils.py b/iniparse/utils.py
index 829fc28..f8b773a 100644
--- a/iniparse/utils.py
+++ b/iniparse/utils.py
@@ -1,5 +1,5 @@
-import compat
-from ini import LineContainer, EmptyLine
+from . import compat
+from .ini import LineContainer, EmptyLine
def tidy(cfg):
"""Clean up blank lines.
diff --git a/tests/__init__.py b/tests/__init__.py
index f1fa321..88689fb 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,12 +1,12 @@
import unittest, doctest
-import test_ini
-import test_misc
-import test_fuzz
-import test_compat
-import test_unicode
-import test_tidy
-import test_multiprocessing
+from . import test_ini
+from . import test_misc
+from . import test_fuzz
+from . import test_compat
+from . import test_unicode
+from . import test_tidy
+from . import test_multiprocessing
from iniparse import config
from iniparse import ini
diff --git a/tests/test_compat.py b/tests/test_compat.py
index b8da3d5..b6dfb5c 100644
--- a/tests/test_compat.py
+++ b/tests/test_compat.py
@@ -1,9 +1,16 @@
from iniparse import compat as ConfigParser
-import StringIO
+from six import StringIO
+try:
+ import UserDict
+except ImportError:
+ import collections as UserDict
import unittest
-import UserDict
-from test import test_support
+import sys
+if sys.version_info[0] < 3:
+ from test import test_support
+else:
+ from test import support as test_support
class SortedDict(UserDict.UserDict):
def items(self):
@@ -35,7 +42,7 @@ class TestCaseBase(unittest.TestCase):
def fromstring(self, string, defaults=None):
cf = self.newconfig(defaults)
- sio = StringIO.StringIO(string)
+ sio = StringIO(string)
cf.readfp(sio)
return cf
@@ -161,7 +168,7 @@ class TestCaseBase(unittest.TestCase):
"No Section!\n")
def parse_error(self, exc, src):
- sio = StringIO.StringIO(src)
+ sio = StringIO(src)
self.assertRaises(exc, self.cf.readfp, sio)
def test_query_errors(self):
@@ -181,7 +188,7 @@ class TestCaseBase(unittest.TestCase):
def get_error(self, exc, section, option):
try:
self.cf.get(section, option)
- except exc, e:
+ except exc as e:
return e
else:
self.fail("expected exception type %s.%s"
@@ -227,7 +234,7 @@ class TestCaseBase(unittest.TestCase):
"foo: another very\n"
" long line"
)
- output = StringIO.StringIO()
+ output = StringIO()
cf.write(output)
self.assertEqual(
output.getvalue(),
@@ -465,7 +472,7 @@ class SortedTestCase(RawConfigParserTestCase):
"o1=4\n"
"[a]\n"
"k=v\n")
- output = StringIO.StringIO()
+ output = StringIO()
self.cf.write(output)
self.assertEquals(output.getvalue(),
"[a]\n"
diff --git a/tests/test_fuzz.py b/tests/test_fuzz.py
index 5420dcc..b219500 100644
--- a/tests/test_fuzz.py
+++ b/tests/test_fuzz.py
@@ -1,9 +1,10 @@
import re
import os
import random
+import sys
import unittest
-import ConfigParser
-from StringIO import StringIO
+from six import StringIO
+from six.moves import configparser
from iniparse import compat, ini, tidy
# TODO:
@@ -96,24 +97,25 @@ class test_fuzz(unittest.TestCase):
s = '\n'.join(good_lines)
cc = compat.RawConfigParser()
cc.readfp(StringIO(s))
- cc_py = ConfigParser.RawConfigParser()
+ cc_py = configparser.RawConfigParser()
cc_py.readfp(StringIO(s))
# compare the two configparsers
self.assertEqualConfig(cc_py, cc)
# check that tidy does not change semantics
tidy(cc)
- cc_tidy = ConfigParser.RawConfigParser()
+ cc_tidy = configparser.RawConfigParser()
cc_tidy.readfp(StringIO(str(cc.data)))
self.assertEqualConfig(cc_py, cc_tidy)
except AssertionError:
fname = 'fuzz-test-iter-%d.ini' % fuzz_iter
- print 'Fuzz test failed at iteration', fuzz_iter
- print 'Writing out failing INI file as', fname
+ print('Fuzz test failed at iteration', fuzz_iter)
+ print('Writing out failing INI file as', fname)
f = open(fname, 'w')
f.write(s)
f.close()
raise
+ @unittest.skipIf(sys.version_info[0] > 2, 'http://code.google.com/p/iniparse/issues/detail?id=22#c9')
def assertEqualConfig(self, c1, c2):
self.assertEqualSorted(c1.sections(), c2.sections())
self.assertEqualSorted(c1.defaults().items(), c2.defaults().items())
@@ -123,9 +125,7 @@ class test_fuzz(unittest.TestCase):
self.assertEqual(c1.get(sec, opt), c2.get(sec, opt))
def assertEqualSorted(self, l1, l2):
- l1.sort()
- l2.sort()
- self.assertEqual(l1, l2)
+ self.assertEqual(sorted(l1), sorted(l2))
class suite(unittest.TestSuite):
def __init__(self):
diff --git a/tests/test_ini.py b/tests/test_ini.py
index 78b2b3c..6d974f0 100644
--- a/tests/test_ini.py
+++ b/tests/test_ini.py
@@ -1,5 +1,5 @@
import unittest
-from StringIO import StringIO
+from six import StringIO
from iniparse import ini
from iniparse import compat
@@ -195,13 +195,13 @@ but = also me
self.assertEqual(p._data.find('section2').find('just').value, 'kidding')
itr = p._data.finditer('section1')
- v = itr.next()
+ v = next(itr)
self.assertEqual(v.find('help').value, 'yourself')
self.assertEqual(v.find('but').value, 'also me')
- v = itr.next()
+ v = next(itr)
self.assertEqual(v.find('help').value, 'me')
self.assertEqual(v.find('I\'m').value, 'desperate')
- self.assertRaises(StopIteration, itr.next)
+ self.assertRaises(StopIteration, next, itr)
self.assertRaises(KeyError, p._data.find, 'section')
self.assertRaises(KeyError, p._data.find('section2').find, 'ahem')
diff --git a/tests/test_misc.py b/tests/test_misc.py
index 31cf4da..96ef035 100644
--- a/tests/test_misc.py
+++ b/tests/test_misc.py
@@ -1,9 +1,9 @@
import re
import unittest
import pickle
-import ConfigParser
+from six.moves import configparser
+from six import StringIO
from textwrap import dedent
-from StringIO import StringIO
from iniparse import compat, ini
class CaseSensitiveConfigParser(compat.ConfigParser):
diff --git a/tests/test_tidy.py b/tests/test_tidy.py
index 7304747..26b6cde 100644
--- a/tests/test_tidy.py
+++ b/tests/test_tidy.py
@@ -1,6 +1,6 @@
import unittest
from textwrap import dedent
-from StringIO import StringIO
+from six import StringIO
from iniparse import tidy,INIConfig
from iniparse.ini import EmptyLine
diff --git a/tests/test_unicode.py b/tests/test_unicode.py
index a56fcab..14d4fbd 100644
--- a/tests/test_unicode.py
+++ b/tests/test_unicode.py
@@ -1,5 +1,5 @@
import unittest
-from StringIO import StringIO
+import six
from iniparse import compat, ini
class test_unicode(unittest.TestCase):
@@ -17,14 +17,14 @@ baz = Marc-Andr\202
"""
def basic_tests(self, s, strable):
- f = StringIO(s)
+ f = six.StringIO(s)
i = ini.INIConfig(f)
- self.assertEqual(unicode(i), s)
- self.assertEqual(type(i.foo.bar), unicode)
+ self.assertEqual(six.text_type(i), s)
+ self.assertEqual(type(i.foo.bar), six.text_type)
if strable:
self.assertEqual(str(i), str(s))
else:
- self.assertRaises(UnicodeEncodeError, lambda: str(i))
+ self.assertRaises(UnicodeEncodeError, lambda: six.text_type(i).encode('ascii'))
return i
def test_ascii(self):
--
2.19.1

View File

@ -1,61 +0,0 @@
From 07763b43ff35573564a4a2509c006b1e30fe59ee Mon Sep 17 00:00:00 2001
From: Jiri Hnidek <jhnidek@redhat.com>
Date: Fri, 18 May 2018 13:39:53 +0200
Subject: [PATCH] Second patch from Fedora Project.
---
PKG-INFO | 7 +++++--
setup.py | 10 +++++++---
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/PKG-INFO b/PKG-INFO
index 31c4ad2..bebcb80 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -18,7 +18,10 @@ Classifier: License :: OSI Approved :: MIT License
Classifier: License :: OSI Approved :: Python Software Foundation License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2.4
-Classifier: Programming Language :: Python :: 2.5
+Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/setup.py b/setup.py
index 736cfa1..e2f8de0 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-from distutils.core import setup
+from setuptools import setup
VERSION = '0.4'
@@ -24,12 +24,16 @@ use.''',
'License :: OSI Approved :: Python Software Foundation License',
'Operating System :: OS Independent',
'Programming Language :: Python',
- 'Programming Language :: Python :: 2.4',
- 'Programming Language :: Python :: 2.5',
+ 'Programming Language :: Python :: 2'
'Programming Language :: Python :: 2.6',
+ 'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.3',
+ 'Programming Language :: Python :: 3.4'
'Topic :: Software Development :: Libraries :: Python Modules',
],
packages = ['iniparse'],
+ install_requires=['six'],
data_files = [
('share/doc/iniparse-%s' % VERSION, ['README', 'LICENSE-PSF',
'LICENSE', 'Changelog',
--
2.19.1