Hello community,

here is the log from the commit of package python-VyattaConfParser for 
openSUSE:Factory checked in at 2019-10-25 18:43:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-VyattaConfParser (Old)
 and      /work/SRC/openSUSE:Factory/.python-VyattaConfParser.new.2990 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-VyattaConfParser"

Fri Oct 25 18:43:03 2019 rev:2 rq:742839 version:0.5.3

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-VyattaConfParser/python-VyattaConfParser.changes
  2019-10-24 23:01:31.627988738 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-VyattaConfParser.new.2990/python-VyattaConfParser.changes
        2019-10-25 18:43:07.527954181 +0200
@@ -1,0 +2,9 @@
+Thu Oct 24 18:06:19 UTC 2019 - [email protected]
+
+- Update to version 0.5.3:
+  * Fix error parsing named section config with missing {} curly
+    brackets
+- Do not longer build for python2, upstream dropped support with
+  this release
+
+-------------------------------------------------------------------

Old:
----
  VyattaConfParser-0.5.2.tar.xz

New:
----
  VyattaConfParser-0.5.3.tar.xz

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

Other differences:
------------------
++++++ python-VyattaConfParser.spec ++++++
--- /var/tmp/diff_new_pack.JEnhO9/_old  2019-10-25 18:43:07.999954630 +0200
+++ /var/tmp/diff_new_pack.JEnhO9/_new  2019-10-25 18:43:08.007954638 +0200
@@ -18,8 +18,9 @@
 
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
+%define skip_python2 1
 Name:           python-VyattaConfParser
-Version:        0.5.2
+Version:        0.5.3
 Release:        0
 Summary:        A python config parser for Vyatta/VyOS
 License:        MIT

++++++ VyattaConfParser-0.5.2.tar.xz -> VyattaConfParser-0.5.3.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/VyattaConfParser-0.5.2/test_vyattaconfparser.py 
new/VyattaConfParser-0.5.3/test_vyattaconfparser.py
--- old/VyattaConfParser-0.5.2/test_vyattaconfparser.py 2019-09-10 
13:32:45.000000000 +0200
+++ new/VyattaConfParser-0.5.3/test_vyattaconfparser.py 2019-10-23 
10:53:22.000000000 +0200
@@ -231,7 +231,7 @@
         assert isinstance(rv, dict)
         assert_equal(correct, rv)
 
-    def test_service_dyndns(self):
+    def test_same_sub_key(self):
         s = """
         service {
             dns {
@@ -245,12 +245,6 @@
                         }
                     }
                 }
-                forwarding {
-                    cache-size 1000
-                    listen-on switch0
-                    name-server 1.1.1.1
-                    system
-                }
             }
         }
         """
@@ -271,12 +265,55 @@
                             },
                         }
                     },
-                    'forwarding': {
-                        'cache-size': '1000',
-                        'listen-on': 'switch0',
-                        'name-server': '1.1.1.1',
-                        'system': 'system',
+                }
+            }
+        }
+        rv = vparser.parse_conf(s)
+        assert isinstance(rv, dict)
+        assert_equal(correct, rv)
+
+    def test_named_section_without_curly_braces(self):
+        s = """
+        vti vti10
+        vti vti11 {
+            address 1.1.1.1/28
+            description Tunnel number 1
+            test_named_no_curly 1
+            test_named_no_curly 2 {
+                some_key value
+                even deeper1
+                even deeper2 {
+                    another_key value
+                }
+            }
+        }
+        vti vti12 {
+            address 2.2.2.2/28
+            description Tunnel number 2
+        }
+        """
+        correct = {
+            'vti': {
+                'vti10': {},
+                'vti11': {
+                    'address': '1.1.1.1/28',
+                    'description': 'Tunnel number 1',
+                    'test_named_no_curly': {
+                        '1': {},
+                        '2': {
+                            'some_key': 'value',
+                            'even': {
+                                'deeper1': {},
+                                'deeper2': {
+                                    'another_key': 'value',
+                                }
+                            }
+                        }
                     }
+                },
+                'vti12': {
+                    'address': '2.2.2.2/28',
+                    'description': 'Tunnel number 2',
                 }
             }
         }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/VyattaConfParser-0.5.2/vyattaconfparser/__init__.py 
new/VyattaConfParser-0.5.3/vyattaconfparser/__init__.py
--- old/VyattaConfParser-0.5.2/vyattaconfparser/__init__.py     2019-09-10 
13:32:45.000000000 +0200
+++ new/VyattaConfParser-0.5.3/vyattaconfparser/__init__.py     2019-10-23 
10:53:22.000000000 +0200
@@ -1,7 +1,7 @@
 from .parser import parse_conf
 
 __title__ = 'Vyatta Config Parser'
-__version__ = '0.5.2'
+__version__ = '0.5.3'
 __author__ = 'Aleksandr Mironov'
 __license__ = 'MIT'
 __all__ = ['parse_conf']
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/VyattaConfParser-0.5.2/vyattaconfparser/parser.py 
new/VyattaConfParser-0.5.3/vyattaconfparser/parser.py
--- old/VyattaConfParser-0.5.2/vyattaconfparser/parser.py       2019-09-10 
13:32:45.000000000 +0200
+++ new/VyattaConfParser-0.5.3/vyattaconfparser/parser.py       2019-10-23 
10:53:22.000000000 +0200
@@ -14,7 +14,7 @@
 # Matches section start `interfaces {`
 rx_section = re.compile(r'^([\w\-]+) \{$', re.UNICODE)
 # Matches named section `ethernet eth0 {`
-rx_dict = re.compile(r'^([\w\-]+) ([\w\-\"\./@:]+) \{$', re.UNICODE)
+rx_named_section = re.compile(r'^([\w\-]+) ([\w\-\"\./@:]+) \{$', re.UNICODE)
 # Matches simple key-value pair `duplex auto`
 rx_value = re.compile(r'^([\w\-]+) "?([^"]+)?"?$', re.UNICODE)
 # Matches single value (flag) `disable`
@@ -70,7 +70,26 @@
             else:
                 t.update(val)
         else:
-            t.update(val)
+            if isinstance(t, str):
+                prev_keys = list(
+                    map(lambda x: list(x.keys())[0], path)
+                )[:-1]
+                prev_section_key = prev_keys[-1]
+
+                if len(prev_keys) == 1:
+                    config[prev_section_key] = {config[prev_section_key]: {}}
+                    t = config[prev_section_key]
+                else:
+                    t = config
+                    for k in prev_keys[:-1]:
+                        t = t[k]
+                    t[prev_section_key] = {t[prev_section_key]: {}}
+                    t = t[prev_section_key]
+
+                t.update({list(item.keys())[0]: val})
+
+            else:
+                t.update(val)
 
     elif val_type == 'named_section':
         pass
@@ -96,9 +115,9 @@
         if path:
             update_tree(config, path, {section: {}}, val_type=val_type)
 
-    elif rx_dict.match(line):
+    elif rx_named_section.match(line):
         val_type = 'named_section'
-        section, name = rx_dict.match(line).groups()
+        section, name = rx_named_section.match(line).groups()
         if section not in [list(p.keys())[0] for p in path]:
             path.append({section: val_type})
         elif section != [list(p.keys())[0] for p in path][-1]:

++++++ _service ++++++
--- /var/tmp/diff_new_pack.JEnhO9/_old  2019-10-25 18:43:08.075954703 +0200
+++ /var/tmp/diff_new_pack.JEnhO9/_new  2019-10-25 18:43:08.075954703 +0200
@@ -2,11 +2,11 @@
   <service mode="disabled" name="tar_scm">
     <param name="url">https://github.com/hedin/vyatta-conf-parser.git</param>
     <param name="scm">git</param>
-    <param name="revision">916b5b1</param>
+    <param name="revision">084ba32</param>
     <param name="package-meta">no</param>
     <param name="changesgenerate">enable</param>
     <param name="filename">VyattaConfParser</param>
-    <param name="versionformat">0.5.2</param>
+    <param name="versionformat">0.5.3</param>
   </service>
   <service mode="disabled" name="recompress">
     <param name="file">*.tar</param>

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.JEnhO9/_old  2019-10-25 18:43:08.087954714 +0200
+++ /var/tmp/diff_new_pack.JEnhO9/_new  2019-10-25 18:43:08.091954718 +0200
@@ -1,4 +1,4 @@
 <servicedata>
 <service name="tar_scm">
                 <param 
name="url">https://github.com/hedin/vyatta-conf-parser.git</param>
-              <param 
name="changesrevision">916b5b1c4b98394e27bb724cd697506db29f2f1a</param></service></servicedata>
\ No newline at end of file
+              <param 
name="changesrevision">084ba320ae1d6079267b3785f618af85089b5367</param></service></servicedata>
\ No newline at end of file


Reply via email to