Hello community,

here is the log from the commit of package python-ciscoconfparse for 
openSUSE:Leap:15.2 checked in at 2020-03-15 13:35:59
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Leap:15.2/python-ciscoconfparse (Old)
 and      /work/SRC/openSUSE:Leap:15.2/.python-ciscoconfparse.new.3160 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-ciscoconfparse"

Sun Mar 15 13:35:59 2020 rev:12 rq:783346 version:1.5.1

Changes:
--------
--- 
/work/SRC/openSUSE:Leap:15.2/python-ciscoconfparse/python-ciscoconfparse.changes
    2020-03-09 18:03:36.428765140 +0100
+++ 
/work/SRC/openSUSE:Leap:15.2/.python-ciscoconfparse.new.3160/python-ciscoconfparse.changes
  2020-03-15 13:36:00.210825284 +0100
@@ -1,0 +2,9 @@
+Wed Feb 26 19:39:37 UTC 2020 - Martin Hauke <[email protected]>
+
+- Update to version 1.5.1
+  * Remove embedded junos debugging
+- Update to version 1.5.0
+  * Complete rewrite of junos parser (fix Github issue #70)
+  * deprecate support for Python 3.4
+
+-------------------------------------------------------------------

Old:
----
  ciscoconfparse-1.4.11.tar.gz

New:
----
  ciscoconfparse-1.5.1.tar.gz

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

Other differences:
------------------
++++++ python-ciscoconfparse.spec ++++++
--- /var/tmp/diff_new_pack.zCnJYu/_old  2020-03-15 13:36:00.534825477 +0100
+++ /var/tmp/diff_new_pack.zCnJYu/_new  2020-03-15 13:36:00.534825477 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package python-ciscoconfparse
 #
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-ciscoconfparse
-Version:        1.4.11
+Version:        1.5.1
 Release:        0
 Summary:        Library for parsing, querying and modifying Cisco IOS-style 
configurations
 License:        GPL-3.0-or-later

++++++ ciscoconfparse-1.4.11.tar.gz -> ciscoconfparse-1.5.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ciscoconfparse-1.4.11/CHANGES 
new/ciscoconfparse-1.5.1/CHANGES
--- old/ciscoconfparse-1.4.11/CHANGES   2019-12-05 12:29:41.000000000 +0100
+++ new/ciscoconfparse-1.5.1/CHANGES    2020-02-20 09:32:17.000000000 +0100
@@ -1,3 +1,5 @@
+1.5.1   20200223 Remove embedded junos debugging
+1.5.0   20200223 Complete rewrite of junos parser (fix Github issue #70); 
deprecate support for Python 3.4
 1.4.11  20191205 Github issue #170 Explicitly close() open filehandles
 1.4.10  20191125 Integrate Github issue #169, add support for parsing 
pathlib.Path objects which contain a configuration
 1.4.9   20191122 Add .as_cidr_net and .as_cidr_addr on IPv4Obj and IPv6Obj
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ciscoconfparse-1.4.11/PKG-INFO 
new/ciscoconfparse-1.5.1/PKG-INFO
--- old/ciscoconfparse-1.4.11/PKG-INFO  2019-12-05 12:38:35.000000000 +0100
+++ new/ciscoconfparse-1.5.1/PKG-INFO   2020-02-20 09:34:59.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: ciscoconfparse
-Version: 1.4.11
+Version: 1.5.1
 Summary: Parse, Audit, Query, Build, and Modify Cisco IOS-style configurations
 Home-page: http://www.pennington.net/py/ciscoconfparse/
 Author: David Michael Pennington
@@ -124,7 +124,7 @@
         Pre-requisites
         ==============
         
-        ciscoconfparse_ requires Python versions 2.7 or 3.4+ (note: version 
3.7.0 has 
+        ciscoconfparse_ requires Python versions 2.7 or 3.5+ (note: version 
3.7.0 has 
         a bug - ref Github issue #117, but version 3.7.1 works); the OS should 
not 
         matter.
         
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ciscoconfparse-1.4.11/README.rst 
new/ciscoconfparse-1.5.1/README.rst
--- old/ciscoconfparse-1.4.11/README.rst        2019-11-22 21:16:29.000000000 
+0100
+++ new/ciscoconfparse-1.5.1/README.rst 2020-02-20 09:14:33.000000000 +0100
@@ -116,7 +116,7 @@
 Pre-requisites
 ==============
 
-ciscoconfparse_ requires Python versions 2.7 or 3.4+ (note: version 3.7.0 has 
+ciscoconfparse_ requires Python versions 2.7 or 3.5+ (note: version 3.7.0 has 
 a bug - ref Github issue #117, but version 3.7.1 works); the OS should not 
 matter.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/ciscoconfparse-1.4.11/ciscoconfparse/ciscoconfparse.py 
new/ciscoconfparse-1.5.1/ciscoconfparse/ciscoconfparse.py
--- old/ciscoconfparse-1.4.11/ciscoconfparse/ciscoconfparse.py  2019-12-05 
12:02:42.000000000 +0100
+++ new/ciscoconfparse-1.5.1/ciscoconfparse/ciscoconfparse.py   2020-02-20 
09:29:08.000000000 +0100
@@ -380,55 +380,105 @@
 
         JUNOS_RE_STR = r"""^
         (?:\s*
-           (?:(?P<line>[^\{{\}}{0}].*?)(?P<braces_eol>[\{{\}}])*(?P<sc>\;)*\s*)
-          |(?P<braces_alone>[\{{\}}\;])
-          |(?P<brace_sc>\}}\;)\s*
-          |(?P<junos_else>^\s*\}}\s*else\s*\{{\s*$)
-          |(?:\s*[{0}](?P<comment>.*))
-        )
-        $
-        """.format(re.escape(self.comment_delimiter))
-        #LINE_RE = re.compile(r'^\s*([^\{\}].*)*\s*([\{\}\;])(\s\#.+)*$')
+            
(?P<braces_close_left>\})*(?P<line1>.*?)(?P<braces_open_right>\{)*;*
+           
|(?P<line2>[^\{\}]*?)(?P<braces_open_left>\{)(?P<condition2>.*?)(?P<braces_close_right>\});*\s*
+           |(?P<line3>[^\{\}]*?);*\s*
+        )$
+        """
         LINE_RE = re.compile(JUNOS_RE_STR, re.VERBOSE)
 
-        def line_level(input):
-            level_offset = 0
-            mm = LINE_RE.search(input)
-            if not (mm is None):
+        COMMENT_RE = 
re.compile(r'^\s*(?P<delimiter>[{0}]+)(?P<comment>[^{0}]*)$'.format(re.escape(self.comment_delimiter)))
+
+        def parse_line_braces(input):
+            assert input is not None
+            indent_child = 0
+            indent_this_line = 0
+
+            mm = LINE_RE.search(input.strip())
+            nn = COMMENT_RE.search(input.strip())
+
+            if nn is not None:
+                results = nn.groupdict()
+                return (indent_this_line, indent_child, 
results.get('delimiter')+results.get('comment', ''))
+
+            elif mm is not None:
                 results = mm.groupdict()
-                line = results.get('line', '')
 
-                ## Hack to fix Github issue #49 (empty double braces at end)
-                nn = re.search(r'^(.+?)\{\s*\}\s*$', input)
-                if nn is not None:
-                    # Detect double braces at the end of a line and strip them
-                    line = nn.group(1)
-
-                junos_else = results.get('junos_else', None)
-                term_char = (results['braces_eol'] or
-                             results.get('braces_sc', None) or
-                             results['braces_alone'] or '').strip()
-                comment = results['comment']
-                if term_char == '{':
-                    level_offset = 1
-                elif term_char == '}':
-                    level_offset = -1
-                elif term_char == '};':
-                    level_offset = -1
-
-                ## Return values
-                if comment is not None:
-                    return '!' + comment, level_offset
-                elif junos_else is not None:
-                    return 'else', level_offset
+                # } line1 { foo bar this } {
+                braces_close_left = bool(results.get('braces_close_left', ''))
+                braces_open_right = bool(results.get('braces_open_right', ''))
+
+                # line2
+                braces_open_left = bool(results.get('braces_open_left', ''))
+                braces_close_right = bool(results.get('braces_close_right', 
''))
+
+                # line3
+                line1_str = results.get('line1', '')
+                line3_str = results.get('line3', '')
+
+                if braces_close_left and braces_open_right:
+                    # Based off line1
+                    #     } elseif { bar baz } {
+                    indent_this_line -= 1
+                    indent_child     += 0
+                    retval = results.get('line1', None)
+                    return (indent_this_line, indent_child, retval)
+
+                elif bool(line1_str) and (braces_close_left is False) and 
(braces_open_right is False):
+                    # Based off line1:
+                    #     address 1.1.1.1
+                    indent_this_line -= 0
+                    indent_child     += 0
+                    retval = results.get('line1', '').strip()
+                    # Strip empty braces here
+                    retval = re.sub(r'\s*\{\s*\}\s*', '', retval)
+                    return (indent_this_line, indent_child, retval)
+
+                elif (line1_str == '') and (braces_close_left is False) and 
(braces_open_right is False):
+                    # Based off line1:
+                    #     return empty string
+                    indent_this_line -= 0
+                    indent_child     += 0
+                    return (indent_this_line, indent_child, '')
+
+                elif braces_open_left and braces_close_right:
+                    # Based off line2
+                    #    this { bar baz }
+                    indent_this_line -= 0
+                    indent_child     += 0
+                    line = results.get('line2', None) or ''
+                    condition = results.get('condition2', None) or ''
+                    if condition.strip() == '': 
+                        retval = line
+                    else:
+                        retval = line + " {" + condition + " }"
+                    return (indent_this_line, indent_child, retval)
+
+                elif braces_close_left:
+                    # Based off line1
+                    #   }
+                    indent_this_line -= 1
+                    indent_child     -= 1
+                    return (indent_this_line, indent_child, '')
+
+                elif braces_open_right:
+                    # Based off line1
+                    #   this that foo {
+                    indent_this_line -= 0
+                    indent_child     += 1
+                    line = results.get('line1', None) or ''
+                    return (indent_this_line, indent_child, line)
+
+                elif (line3_str != '') and (line3_str is not None):
+                    indent_this_line += 0
+                    indent_child     += 0
+                    return (indent_this_line, indent_child, '')
+
                 else:
-                    return line, level_offset
+                    raise ValueError('Cannot parse junos 
match:"{0}"'.format(input))
 
-            elif input.strip() == '':
-                ## pass blank lines back
-                return input, 0
             else:
-                raise ValueError("LINE_RE Regex fail - Could not parse: 
'{0}'".format(input))
+                raise ValueError('Cannot parse junos:"{0}"'.format(input))
 
         lines = list()
         offset = 0
@@ -436,13 +486,10 @@
         for idx, tmp in enumerate(input_list):
             if self.debug is True:
                 _log.debug("Parse line {0}:'{1}'".format(idx+1, tmp.strip()))
-            line, line_offset = line_level(tmp.strip())
-            if line is None:
-                line = ""
-            # Debugging here...
-            #print "FOO", tmp, "BAR", line, line_offset
-            lines.append(" " * STOP_WIDTH * offset + line)
-            offset += line_offset
+            (indent_this_line, indent_child, line) = parse_line_braces(
+                tmp.strip())
+            lines.append((" " * STOP_WIDTH * (offset + indent_this_line)) + 
line.strip())
+            offset += indent_child
         return lines
 
     def find_interface_objects(self, intfspec, exactmatch=True):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ciscoconfparse-1.4.11/ciscoconfparse/version 
new/ciscoconfparse-1.5.1/ciscoconfparse/version
--- old/ciscoconfparse-1.4.11/ciscoconfparse/version    2019-12-05 
12:28:00.000000000 +0100
+++ new/ciscoconfparse-1.5.1/ciscoconfparse/version     2020-02-20 
09:30:18.000000000 +0100
@@ -1 +1 @@
-1.4.11
+1.5.1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/ciscoconfparse-1.4.11/ciscoconfparse.egg-info/PKG-INFO 
new/ciscoconfparse-1.5.1/ciscoconfparse.egg-info/PKG-INFO
--- old/ciscoconfparse-1.4.11/ciscoconfparse.egg-info/PKG-INFO  2019-12-05 
12:38:31.000000000 +0100
+++ new/ciscoconfparse-1.5.1/ciscoconfparse.egg-info/PKG-INFO   2020-02-20 
09:34:55.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: ciscoconfparse
-Version: 1.4.11
+Version: 1.5.1
 Summary: Parse, Audit, Query, Build, and Modify Cisco IOS-style configurations
 Home-page: http://www.pennington.net/py/ciscoconfparse/
 Author: David Michael Pennington
@@ -124,7 +124,7 @@
         Pre-requisites
         ==============
         
-        ciscoconfparse_ requires Python versions 2.7 or 3.4+ (note: version 
3.7.0 has 
+        ciscoconfparse_ requires Python versions 2.7 or 3.5+ (note: version 
3.7.0 has 
         a bug - ref Github issue #117, but version 3.7.1 works); the OS should 
not 
         matter.
         
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ciscoconfparse-1.4.11/tests/test_Models_Junos.py 
new/ciscoconfparse-1.5.1/tests/test_Models_Junos.py
--- old/ciscoconfparse-1.4.11/tests/test_Models_Junos.py        2019-05-12 
15:12:43.000000000 +0200
+++ new/ciscoconfparse-1.5.1/tests/test_Models_Junos.py 2020-02-20 
08:49:44.000000000 +0100
@@ -44,4 +44,4 @@
     ]
     parse = CiscoConfParse(config, syntax='junos')
     retval = parse.find_objects('profiles2')[0].children
-    assert retval[0].text=='    test2 '
+    assert retval[0].text.strip()=='test2'


Reply via email to