Hello community,
here is the log from the commit of package python-pyparsing for
openSUSE:Factory checked in at 2020-05-07 15:05:56
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pyparsing (Old)
and /work/SRC/openSUSE:Factory/.python-pyparsing.new.2738 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pyparsing"
Thu May 7 15:05:56 2020 rev:37 rq:800308 version:2.4.7
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pyparsing/python-pyparsing.changes
2020-02-14 16:23:27.511128252 +0100
+++
/work/SRC/openSUSE:Factory/.python-pyparsing.new.2738/python-pyparsing.changes
2020-05-07 15:06:12.659799550 +0200
@@ -1,0 +2,12 @@
+Tue May 5 09:08:59 UTC 2020 - Dirk Mueller <[email protected]>
+
+- update to 2.4.7:
+ . Each bug with Regex expressions
+ . And expressions not properly constructing with generator
+ . Traceback abbreviation
+ . Bug in delta_time example
+ . Fix regexen in pyparsing_common.real and .sci_real
+ . Avoid FutureWarning on Python 3.7 or later
+ . Cleanup output in runTests if comments are embedded in test string
+
+-------------------------------------------------------------------
Old:
----
pyparsing-2.4.6.tar.gz
New:
----
pyparsing-2.4.7.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pyparsing.spec ++++++
--- /var/tmp/diff_new_pack.mWZHml/_old 2020-05-07 15:06:13.963802434 +0200
+++ /var/tmp/diff_new_pack.mWZHml/_new 2020-05-07 15:06:13.963802434 +0200
@@ -28,7 +28,7 @@
%bcond_with test
%endif
Name: python-pyparsing%{psuffix}
-Version: 2.4.6
+Version: 2.4.7
Release: 0
Summary: Grammar Parser Library for Python
License: MIT AND GPL-2.0-or-later AND GPL-3.0-or-later
++++++ pyparsing-2.4.6.tar.gz -> pyparsing-2.4.7.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pyparsing-2.4.6/CHANGES new/pyparsing-2.4.7/CHANGES
--- old/pyparsing-2.4.6/CHANGES 2019-12-25 06:47:29.000000000 +0100
+++ new/pyparsing-2.4.7/CHANGES 2020-03-31 04:48:57.000000000 +0200
@@ -2,6 +2,18 @@
Change Log
==========
+Version 2.4.7 - March, 2020
+---------------------------
+- Backport of selected fixes from 3.0.0 work:
+ . Each bug with Regex expressions
+ . And expressions not properly constructing with generator
+ . Traceback abbreviation
+ . Bug in delta_time example
+ . Fix regexen in pyparsing_common.real and .sci_real
+ . Avoid FutureWarning on Python 3.7 or later
+ . Cleanup output in runTests if comments are embedded in test string
+
+
Version 2.4.6 - December, 2019
------------------------------
- Fixed typos in White mapping of whitespace characters, to use
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pyparsing-2.4.6/PKG-INFO new/pyparsing-2.4.7/PKG-INFO
--- old/pyparsing-2.4.6/PKG-INFO 2019-12-25 06:49:39.820865200 +0100
+++ new/pyparsing-2.4.7/PKG-INFO 2020-04-06 00:19:28.676653400 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.2
Name: pyparsing
-Version: 2.4.6
+Version: 2.4.7
Summary: Python parsing module
Home-page: https://github.com/pyparsing/pyparsing/
Author: Paul McGuire
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pyparsing-2.4.6/examples/delta_time.py
new/pyparsing-2.4.7/examples/delta_time.py
--- old/pyparsing-2.4.6/examples/delta_time.py 2019-11-03 22:47:38.000000000
+0100
+++ new/pyparsing-2.4.7/examples/delta_time.py 2020-03-31 04:48:57.000000000
+0200
@@ -52,6 +52,9 @@
def plural(s):
return CK(s) | CK(s + 's').addParseAction(pp.replaceWith(s))
week, day, hour, minute, second = map(plural, "week day hour minute
second".split())
+time_units = hour | minute | second
+any_time_units = week | day | time_units
+
am = CL("am")
pm = CL("pm")
COLON = pp.Suppress(':')
@@ -69,7 +72,7 @@
couple = (pp.Optional(CK("a")) + CK("couple") +
pp.Optional(CK("of"))).setParseAction(pp.replaceWith(2))
a_qty = (CK("a") | CK("an")).setParseAction(pp.replaceWith(1))
the_qty = CK("the").setParseAction(pp.replaceWith(1))
-qty = pp.ungroup(integer | couple | a_qty | the_qty)
+qty = pp.ungroup(integer | couple | a_qty | the_qty).setName("qty")
time_ref_present =
pp.Empty().addParseAction(pp.replaceWith(True))('time_ref_present')
def fill_24hr_time_fields(t):
@@ -86,8 +89,10 @@
weekday_name_list = list(calendar.day_name)
weekday_name = pp.oneOf(weekday_name_list)
-_24hour_time = pp.Word(pp.nums, exact=4).addParseAction(lambda t:
[int(t[0][:2]),int(t[0][2:])],
- fill_24hr_time_fields)
+_24hour_time = (~(integer + any_time_units)
+ + pp.Word(pp.nums, exact=4).addParseAction(lambda t:
[int(t[0][:2]),int(t[0][2:])],
+
fill_24hr_time_fields)
+ )
_24hour_time.setName("0000 time")
ampm = am | pm
timespec = (integer("HH")
@@ -302,6 +307,10 @@
2pm next Sunday
next Sunday at 2pm
last Sunday at 2pm
+ 10 seconds ago
+ 100 seconds ago
+ 1000 seconds ago
+ 10000 seconds ago
"""
time_of_day = timedelta(hours=current_time.hour,
@@ -309,6 +318,10 @@
seconds=current_time.second)
expected = {
'now' : timedelta(0),
+ "10 seconds ago": timedelta(seconds=-10),
+ "100 seconds ago": timedelta(seconds=-100),
+ "1000 seconds ago": timedelta(seconds=-1000),
+ "10000 seconds ago": timedelta(seconds=-10000),
'10 minutes ago': timedelta(minutes=-10),
'10 minutes from now': timedelta(minutes=10),
'in 10 minutes': timedelta(minutes=10),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pyparsing-2.4.6/pyparsing.egg-info/PKG-INFO
new/pyparsing-2.4.7/pyparsing.egg-info/PKG-INFO
--- old/pyparsing-2.4.6/pyparsing.egg-info/PKG-INFO 2019-12-25
06:49:39.000000000 +0100
+++ new/pyparsing-2.4.7/pyparsing.egg-info/PKG-INFO 2020-04-06
00:19:28.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.2
Name: pyparsing
-Version: 2.4.6
+Version: 2.4.7
Summary: Python parsing module
Home-page: https://github.com/pyparsing/pyparsing/
Author: Paul McGuire
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pyparsing-2.4.6/pyparsing.py
new/pyparsing-2.4.7/pyparsing.py
--- old/pyparsing-2.4.6/pyparsing.py 2019-12-25 06:47:29.000000000 +0100
+++ new/pyparsing-2.4.7/pyparsing.py 2020-03-31 04:48:57.000000000 +0200
@@ -95,8 +95,8 @@
namespace class
"""
-__version__ = "2.4.6"
-__versionTime__ = "24 Dec 2019 04:27 UTC"
+__version__ = "2.4.7"
+__versionTime__ = "30 Mar 2020 00:43 UTC"
__author__ = "Paul McGuire <[email protected]>"
import string
@@ -1391,6 +1391,12 @@
"""
ParserElement._literalStringClass = cls
+ @classmethod
+ def _trim_traceback(cls, tb):
+ while tb.tb_next:
+ tb = tb.tb_next
+ return tb
+
def __init__(self, savelist=False):
self.parseAction = list()
self.failAction = None
@@ -1943,7 +1949,9 @@
if ParserElement.verbose_stacktrace:
raise
else:
- # catch and re-raise exception from here, clears out pyparsing
internal stack trace
+ # catch and re-raise exception from here, clearing out
pyparsing internal stack trace
+ if getattr(exc, '__traceback__', None) is not None:
+ exc.__traceback__ = self._trim_traceback(exc.__traceback__)
raise exc
else:
return tokens
@@ -2017,7 +2025,9 @@
if ParserElement.verbose_stacktrace:
raise
else:
- # catch and re-raise exception from here, clears out pyparsing
internal stack trace
+ # catch and re-raise exception from here, clearing out
pyparsing internal stack trace
+ if getattr(exc, '__traceback__', None) is not None:
+ exc.__traceback__ = self._trim_traceback(exc.__traceback__)
raise exc
def transformString(self, instring):
@@ -2063,7 +2073,9 @@
if ParserElement.verbose_stacktrace:
raise
else:
- # catch and re-raise exception from here, clears out pyparsing
internal stack trace
+ # catch and re-raise exception from here, clearing out
pyparsing internal stack trace
+ if getattr(exc, '__traceback__', None) is not None:
+ exc.__traceback__ = self._trim_traceback(exc.__traceback__)
raise exc
def searchString(self, instring, maxMatches=_MAX_INT):
@@ -2093,7 +2105,9 @@
if ParserElement.verbose_stacktrace:
raise
else:
- # catch and re-raise exception from here, clears out pyparsing
internal stack trace
+ # catch and re-raise exception from here, clearing out
pyparsing internal stack trace
+ if getattr(exc, '__traceback__', None) is not None:
+ exc.__traceback__ = self._trim_traceback(exc.__traceback__)
raise exc
def split(self, instring, maxsplit=_MAX_INT, includeSeparators=False):
@@ -2565,7 +2579,9 @@
if ParserElement.verbose_stacktrace:
raise
else:
- # catch and re-raise exception from here, clears out pyparsing
internal stack trace
+ # catch and re-raise exception from here, clearing out
pyparsing internal stack trace
+ if getattr(exc, '__traceback__', None) is not None:
+ exc.__traceback__ = self._trim_traceback(exc.__traceback__)
raise exc
def __eq__(self, other):
@@ -2724,7 +2740,7 @@
continue
if not t:
continue
- out = ['\n'.join(comments), t]
+ out = ['\n' + '\n'.join(comments) if comments else '', t]
comments = []
try:
# convert newline marks to actual newlines, and strip leading
BOM if present
@@ -3312,7 +3328,7 @@
self.name = _ustr(self)
self.errmsg = "Expected " + self.name
self.mayIndexError = False
- self.mayReturnEmpty = True
+ self.mayReturnEmpty = self.re_match("") is not None
self.asGroupList = asGroupList
self.asMatch = asMatch
if self.asGroupList:
@@ -3993,6 +4009,7 @@
self.leaveWhitespace()
def __init__(self, exprs, savelist=True):
+ exprs = list(exprs)
if exprs and Ellipsis in exprs:
tmp = []
for i, expr in enumerate(exprs):
@@ -4358,7 +4375,7 @@
if self.initExprGroups:
self.opt1map = dict((id(e.expr), e) for e in self.exprs if
isinstance(e, Optional))
opt1 = [e.expr for e in self.exprs if isinstance(e, Optional)]
- opt2 = [e for e in self.exprs if e.mayReturnEmpty and not
isinstance(e, Optional)]
+ opt2 = [e for e in self.exprs if e.mayReturnEmpty and not
isinstance(e, (Optional, Regex))]
self.optionals = opt1 + opt2
self.multioptionals = [e.expr for e in self.exprs if isinstance(e,
ZeroOrMore)]
self.multirequired = [e.expr for e in self.exprs if isinstance(e,
OneOrMore)]
@@ -5435,8 +5452,8 @@
return rep
def _escapeRegexRangeChars(s):
- # ~ escape these chars: ^-]
- for c in r"\^-]":
+ # ~ escape these chars: ^-[]
+ for c in r"\^-[]":
s = s.replace(c, _bslash + c)
s = s.replace("\n", r"\n")
s = s.replace("\t", r"\t")
@@ -6550,10 +6567,10 @@
"""mixed integer of the form 'integer - fraction', with optional leading
integer, returns float"""
mixed_integer.addParseAction(sum)
- real = Regex(r'[+-]?(:?\d+\.\d*|\.\d+)').setName("real
number").setParseAction(convertToFloat)
+ real = Regex(r'[+-]?(?:\d+\.\d*|\.\d+)').setName("real
number").setParseAction(convertToFloat)
"""expression that parses a floating point number and returns a float"""
- sci_real =
Regex(r'[+-]?(:?\d+(:?[eE][+-]?\d+)|(:?\d+\.\d*|\.\d+)(:?[eE][+-]?\d+)?)').setName("real
number with scientific notation").setParseAction(convertToFloat)
+ sci_real =
Regex(r'[+-]?(?:\d+(?:[eE][+-]?\d+)|(?:\d+\.\d*|\.\d+)(?:[eE][+-]?\d+)?)').setName("real
number with scientific notation").setParseAction(convertToFloat)
"""expression that parses a floating point number with optional
scientific notation and returns a float"""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pyparsing-2.4.6/unitTests.py
new/pyparsing-2.4.7/unitTests.py
--- old/pyparsing-2.4.6/unitTests.py 2019-12-25 06:47:29.000000000 +0100
+++ new/pyparsing-2.4.7/unitTests.py 2020-03-31 04:48:57.000000000 +0200
@@ -2845,14 +2845,28 @@
def runTest1(self):
from pyparsing import Optional, Keyword
- the_input = "Major Tal Weiss"
- parser1 = (Optional('Tal') + Optional('Weiss')) & Keyword('Major')
- parser2 = Optional(Optional('Tal') + Optional('Weiss')) &
Keyword('Major')
- p1res = parser1.parseString( the_input)
- p2res = parser2.parseString( the_input)
- self.assertEqual(p1res.asList(), p2res.asList(),
- "Each failed to match with nested Optionals, "
- + str(p1res.asList()) + " should match " +
str(p2res.asList()))
+ for the_input in [
+ "Tal Weiss Major",
+ "Tal Major",
+ "Weiss Major",
+ "Major",
+ "Major Tal",
+ "Major Weiss",
+ "Major Tal Weiss",
+ ]:
+ print_(the_input)
+ parser1 = (Optional("Tal") + Optional("Weiss")) & Keyword("Major")
+ parser2 = Optional(Optional("Tal") + Optional("Weiss")) &
Keyword("Major")
+ p1res = parser1.parseString(the_input)
+ p2res = parser2.parseString(the_input)
+ self.assertEqual(
+ p1res.asList(),
+ p2res.asList(),
+ "Each failed to match with nested Optionals, "
+ + str(p1res.asList())
+ + " should match "
+ + str(p2res.asList()),
+ )
def runTest2(self):
from pyparsing import Word, alphanums, OneOrMore, Group, Regex,
Optional
@@ -2906,12 +2920,34 @@
42
""")
+ def testParseExpressionsWithRegex(self):
+ from itertools import product
+ match_empty_regex = pp.Regex(r"[a-z]*")
+ match_nonempty_regex = pp.Regex(r"[a-z]+")
+
+ parser_classes = pp.ParseExpression.__subclasses__()
+ test_string = "abc def"
+ expected = ["abc"]
+ for expr, cls in product((match_nonempty_regex, match_empty_regex),
parser_classes):
+ print_(expr, cls)
+ parser = cls([expr])
+ parsed_result = parser.parseString(test_string)
+ print_(parsed_result.dump())
+ self.assertParseResultsEquals(parsed_result, expected)
+
+ for expr, cls in product((match_nonempty_regex, match_empty_regex),
(pp.MatchFirst, pp.Or)):
+ parser = cls([expr, expr])
+ print_(parser)
+ parsed_result = parser.parseString(test_string)
+ print_(parsed_result.dump())
+ self.assertParseResultsEquals(parsed_result, expected)
def runTest(self):
self.runTest1()
self.runTest2()
self.runTest3()
self.runTest4()
+ self.testParseExpressionsWithRegex()
class SumParseResultsTest(ParseTestCase):
def runTest(self):