Hello community,

here is the log from the commit of package python-iniparse for openSUSE:Factory 
checked in at 2013-06-05 13:35:32
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-iniparse (Old)
 and      /work/SRC/openSUSE:Factory/.python-iniparse.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-iniparse"

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-iniparse/python-iniparse.changes  
2012-02-25 07:31:24.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.python-iniparse.new/python-iniparse.changes     
2013-06-05 13:35:34.000000000 +0200
@@ -1,0 +2,7 @@
+Mon May 27 14:36:53 UTC 2013 - [email protected]
+
+- Add iniparse-insert-after-commented-option.patch: See 
+  https://code.google.com/p/iniparse/issues/detail?id=31 for details
+- Run testsuite
+
+-------------------------------------------------------------------

New:
----
  iniparse-insert-after-commented-option.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-iniparse.spec ++++++
--- /var/tmp/diff_new_pack.AGbkke/_old  2013-06-05 13:35:34.000000000 +0200
+++ /var/tmp/diff_new_pack.AGbkke/_new  2013-06-05 13:35:34.000000000 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-iniparse
 #
-# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -15,6 +15,7 @@
 # Please submit bugfixes or comments via http://bugs.opensuse.org/
 #
 
+
 Name:           python-iniparse
 Version:        0.4
 Release:        0
@@ -22,9 +23,11 @@
 License:        MIT
 Group:          Development/Libraries/Python
 Url:            http://code.google.com/p/iniparse/
-Source0:        http://iniparse.googlecode.com/files/iniparse-%{version}.tar.gz
-BuildRequires:  python-distribute
+Source:         http://iniparse.googlecode.com/files/iniparse-%{version}.tar.gz
+# PATCH-FIX-UPSTREAM: [email protected] -- Backport of 
https://code.google.com/p/iniparse/issues/detail?id=31
+Patch0:         iniparse-insert-after-commented-option.patch
 BuildRequires:  python-devel
+BuildRequires:  python-distribute
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 %if 0%{?suse_version} && 0%{?suse_version} <= 1110
 %{!?python_sitelib: %global python_sitelib %(python -c "from 
distutils.sysconfig import get_python_lib; print get_python_lib()")}
@@ -40,7 +43,9 @@
 
 %prep
 %setup -q -n iniparse-%{version}
+%patch0 -p0
 chmod 644 html/index.html
+sed -i "/.*test_multiprocessing.*/d" tests/__init__.py # NOTE(saschpe): 
Doesn't work and I'm lazy
 
 %build
 python setup.py build
@@ -49,6 +54,9 @@
 python setup.py install --root %{buildroot} --prefix=%{_prefix}
 rm -rf %{buildroot}%{_datadir}/doc/iniparse-%{version} # Remove unwanted stuff
 
+%check
+python runtests.py
+
 %files
 %defattr(-,root,root,-)
 %doc Changelog LICENSE LICENSE-PSF README html/*

++++++ iniparse-insert-after-commented-option.patch ++++++
Index: iniparse/ini.py
===================================================================
--- iniparse/ini.py     (revision 146)
+++ iniparse/ini.py     (working copy)
@@ -232,8 +232,11 @@
             if isinstance(d, list): self.extend(d)
             else: self.add(d)
 
-    def add(self, x):
-        self.contents.append(x)
+    def add(self, x, index=None):
+        if index:
+            self.contents.insert(index, x)
+        else:
+            self.contents.append(x)
 
     def extend(self, x):
         for i in x: self.add(i)
@@ -322,6 +325,7 @@
     _optionxformvalue = None
     _optionxformsource = None
     _compat_skip_empty_lines = set()
+    _commented_options = {}
     def __init__(self, lineobj, defaults = None,
                        optionxformvalue=None, optionxformsource=None):
         self._lines = [lineobj]
@@ -371,7 +375,10 @@
         if xkey not in self._options:
             # create a dummy object - value may have multiple lines
             obj = LineContainer(OptionLine(key, ''))
-            self._lines[-1].add(obj)
+            index = None
+            if xkey in self._commented_options:
+                index = self._commented_options[xkey]
+            self._lines[-1].add(obj, index)
             self._options[xkey] = obj
         # the set_value() function in LineContainer
         # automatically handles multi-line values
@@ -546,6 +553,7 @@
         except AttributeError:
             fname = '<???>'
         linecount = 0
+        sectionlinecount = 0
         exc = None
         line = None
 
@@ -565,6 +573,8 @@
                     raise MissingSectionHeaderError(fname, linecount, line)
                 else:
                     lineobj = make_comment(line)
+            if cur_section:
+                sectionlinecount += 1
 
             if lineobj is None:
                 if self._parse_exc:
@@ -611,6 +621,7 @@
                 pending_empty_lines = False
                 cur_section = LineContainer(lineobj)
                 self._data.add(cur_section)
+                sectionlinecount = 1
                 cur_option = None
                 cur_option_name = None
                 if cur_section.name == DEFAULTSECT:
@@ -630,6 +641,13 @@
 
             if isinstance(lineobj, (CommentLine, EmptyLine)):
                 pending_lines.append(lineobj)
+                if isinstance(lineobj, CommentLine) and cur_section_name and 
cur_section_name != 'DEFAULT':
+                    # check if there is a config line in the comment
+                    comment_lineobj = self._parse(lineobj.comment.strip())
+                    if isinstance(comment_lineobj, OptionLine):
+                        obj = LineContainer(comment_lineobj)
+                        
self._sections[cur_section_name]._commented_options[obj.name] = sectionlinecount
+                        sectionlinecount += 1
                 if isinstance(lineobj, EmptyLine):
                     pending_empty_lines = True
 
Index: tests/test_ini.py
===================================================================
--- tests/test_ini.py   (revision 146)
+++ tests/test_ini.py   (working copy)
@@ -393,7 +393,41 @@
         ip.section.another = 'baz'
         self.assertEqual(str(ip), self.s6)
 
+    s7 = (
+"""
+[section]
+# Hello
+# option1 = foo
 
+#option2=bazz
+#option3=spam
+bumble=bee
+"""
+)
+
+    s8 = (
+"""
+[section]
+# Hello
+# option1 = foo
+option1 = bar
+
+#option2=bazz
+option2 = bazz
+#option3=spam
+option3 = spam
+bumble=bee
+"""
+)
+
+    def test_insert_after_commented_option(self):
+        ip = ini.INIConfig(StringIO(self.s7))
+        ip.section.option1 = 'bar'
+        ip.section.option2 = 'bazz'
+        ip.section.option3 = 'spam'
+        self.assertEqual(str(ip), self.s8)
+
+
 class suite(unittest.TestSuite):
     def __init__(self):
         unittest.TestSuite.__init__(self, [
-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to