Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3abab34

Browse files
committed
Fix some regular expressions.
svn path=/branches/transforms/; revision=4729
1 parent 0b6033d commit 3abab34

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

lib/matplotlib/fontconfig_pattern.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class FontconfigPatternParser:
3535
See here for a rough specification of these patterns:
3636
http://www.fontconfig.org/fontconfig-user.html
3737
"""
38-
38+
3939

4040
_constants = {
4141
'thin' : ('weight', 'light'),
@@ -63,12 +63,12 @@ class FontconfigPatternParser:
6363
'extraexpanded' : ('width', 'extra-expanded'),
6464
'ultraexpanded' : ('width', 'ultra-expanded')
6565
}
66-
66+
6767
def __init__(self):
6868
family = Regex(r'([^%s]|(\\[%s]))*' %
6969
(family_punc, family_punc)) \
7070
.setParseAction(self._family)
71-
size = Regex(r'[0-9.]+') \
71+
size = Regex(r"([0-9]+\.?[0-9]*|\.[0-9]+)") \
7272
.setParseAction(self._size)
7373
name = Regex(r'[a-z]+') \
7474
.setParseAction(self._name)
@@ -79,7 +79,7 @@ def __init__(self):
7979
families =(family
8080
+ ZeroOrMore(
8181
Literal(',')
82-
+ family)
82+
+ family)
8383
).setParseAction(self._families)
8484

8585
point_sizes =(size
@@ -118,10 +118,10 @@ def parse(self, pattern):
118118
self._parser.parseString(pattern)
119119
except self.ParseException, e:
120120
raise ValueError("Could not parse font string: '%s'\n%s" % (pattern, e))
121-
121+
122122
self._properties = None
123123
return props
124-
124+
125125
def _family(self, s, loc, tokens):
126126
return [family_unescape(r'\1', tokens[0])]
127127

@@ -141,7 +141,7 @@ def _families(self, s, loc, tokens):
141141
def _point_sizes(self, s, loc, tokens):
142142
self._properties['size'] = tokens
143143
return []
144-
144+
145145
def _property(self, s, loc, tokens):
146146
if len(tokens) == 1:
147147
if tokens[0] in self._constants:

lib/matplotlib/mathtext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1984,7 +1984,7 @@ def __init__(self):
19841984
autoDelim = Forward().setParseAction(self.auto_sized_delimiter)
19851985
self._expression = Forward().setParseAction(self.finish).setName("finish")
19861986

1987-
float = Regex(r"-?[0-9]*(\.[0-9]+)?")
1987+
float = Regex(r"[-+]?([0-9]+\.?[0-9]*|\.[0-9]+)")
19881988

19891989
lbrace = Literal('{').suppress()
19901990
rbrace = Literal('}').suppress()

0 commit comments

Comments
 (0)