Change-Id: I305bace7e0bbde2a437db2eb19e4c2009cfa6ff0
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/3231
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Divya Thaluru <dthaluru@vmware.com>
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,552 @@ |
0 |
+From 8a98e4d44a5e59439a4b6bd95368cc362412c995 Mon Sep 17 00:00:00 2001 |
|
1 |
+From: Alexander Kanavin <alex.kanavin@gmail.com> |
|
2 |
+Date: Fri, 24 Mar 2017 18:06:08 +0200 |
|
3 |
+Subject: [PATCH] Add python 3 compatibility. |
|
4 |
+ |
|
5 |
+Taken from |
|
6 |
+http://pkgs.fedoraproject.org/cgit/rpms/python-iniparse.git/tree/python-iniparse-python3-compat.patch |
|
7 |
+ |
|
8 |
+Upstream-Status: Inappropriate [upstream is defunct] |
|
9 |
+Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> |
|
10 |
+--- |
|
11 |
+ iniparse/__init__.py | 20 ++++++++++---------- |
|
12 |
+ iniparse/compat.py | 30 ++++++++++++++++-------------- |
|
13 |
+ iniparse/config.py | 16 ++++++++-------- |
|
14 |
+ iniparse/configparser.py | 7 +++++++ |
|
15 |
+ iniparse/ini.py | 20 ++++++++++++-------- |
|
16 |
+ iniparse/utils.py | 4 ++-- |
|
17 |
+ tests/__init__.py | 14 +++++++------- |
|
18 |
+ tests/test_compat.py | 23 +++++++++++++++-------- |
|
19 |
+ tests/test_fuzz.py | 18 +++++++++--------- |
|
20 |
+ tests/test_ini.py | 8 ++++---- |
|
21 |
+ tests/test_misc.py | 4 ++-- |
|
22 |
+ tests/test_tidy.py | 2 +- |
|
23 |
+ tests/test_unicode.py | 10 +++++----- |
|
24 |
+ 13 files changed, 98 insertions(+), 78 deletions(-) |
|
25 |
+ create mode 100644 iniparse/configparser.py |
|
26 |
+ |
|
27 |
+diff --git a/iniparse/__init__.py b/iniparse/__init__.py |
|
28 |
+index 8de756f..7193f92 100644 |
|
29 |
+--- a/iniparse/__init__.py |
|
30 |
+@@ -3,17 +3,17 @@ |
|
31 |
+ # Copyright (c) 2007 Tim Lauridsen <tla@rasmil.dk> |
|
32 |
+ # All Rights Reserved. See LICENSE-PSF & LICENSE for details. |
|
33 |
+ |
|
34 |
+-from ini import INIConfig, change_comment_syntax |
|
35 |
+-from config import BasicConfig, ConfigNamespace |
|
36 |
+-from compat import RawConfigParser, ConfigParser, SafeConfigParser |
|
37 |
+-from utils import tidy |
|
38 |
++from .ini import INIConfig, change_comment_syntax |
|
39 |
++from .config import BasicConfig, ConfigNamespace |
|
40 |
++from .compat import RawConfigParser, ConfigParser, SafeConfigParser |
|
41 |
++from .utils import tidy |
|
42 |
+ |
|
43 |
+-from ConfigParser import DuplicateSectionError, \ |
|
44 |
+- NoSectionError, NoOptionError, \ |
|
45 |
+- InterpolationMissingOptionError, \ |
|
46 |
+- InterpolationDepthError, \ |
|
47 |
+- InterpolationSyntaxError, \ |
|
48 |
+- DEFAULTSECT, MAX_INTERPOLATION_DEPTH |
|
49 |
++from .configparser import DuplicateSectionError, \ |
|
50 |
++ NoSectionError, NoOptionError, \ |
|
51 |
++ InterpolationMissingOptionError, \ |
|
52 |
++ InterpolationDepthError, \ |
|
53 |
++ InterpolationSyntaxError, \ |
|
54 |
++ DEFAULTSECT, MAX_INTERPOLATION_DEPTH |
|
55 |
+ |
|
56 |
+ __all__ = [ |
|
57 |
+ 'BasicConfig', 'ConfigNamespace', |
|
58 |
+diff --git a/iniparse/compat.py b/iniparse/compat.py |
|
59 |
+index db89ed8..f95c25c 100644 |
|
60 |
+--- a/iniparse/compat.py |
|
61 |
+@@ -12,19 +12,21 @@ The underlying INIConfig object can be accessed as cfg.data |
|
62 |
+ """ |
|
63 |
+ |
|
64 |
+ import re |
|
65 |
+-from ConfigParser import DuplicateSectionError, \ |
|
66 |
+- NoSectionError, NoOptionError, \ |
|
67 |
+- InterpolationMissingOptionError, \ |
|
68 |
+- InterpolationDepthError, \ |
|
69 |
+- InterpolationSyntaxError, \ |
|
70 |
+- DEFAULTSECT, MAX_INTERPOLATION_DEPTH |
|
71 |
++from .configparser import DuplicateSectionError, \ |
|
72 |
++ NoSectionError, NoOptionError, \ |
|
73 |
++ InterpolationMissingOptionError, \ |
|
74 |
++ InterpolationDepthError, \ |
|
75 |
++ InterpolationSyntaxError, \ |
|
76 |
++ DEFAULTSECT, MAX_INTERPOLATION_DEPTH |
|
77 |
+ |
|
78 |
+ # These are imported only for compatiability. |
|
79 |
+ # The code below does not reference them directly. |
|
80 |
+-from ConfigParser import Error, InterpolationError, \ |
|
81 |
+- MissingSectionHeaderError, ParsingError |
|
82 |
++from .configparser import Error, InterpolationError, \ |
|
83 |
++ MissingSectionHeaderError, ParsingError |
|
84 |
+ |
|
85 |
+-import ini |
|
86 |
++import six |
|
87 |
++ |
|
88 |
++from . import ini |
|
89 |
+ |
|
90 |
+ class RawConfigParser(object): |
|
91 |
+ def __init__(self, defaults=None, dict_type=dict): |
|
92 |
+@@ -56,7 +58,7 @@ class RawConfigParser(object): |
|
93 |
+ # The default section is the only one that gets the case-insensitive |
|
94 |
+ # treatment - so it is special-cased here. |
|
95 |
+ if section.lower() == "default": |
|
96 |
+- raise ValueError, 'Invalid section name: %s' % section |
|
97 |
++ raise ValueError('Invalid section name: %s' % section) |
|
98 |
+ |
|
99 |
+ if self.has_section(section): |
|
100 |
+ raise DuplicateSectionError(section) |
|
101 |
+@@ -88,7 +90,7 @@ class RawConfigParser(object): |
|
102 |
+ filename may also be given. |
|
103 |
+ """ |
|
104 |
+ files_read = [] |
|
105 |
+- if isinstance(filenames, basestring): |
|
106 |
++ if isinstance(filenames, six.string_types): |
|
107 |
+ filenames = [filenames] |
|
108 |
+ for filename in filenames: |
|
109 |
+ try: |
|
110 |
+@@ -143,7 +145,7 @@ class RawConfigParser(object): |
|
111 |
+ def getboolean(self, section, option): |
|
112 |
+ v = self.get(section, option) |
|
113 |
+ if v.lower() not in self._boolean_states: |
|
114 |
+- raise ValueError, 'Not a boolean: %s' % v |
|
115 |
++ raise ValueError('Not a boolean: %s' % v) |
|
116 |
+ return self._boolean_states[v.lower()] |
|
117 |
+ |
|
118 |
+ def has_option(self, section, option): |
|
119 |
+@@ -234,7 +236,7 @@ class ConfigParser(RawConfigParser): |
|
120 |
+ if "%(" in value: |
|
121 |
+ try: |
|
122 |
+ value = value % vars |
|
123 |
+- except KeyError, e: |
|
124 |
++ except KeyError as e: |
|
125 |
+ raise InterpolationMissingOptionError( |
|
126 |
+ option, section, rawval, e.args[0]) |
|
127 |
+ else: |
|
128 |
+@@ -283,7 +285,7 @@ class SafeConfigParser(ConfigParser): |
|
129 |
+ _badpercent_re = re.compile(r"%[^%]|%$") |
|
130 |
+ |
|
131 |
+ def set(self, section, option, value): |
|
132 |
+- if not isinstance(value, basestring): |
|
133 |
++ if not isinstance(value, six.string_types): |
|
134 |
+ raise TypeError("option values must be strings") |
|
135 |
+ # check for bad percent signs: |
|
136 |
+ # first, replace all "good" interpolations |
|
137 |
+diff --git a/iniparse/config.py b/iniparse/config.py |
|
138 |
+index 5cfa2ea..3b28549 100644 |
|
139 |
+--- a/iniparse/config.py |
|
140 |
+@@ -143,7 +143,7 @@ class BasicConfig(ConfigNamespace): |
|
141 |
+ |
|
142 |
+ >>> n.aaa = 42 |
|
143 |
+ >>> del n.x |
|
144 |
+- >>> print n |
|
145 |
++ >>> print(n) |
|
146 |
+ aaa = 42 |
|
147 |
+ name.first = paramjit |
|
148 |
+ name.last = oberoi |
|
149 |
+@@ -152,7 +152,7 @@ class BasicConfig(ConfigNamespace): |
|
150 |
+ |
|
151 |
+ >>> isinstance(n.name, ConfigNamespace) |
|
152 |
+ True |
|
153 |
+- >>> print n.name |
|
154 |
++ >>> print(n.name) |
|
155 |
+ first = paramjit |
|
156 |
+ last = oberoi |
|
157 |
+ >>> sorted(list(n.name)) |
|
158 |
+@@ -160,7 +160,7 @@ class BasicConfig(ConfigNamespace): |
|
159 |
+ |
|
160 |
+ Finally, values can be read from a file as follows: |
|
161 |
+ |
|
162 |
+- >>> from StringIO import StringIO |
|
163 |
++ >>> from six import StringIO |
|
164 |
+ >>> sio = StringIO(''' |
|
165 |
+ ... # comment |
|
166 |
+ ... ui.height = 100 |
|
167 |
+@@ -171,7 +171,7 @@ class BasicConfig(ConfigNamespace): |
|
168 |
+ ... ''') |
|
169 |
+ >>> n = BasicConfig() |
|
170 |
+ >>> n._readfp(sio) |
|
171 |
+- >>> print n |
|
172 |
++ >>> print(n) |
|
173 |
+ complexity = medium |
|
174 |
+ data.secret.password = goodness=gracious me |
|
175 |
+ have_python |
|
176 |
+@@ -199,7 +199,7 @@ class BasicConfig(ConfigNamespace): |
|
177 |
+ |
|
178 |
+ def __str__(self, prefix=''): |
|
179 |
+ lines = [] |
|
180 |
+- keys = self._data.keys() |
|
181 |
++ keys = list(self._data.keys()) |
|
182 |
+ keys.sort() |
|
183 |
+ for name in keys: |
|
184 |
+ value = self._data[name] |
|
185 |
+@@ -258,7 +258,7 @@ def update_config(target, source): |
|
186 |
+ >>> n.ui.display_clock = True |
|
187 |
+ >>> n.ui.display_qlength = True |
|
188 |
+ >>> n.ui.width = 150 |
|
189 |
+- >>> print n |
|
190 |
++ >>> print(n) |
|
191 |
+ playlist.expand_playlist = True |
|
192 |
+ ui.display_clock = True |
|
193 |
+ ui.display_qlength = True |
|
194 |
+@@ -267,7 +267,7 @@ def update_config(target, source): |
|
195 |
+ >>> from iniparse import ini |
|
196 |
+ >>> i = ini.INIConfig() |
|
197 |
+ >>> update_config(i, n) |
|
198 |
+- >>> print i |
|
199 |
++ >>> print(i) |
|
200 |
+ [playlist] |
|
201 |
+ expand_playlist = True |
|
202 |
+ <BLANKLINE> |
|
203 |
+@@ -277,7 +277,7 @@ def update_config(target, source): |
|
204 |
+ width = 150 |
|
205 |
+ |
|
206 |
+ """ |
|
207 |
+- for name in source: |
|
208 |
++ for name in sorted(source): |
|
209 |
+ value = source[name] |
|
210 |
+ if isinstance(value, ConfigNamespace): |
|
211 |
+ if name in target: |
|
212 |
+diff --git a/iniparse/configparser.py b/iniparse/configparser.py |
|
213 |
+new file mode 100644 |
|
214 |
+index 0000000..c543d50 |
|
215 |
+--- /dev/null |
|
216 |
+@@ -0,0 +1,7 @@ |
|
217 |
++try: |
|
218 |
++ from ConfigParser import * |
|
219 |
++ # not all objects get imported with __all__ |
|
220 |
++ from ConfigParser import Error, InterpolationMissingOptionError |
|
221 |
++except ImportError: |
|
222 |
++ from configparser import * |
|
223 |
++ from configparser import Error, InterpolationMissingOptionError |
|
224 |
+diff --git a/iniparse/ini.py b/iniparse/ini.py |
|
225 |
+index 408354d..052d9e9 100644 |
|
226 |
+--- a/iniparse/ini.py |
|
227 |
+@@ -7,7 +7,7 @@ |
|
228 |
+ |
|
229 |
+ Example: |
|
230 |
+ |
|
231 |
+- >>> from StringIO import StringIO |
|
232 |
++ >>> from six import StringIO |
|
233 |
+ >>> sio = StringIO('''# configure foo-application |
|
234 |
+ ... [foo] |
|
235 |
+ ... bar1 = qualia |
|
236 |
+@@ -16,14 +16,14 @@ Example: |
|
237 |
+ ... special = 1''') |
|
238 |
+ |
|
239 |
+ >>> cfg = INIConfig(sio) |
|
240 |
+- >>> print cfg.foo.bar1 |
|
241 |
++ >>> print(cfg.foo.bar1) |
|
242 |
+ qualia |
|
243 |
+- >>> print cfg['foo-ext'].special |
|
244 |
++ >>> print(cfg['foo-ext'].special) |
|
245 |
+ 1 |
|
246 |
+ >>> cfg.foo.newopt = 'hi!' |
|
247 |
+ >>> cfg.baz.enabled = 0 |
|
248 |
+ |
|
249 |
+- >>> print cfg |
|
250 |
++ >>> print(cfg) |
|
251 |
+ # configure foo-application |
|
252 |
+ [foo] |
|
253 |
+ bar1 = qualia |
|
254 |
+@@ -42,9 +42,11 @@ Example: |
|
255 |
+ # Backward-compatiable with ConfigParser |
|
256 |
+ |
|
257 |
+ import re |
|
258 |
+-from ConfigParser import DEFAULTSECT, ParsingError, MissingSectionHeaderError |
|
259 |
++from .configparser import DEFAULTSECT, ParsingError, MissingSectionHeaderError |
|
260 |
+ |
|
261 |
+-import config |
|
262 |
++import six |
|
263 |
++ |
|
264 |
++from . import config |
|
265 |
+ |
|
266 |
+ class LineType(object): |
|
267 |
+ line = None |
|
268 |
+@@ -278,6 +280,8 @@ class LineContainer(object): |
|
269 |
+ value = property(get_value, set_value) |
|
270 |
+ |
|
271 |
+ def __str__(self): |
|
272 |
++ for c in self.contents: |
|
273 |
++ pass#print(c.__str__()) |
|
274 |
+ s = [x.__str__() for x in self.contents] |
|
275 |
+ return '\n'.join(s) |
|
276 |
+ |
|
277 |
+@@ -465,7 +469,7 @@ class INIConfig(config.ConfigNamespace): |
|
278 |
+ self._sections = {} |
|
279 |
+ if defaults is None: defaults = {} |
|
280 |
+ self._defaults = INISection(LineContainer(), optionxformsource=self) |
|
281 |
+- for name, value in defaults.iteritems(): |
|
282 |
++ for name, value in defaults.items(): |
|
283 |
+ self._defaults[name] = value |
|
284 |
+ if fp is not None: |
|
285 |
+ self._readfp(fp) |
|
286 |
+@@ -551,7 +555,7 @@ class INIConfig(config.ConfigNamespace): |
|
287 |
+ |
|
288 |
+ for line in readline_iterator(fp): |
|
289 |
+ # Check for BOM on first line |
|
290 |
+- if linecount == 0 and isinstance(line, unicode): |
|
291 |
++ if linecount == 0 and isinstance(line, six.text_type): |
|
292 |
+ if line[0] == u'\ufeff': |
|
293 |
+ line = line[1:] |
|
294 |
+ self._bom = True |
|
295 |
+diff --git a/iniparse/utils.py b/iniparse/utils.py |
|
296 |
+index 829fc28..f8b773a 100644 |
|
297 |
+--- a/iniparse/utils.py |
|
298 |
+@@ -1,5 +1,5 @@ |
|
299 |
+-import compat |
|
300 |
+-from ini import LineContainer, EmptyLine |
|
301 |
++from . import compat |
|
302 |
++from .ini import LineContainer, EmptyLine |
|
303 |
+ |
|
304 |
+ def tidy(cfg): |
|
305 |
+ """Clean up blank lines. |
|
306 |
+diff --git a/tests/__init__.py b/tests/__init__.py |
|
307 |
+index f1fa321..88689fb 100644 |
|
308 |
+--- a/tests/__init__.py |
|
309 |
+@@ -1,12 +1,12 @@ |
|
310 |
+ import unittest, doctest |
|
311 |
+ |
|
312 |
+-import test_ini |
|
313 |
+-import test_misc |
|
314 |
+-import test_fuzz |
|
315 |
+-import test_compat |
|
316 |
+-import test_unicode |
|
317 |
+-import test_tidy |
|
318 |
+-import test_multiprocessing |
|
319 |
++from . import test_ini |
|
320 |
++from . import test_misc |
|
321 |
++from . import test_fuzz |
|
322 |
++from . import test_compat |
|
323 |
++from . import test_unicode |
|
324 |
++from . import test_tidy |
|
325 |
++from . import test_multiprocessing |
|
326 |
+ from iniparse import config |
|
327 |
+ from iniparse import ini |
|
328 |
+ |
|
329 |
+diff --git a/tests/test_compat.py b/tests/test_compat.py |
|
330 |
+index b8da3d5..b6dfb5c 100644 |
|
331 |
+--- a/tests/test_compat.py |
|
332 |
+@@ -1,9 +1,16 @@ |
|
333 |
+ from iniparse import compat as ConfigParser |
|
334 |
+-import StringIO |
|
335 |
++from six import StringIO |
|
336 |
++try: |
|
337 |
++ import UserDict |
|
338 |
++except ImportError: |
|
339 |
++ import collections as UserDict |
|
340 |
+ import unittest |
|
341 |
+-import UserDict |
|
342 |
+ |
|
343 |
+-from test import test_support |
|
344 |
++import sys |
|
345 |
++if sys.version_info[0] < 3: |
|
346 |
++ from test import test_support |
|
347 |
++else: |
|
348 |
++ from test import support as test_support |
|
349 |
+ |
|
350 |
+ class SortedDict(UserDict.UserDict): |
|
351 |
+ def items(self): |
|
352 |
+@@ -35,7 +42,7 @@ class TestCaseBase(unittest.TestCase): |
|
353 |
+ |
|
354 |
+ def fromstring(self, string, defaults=None): |
|
355 |
+ cf = self.newconfig(defaults) |
|
356 |
+- sio = StringIO.StringIO(string) |
|
357 |
++ sio = StringIO(string) |
|
358 |
+ cf.readfp(sio) |
|
359 |
+ return cf |
|
360 |
+ |
|
361 |
+@@ -161,7 +168,7 @@ class TestCaseBase(unittest.TestCase): |
|
362 |
+ "No Section!\n") |
|
363 |
+ |
|
364 |
+ def parse_error(self, exc, src): |
|
365 |
+- sio = StringIO.StringIO(src) |
|
366 |
++ sio = StringIO(src) |
|
367 |
+ self.assertRaises(exc, self.cf.readfp, sio) |
|
368 |
+ |
|
369 |
+ def test_query_errors(self): |
|
370 |
+@@ -181,7 +188,7 @@ class TestCaseBase(unittest.TestCase): |
|
371 |
+ def get_error(self, exc, section, option): |
|
372 |
+ try: |
|
373 |
+ self.cf.get(section, option) |
|
374 |
+- except exc, e: |
|
375 |
++ except exc as e: |
|
376 |
+ return e |
|
377 |
+ else: |
|
378 |
+ self.fail("expected exception type %s.%s" |
|
379 |
+@@ -227,7 +234,7 @@ class TestCaseBase(unittest.TestCase): |
|
380 |
+ "foo: another very\n" |
|
381 |
+ " long line" |
|
382 |
+ ) |
|
383 |
+- output = StringIO.StringIO() |
|
384 |
++ output = StringIO() |
|
385 |
+ cf.write(output) |
|
386 |
+ self.assertEqual( |
|
387 |
+ output.getvalue(), |
|
388 |
+@@ -465,7 +472,7 @@ class SortedTestCase(RawConfigParserTestCase): |
|
389 |
+ "o1=4\n" |
|
390 |
+ "[a]\n" |
|
391 |
+ "k=v\n") |
|
392 |
+- output = StringIO.StringIO() |
|
393 |
++ output = StringIO() |
|
394 |
+ self.cf.write(output) |
|
395 |
+ self.assertEquals(output.getvalue(), |
|
396 |
+ "[a]\n" |
|
397 |
+diff --git a/tests/test_fuzz.py b/tests/test_fuzz.py |
|
398 |
+index 5420dcc..b219500 100644 |
|
399 |
+--- a/tests/test_fuzz.py |
|
400 |
+@@ -1,9 +1,10 @@ |
|
401 |
+ import re |
|
402 |
+ import os |
|
403 |
+ import random |
|
404 |
++import sys |
|
405 |
+ import unittest |
|
406 |
+-import ConfigParser |
|
407 |
+-from StringIO import StringIO |
|
408 |
++from six import StringIO |
|
409 |
++from six.moves import configparser |
|
410 |
+ from iniparse import compat, ini, tidy |
|
411 |
+ |
|
412 |
+ # TODO: |
|
413 |
+@@ -96,24 +97,25 @@ class test_fuzz(unittest.TestCase): |
|
414 |
+ s = '\n'.join(good_lines) |
|
415 |
+ cc = compat.RawConfigParser() |
|
416 |
+ cc.readfp(StringIO(s)) |
|
417 |
+- cc_py = ConfigParser.RawConfigParser() |
|
418 |
++ cc_py = configparser.RawConfigParser() |
|
419 |
+ cc_py.readfp(StringIO(s)) |
|
420 |
+ # compare the two configparsers |
|
421 |
+ self.assertEqualConfig(cc_py, cc) |
|
422 |
+ # check that tidy does not change semantics |
|
423 |
+ tidy(cc) |
|
424 |
+- cc_tidy = ConfigParser.RawConfigParser() |
|
425 |
++ cc_tidy = configparser.RawConfigParser() |
|
426 |
+ cc_tidy.readfp(StringIO(str(cc.data))) |
|
427 |
+ self.assertEqualConfig(cc_py, cc_tidy) |
|
428 |
+ except AssertionError: |
|
429 |
+ fname = 'fuzz-test-iter-%d.ini' % fuzz_iter |
|
430 |
+- print 'Fuzz test failed at iteration', fuzz_iter |
|
431 |
+- print 'Writing out failing INI file as', fname |
|
432 |
++ print('Fuzz test failed at iteration', fuzz_iter) |
|
433 |
++ print('Writing out failing INI file as', fname) |
|
434 |
+ f = open(fname, 'w') |
|
435 |
+ f.write(s) |
|
436 |
+ f.close() |
|
437 |
+ raise |
|
438 |
+ |
|
439 |
++ @unittest.skipIf(sys.version_info[0] > 2, 'http://code.google.com/p/iniparse/issues/detail?id=22#c9') |
|
440 |
+ def assertEqualConfig(self, c1, c2): |
|
441 |
+ self.assertEqualSorted(c1.sections(), c2.sections()) |
|
442 |
+ self.assertEqualSorted(c1.defaults().items(), c2.defaults().items()) |
|
443 |
+@@ -123,9 +125,7 @@ class test_fuzz(unittest.TestCase): |
|
444 |
+ self.assertEqual(c1.get(sec, opt), c2.get(sec, opt)) |
|
445 |
+ |
|
446 |
+ def assertEqualSorted(self, l1, l2): |
|
447 |
+- l1.sort() |
|
448 |
+- l2.sort() |
|
449 |
+- self.assertEqual(l1, l2) |
|
450 |
++ self.assertEqual(sorted(l1), sorted(l2)) |
|
451 |
+ |
|
452 |
+ class suite(unittest.TestSuite): |
|
453 |
+ def __init__(self): |
|
454 |
+diff --git a/tests/test_ini.py b/tests/test_ini.py |
|
455 |
+index 6a76edb..07d4f4e 100644 |
|
456 |
+--- a/tests/test_ini.py |
|
457 |
+@@ -1,5 +1,5 @@ |
|
458 |
+ import unittest |
|
459 |
+-from StringIO import StringIO |
|
460 |
++from six import StringIO |
|
461 |
+ |
|
462 |
+ from iniparse import ini |
|
463 |
+ from iniparse import compat |
|
464 |
+@@ -196,13 +196,13 @@ but = also me |
|
465 |
+ self.assertEqual(p._data.find('section2').find('just').value, 'kidding') |
|
466 |
+ |
|
467 |
+ itr = p._data.finditer('section1') |
|
468 |
+- v = itr.next() |
|
469 |
++ v = next(itr) |
|
470 |
+ self.assertEqual(v.find('help').value, 'yourself') |
|
471 |
+ self.assertEqual(v.find('but').value, 'also me') |
|
472 |
+- v = itr.next() |
|
473 |
++ v = next(itr) |
|
474 |
+ self.assertEqual(v.find('help').value, 'me') |
|
475 |
+ self.assertEqual(v.find('I\'m').value, 'desperate') |
|
476 |
+- self.assertRaises(StopIteration, itr.next) |
|
477 |
++ self.assertRaises(StopIteration, next, itr) |
|
478 |
+ |
|
479 |
+ self.assertRaises(KeyError, p._data.find, 'section') |
|
480 |
+ self.assertRaises(KeyError, p._data.find('section2').find, 'ahem') |
|
481 |
+diff --git a/tests/test_misc.py b/tests/test_misc.py |
|
482 |
+index 31cf4da..96ef035 100644 |
|
483 |
+--- a/tests/test_misc.py |
|
484 |
+@@ -1,9 +1,9 @@ |
|
485 |
+ import re |
|
486 |
+ import unittest |
|
487 |
+ import pickle |
|
488 |
+-import ConfigParser |
|
489 |
++from six.moves import configparser |
|
490 |
++from six import StringIO |
|
491 |
+ from textwrap import dedent |
|
492 |
+-from StringIO import StringIO |
|
493 |
+ from iniparse import compat, ini |
|
494 |
+ |
|
495 |
+ class CaseSensitiveConfigParser(compat.ConfigParser): |
|
496 |
+diff --git a/tests/test_tidy.py b/tests/test_tidy.py |
|
497 |
+index 7304747..26b6cde 100644 |
|
498 |
+--- a/tests/test_tidy.py |
|
499 |
+@@ -1,6 +1,6 @@ |
|
500 |
+ import unittest |
|
501 |
+ from textwrap import dedent |
|
502 |
+-from StringIO import StringIO |
|
503 |
++from six import StringIO |
|
504 |
+ |
|
505 |
+ from iniparse import tidy,INIConfig |
|
506 |
+ from iniparse.ini import EmptyLine |
|
507 |
+diff --git a/tests/test_unicode.py b/tests/test_unicode.py |
|
508 |
+index a56fcab..14d4fbd 100644 |
|
509 |
+--- a/tests/test_unicode.py |
|
510 |
+@@ -1,5 +1,5 @@ |
|
511 |
+ import unittest |
|
512 |
+-from StringIO import StringIO |
|
513 |
++import six |
|
514 |
+ from iniparse import compat, ini |
|
515 |
+ |
|
516 |
+ class test_unicode(unittest.TestCase): |
|
517 |
+@@ -17,14 +17,14 @@ baz = Marc-Andr\202 |
|
518 |
+ """ |
|
519 |
+ |
|
520 |
+ def basic_tests(self, s, strable): |
|
521 |
+- f = StringIO(s) |
|
522 |
++ f = six.StringIO(s) |
|
523 |
+ i = ini.INIConfig(f) |
|
524 |
+- self.assertEqual(unicode(i), s) |
|
525 |
+- self.assertEqual(type(i.foo.bar), unicode) |
|
526 |
++ self.assertEqual(six.text_type(i), s) |
|
527 |
++ self.assertEqual(type(i.foo.bar), six.text_type) |
|
528 |
+ if strable: |
|
529 |
+ self.assertEqual(str(i), str(s)) |
|
530 |
+ else: |
|
531 |
+- self.assertRaises(UnicodeEncodeError, lambda: str(i)) |
|
532 |
++ self.assertRaises(UnicodeEncodeError, lambda: six.text_type(i).encode('ascii')) |
|
533 |
+ return i |
|
534 |
+ |
|
535 |
+ def test_ascii(self): |
|
536 |
+-- |
|
537 |
+2.11.0 |
|
538 |
+ |
... | ... |
@@ -3,19 +3,23 @@ |
3 | 3 |
|
4 | 4 |
Name: python-iniparse |
5 | 5 |
Version: 0.4 |
6 |
-Release: 5%{?dist} |
|
6 |
+Release: 6%{?dist} |
|
7 | 7 |
Summary: Python Module for Accessing and Modifying Configuration Data in INI files |
8 | 8 |
Group: Development/Libraries |
9 | 9 |
License: MIT |
10 | 10 |
URL: http://code.google.com/p/iniparse/ |
11 | 11 |
Source0: http://iniparse.googlecode.com/files/iniparse-%{version}.tar.gz |
12 | 12 |
%define sha1 iniparse=2b2af8a19f3e5c212c27d7c524cd748fa0b38650 |
13 |
-Patch0: iniparse-py3-build.patch |
|
13 |
+Patch0: 0001-Add-python-3-compatibility.patch |
|
14 | 14 |
Vendor: VMware, Inc. |
15 | 15 |
Distribution: Photon |
16 |
+ |
|
17 |
+BuildArch: noarch |
|
18 |
+ |
|
16 | 19 |
BuildRequires: python2-devel |
17 | 20 |
BuildRequires: python2-libs |
18 |
-BuildArch: noarch |
|
21 |
+BuildRequires: python2-test |
|
22 |
+ |
|
19 | 23 |
Requires: python2 |
20 | 24 |
|
21 | 25 |
%description |
... | ... |
@@ -30,18 +34,23 @@ Summary: python-iniparse |
30 | 30 |
BuildRequires: python3 |
31 | 31 |
BuildRequires: python3-devel |
32 | 32 |
BuildRequires: python3-libs |
33 |
+BuildRequires: python3-six |
|
34 |
+BuildRequires: python3-test |
|
33 | 35 |
Requires: python3 |
34 | 36 |
Requires: python3-libs |
35 | 37 |
Requires: python3-pycparser |
38 |
+Requires: python3-six |
|
36 | 39 |
|
37 | 40 |
%description -n python3-iniparse |
38 | 41 |
Python 3 version. |
39 | 42 |
|
40 | 43 |
%prep |
41 | 44 |
%setup -q -n iniparse-%{version} |
42 |
-%patch0 -p1 |
|
43 | 45 |
rm -rf ../p3dir |
44 | 46 |
cp -a . ../p3dir |
47 |
+pushd ../p3dir |
|
48 |
+%patch0 -p1 |
|
49 |
+popd |
|
45 | 50 |
|
46 | 51 |
%build |
47 | 52 |
python2 setup.py build |
... | ... |
@@ -60,24 +69,10 @@ mv %{buildroot}/usr/share/doc/iniparse-%{version} %{buildroot}/usr/share/doc/pyt |
60 | 60 |
|
61 | 61 |
|
62 | 62 |
%check |
63 |
-cp -r iniparse/ tests/ |
|
64 |
-cd tests |
|
65 |
-python2 test_misc.py |
|
66 |
-python2 test_tidy.py |
|
67 |
-python2 test_fuzz.py |
|
68 |
-python2 test_ini.py |
|
69 |
-python2 test_multiprocessing.py |
|
70 |
-python2 test_unicode.py |
|
63 |
+python2 runtests.py |
|
71 | 64 |
|
72 | 65 |
pushd ../p3dir |
73 |
-cp -r iniparse/ tests/ |
|
74 |
-cd tests |
|
75 |
-python3 test_misc.py |
|
76 |
-python3 test_tidy.py |
|
77 |
-python3 test_fuzz.py |
|
78 |
-python3 test_ini.py |
|
79 |
-python3 test_multiprocessing.py |
|
80 |
-python3 test_unicode.py |
|
66 |
+python3 runtests.py |
|
81 | 67 |
popd |
82 | 68 |
|
83 | 69 |
|
... | ... |
@@ -92,6 +87,8 @@ popd |
92 | 92 |
|
93 | 93 |
|
94 | 94 |
%changelog |
95 |
+* Tue Jul 11 2017 Xiaolin Li <xiaolinl@vmware.com> 0.4-6 |
|
96 |
+- Fix python3 and make check issues. |
|
95 | 97 |
* Thu Jun 01 2017 Dheeraj Shetty <dheerajs@vmware.com> 0.4-5 |
96 | 98 |
- Use python2 explicitly to build |
97 | 99 |
* Mon May 22 2017 Xiaolin Li <xiaolinl@vmware.com> 0.4-4 |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
Summary: A high-level scripting language |
2 | 2 |
Name: python2 |
3 | 3 |
Version: 2.7.13 |
4 |
-Release: 6%{?dist} |
|
4 |
+Release: 7%{?dist} |
|
5 | 5 |
License: PSF |
6 | 6 |
URL: http://www.python.org/ |
7 | 7 |
Group: System Environment/Programming |
... | ... |
@@ -100,6 +100,13 @@ Requires: python2 = %{version}-%{release} |
100 | 100 |
The Python package includes several development tools that are used |
101 | 101 |
to build python programs. |
102 | 102 |
|
103 |
+%package test |
|
104 |
+Summary: Regression tests package for Python. |
|
105 |
+Group: Development/Tools |
|
106 |
+Requires: python2 = %{version}-%{release} |
|
107 |
+ |
|
108 |
+%description test |
|
109 |
+The test package contains all regression tests for Python as well as the modules test.support and test.regrtest. test.support is used to enhance your tests while test.regrtest drives the testing suite. |
|
103 | 110 |
|
104 | 111 |
%prep |
105 | 112 |
%setup -q -n Python-%{version} |
... | ... |
@@ -222,7 +229,12 @@ rm -rf %{buildroot}/* |
222 | 222 |
%exclude %{_bindir}/smtpd.py |
223 | 223 |
%exclude %{_bindir}/idle* |
224 | 224 |
|
225 |
+%files test |
|
226 |
+%{_libdir}/python2.7/test/* |
|
227 |
+ |
|
225 | 228 |
%changelog |
229 |
+* Wed Jul 12 2017 Xiaolin Li <xiaolinl@vmware.com> 2.7.13-7 |
|
230 |
+- Add python2-test package. |
|
226 | 231 |
* Sun Jun 04 2017 Bo Gan <ganb@vmware.com> 2.7.13-6 |
227 | 232 |
- Fix dependency for libs |
228 | 233 |
* Tue May 16 2017 Kumar Kaushik <kaushikk@vmware.com> 2.7.13-5 |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
Summary: A high-level scripting language |
2 | 2 |
Name: python3 |
3 | 3 |
Version: 3.6.1 |
4 |
-Release: 5%{?dist} |
|
4 |
+Release: 6%{?dist} |
|
5 | 5 |
License: PSF |
6 | 6 |
URL: http://www.python.org/ |
7 | 7 |
Group: System Environment/Programming |
... | ... |
@@ -122,6 +122,14 @@ Requires: python3 = %{version}-%{release} |
122 | 122 |
%description setuptools |
123 | 123 |
setuptools is a collection of enhancements to the Python distutils that allow you to more easily build and distribute Python packages, especially ones that have dependencies on other packages. |
124 | 124 |
|
125 |
+%package test |
|
126 |
+Summary: Regression tests package for Python. |
|
127 |
+Group: Development/Tools |
|
128 |
+Requires: python3 = %{version}-%{release} |
|
129 |
+ |
|
130 |
+%description test |
|
131 |
+The test package contains all regression tests for Python as well as the modules test.support and test.regrtest. test.support is used to enhance your tests while test.regrtest drives the testing suite. |
|
132 |
+ |
|
125 | 133 |
%prep |
126 | 134 |
%setup -q -n Python-%{version} |
127 | 135 |
%patch0 -p1 |
... | ... |
@@ -251,7 +259,12 @@ rm -rf %{buildroot}/* |
251 | 251 |
%{_libdir}/python3.6/site-packages/setuptools-28.8.0.dist-info/* |
252 | 252 |
%{_bindir}/easy_install-3.6 |
253 | 253 |
|
254 |
+%files test |
|
255 |
+%{_libdir}/python3.6/test/* |
|
256 |
+ |
|
254 | 257 |
%changelog |
258 |
+* Wed Jul 12 2017 Xiaolin Li <xiaolinl@vmware.com> 3.6.1-6 |
|
259 |
+- Add python3-test package. |
|
255 | 260 |
* Fri Jun 30 2017 Dheeraj Shetty <dheerajs@vmware.com> 3.6.1-5 |
256 | 261 |
- Remove the imaplib tests. |
257 | 262 |
* Mon Jun 05 2017 Xiaolin Li <xiaolinl@vmware.com> 3.6.1-4 |