summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2015-10-29 05:57:09 +0000
committerptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2015-10-29 05:57:09 +0000
commit86e7b17f955acfa8022521d9fb43a0ca59b6692e (patch)
tree0b485a4b566bd0b112beedc96728ed4642740895
parentd42a5f0a88a1e1d74cd2c8da69665c14c4d451c8 (diff)
downloadpyparsing-86e7b17f955acfa8022521d9fb43a0ca59b6692e.tar.gz
Redo withClass; fix typo in Word, remove Token.setName() that does nothing significant (suggested by williamzjc)
git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/trunk@291 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b
-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()