From 2cedb21cc3eff2a57f0d781dc38e679589664d3a Mon Sep 17 00:00:00 2001 From: Paul McGuire Date: Mon, 1 Apr 2019 22:52:44 -0500 Subject: General code cleanup; have unit test module exit(0 or 1) depending on test success, to trigger CI pass/fail; fix bug that crept into withAttribute; minor performance tweaks in Regex and Word --- pyparsing.py | 59 ++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 23 deletions(-) (limited to 'pyparsing.py') diff --git a/pyparsing.py b/pyparsing.py index 705e9ac..ebea155 100644 --- a/pyparsing.py +++ b/pyparsing.py @@ -94,7 +94,7 @@ classes inherit from. Use the docstrings for examples of how to: """ __version__ = "2.4.0" -__versionTime__ = "30 Mar 2019 07:57 UTC" +__versionTime__ = "02 Apr 2019 02:07 UTC" __author__ = "Paul McGuire " import string @@ -762,7 +762,7 @@ class ParseResults(object): print(patt.addParseAction(make_palindrome).parseString("lskdj sdlkjf lksd")) # -> 'lskdjsdlkjflksddsklfjkldsjdksl' """ if isinstance(itemseq, ParseResults): - self += itemseq + self.__iadd__(itemseq) else: self.__toklist.extend(itemseq) @@ -2936,7 +2936,7 @@ class Word(Token): loc = result.end() return loc, result.group() - if not(instring[ loc ] in self.initChars): + if instring[loc] not in self.initChars: raise ParseException(instring, loc, self.errmsg, self) start = loc @@ -2951,9 +2951,9 @@ class Word(Token): throwException = False if loc - start < self.minLen: throwException = True - if self.maxSpecified and loc < instrlen and instring[loc] in bodychars: + elif self.maxSpecified and loc < instrlen and instring[loc] in bodychars: throwException = True - if self.asKeyword: + elif self.asKeyword: if (start>0 and instring[start-1] in bodychars) or (loc") + closeTag = Combine(_L("", adjacent=False) openTag = openTag("start"+"".join(resname.replace(":"," ").title().split())).setName("<%s>" % resname) closeTag = closeTag("end"+"".join(resname.replace(":"," ").title().split())).setName("" % resname) -- cgit v1.2.1