summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul McGuire <ptmcg@austin.rr.com>2015-10-29 05:57:09 +0000
committerPaul McGuire <ptmcg@austin.rr.com>2015-10-29 05:57:09 +0000
commit0208700c5e61efeccf89208562ebefb9b93cbce4 (patch)
tree0b485a4b566bd0b112beedc96728ed4642740895 /src
parent59278a1d1569c9ef720e3db591bc3feaa52c4b05 (diff)
downloadpyparsing-git-0208700c5e61efeccf89208562ebefb9b93cbce4.tar.gz
Redo withClass; fix typo in Word, remove Token.setName() that does nothing significant (suggested by williamzjc)
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES3
-rw-r--r--src/pyparsing.py16
2 files changed, 6 insertions, 13 deletions
diff --git a/src/CHANGES b/src/CHANGES
index e5f8fb2..09def63 100644
--- a/src/CHANGES
+++ b/src/CHANGES
@@ -27,7 +27,8 @@ Version 2.0.4 -
- Adopt new-fangled Python features, like decorators and ternary expressions,
per suggestions from Williamzjc - thanks William! (Oh yeah, I'm not
- supporting Python 2.3 with this code any more...)
+ supporting Python 2.3 with this code any more...) Plus, some additional
+ code fixes/cleanup - thanks again!
- Added ParserElement.runTests, a little test bench for quickly running
an expression against a list of sample input strings. Basically, I got
diff --git a/src/pyparsing.py b/src/pyparsing.py
index bbcebe6..81c82ce 100644
--- a/src/pyparsing.py
+++ b/src/pyparsing.py
@@ -58,7 +58,7 @@ The pyparsing module handles some of the problems that are typically vexing when
"""
__version__ = "2.0.4"
-__versionTime__ = "24 Oct 2015 16:26"
+__versionTime__ = "28 Oct 2015 21:50"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
import string
@@ -1572,11 +1572,6 @@ class Token(ParserElement):
def __init__( self ):
super(Token,self).__init__( savelist=False )
- def setName(self, name):
- s = super(Token,self).setName(name)
- self.errmsg = "Expected " + self.name
- return s
-
class Empty(Token):
"""An empty token, will always match."""
@@ -1763,7 +1758,7 @@ class Word(Token):
if ' ' not in self.initCharsOrig+self.bodyCharsOrig and (min==1 and max==0 and exact==0):
if self.bodyCharsOrig == self.initCharsOrig:
self.reString = "[%s]+" % _escapeRegexRangeChars(self.initCharsOrig)
- elif len(self.bodyCharsOrig) == 1:
+ elif len(self.initCharsOrig) == 1:
self.reString = "%s[%s]*" % \
(re.escape(self.initCharsOrig),
_escapeRegexRangeChars(self.bodyCharsOrig),)
@@ -3548,11 +3543,8 @@ def withClass(classname, namespace=''):
"""Simplified version of C{L{withAttribute}} when matching on a div class - made
difficult because C{class} is a reserved word in Python.
"""
- if namespace:
- key = "%s:class" % namespace
- else:
- key = "class"
- return withAttribute(**{key : classname})
+ classattr = "%s:class" % namespace if namespace else "class"
+ return withAttribute(**{classattr : classname})
opAssoc = _Constants()
opAssoc.LEFT = object()