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

Skip to content

Commit 04b9ab9

Browse files
committed
Merge pull request #2279 from jenshnielsen/pyparsing
Pyparsing
2 parents 87d25ff + 07fec13 commit 04b9ab9

File tree

4 files changed

+74
-68
lines changed

4 files changed

+74
-68
lines changed

.travis.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ python:
77
- 3.3
88

99
install:
10-
- pip install -q --use-mirrors nose python-dateutil numpy pep8
11-
# This is a workaround to install the latest versions of pyparsing,
12-
# which are not yet available on PyPI
13-
- 'if [ ${TRAVIS_PYTHON_VERSION:0:1} == "3" ]; then pip -q install http://sourceforge.net/projects/pyparsing/files/pyparsing/pyparsing-2.0.0/pyparsing-2.0.0.tar.gz; fi'
14-
- 'if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then pip -q install http://sourceforge.net/projects/pyparsing/files/pyparsing/pyparsing-1.5.7/pyparsing-1.5.7.tar.gz; fi'
10+
- pip install -q --use-mirrors nose python-dateutil numpy pep8 pyparsing
1511
- if [[ $TRAVIS_PYTHON_VERSION == '2.'* ]]; then pip -q install --use-mirrors PIL; fi
1612
- sudo apt-get update && sudo apt-get -qq install inkscape
1713
- python setup.py install

lib/matplotlib/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,21 @@
120120
"matplotlib requires pyparsing >= {0}".format(
121121
'.'.join(str(x) for x in _required)))
122122

123+
if pyparsing.__version__ == '2.0.0':
124+
raise ImportError(
125+
"pyparsing 2.0.0 has bugs that prevent its use with "
126+
"matplotlib")
127+
128+
# pyparsing 1.5.6 does not have <<= on the Forward class, but
129+
# pyparsing 2.0.0 and later will spew deprecation warnings if
130+
# using << instead. In order to support pyparsing 1.5.6 and above
131+
# with a common code base, this small monkey patch is applied.
132+
if not hasattr(pyparsing.Forward, '__ilshift__'):
133+
def _forward_ilshift(self, other):
134+
self.__lshift__(other)
135+
return self
136+
pyparsing.Forward.__ilshift__ = _forward_ilshift
137+
123138
import os, re, shutil, warnings
124139
import distutils.sysconfig
125140
import distutils.version

lib/matplotlib/mathtext.py

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,69 +2179,69 @@ def __init__(self):
21792179
if key != 'self':
21802180
val.setName(key)
21812181

2182-
float_literal << Regex(r"[-+]?([0-9]+\.?[0-9]*|\.[0-9]+)")
2183-
int_literal << Regex("[-+]?[0-9]+")
2182+
float_literal <<= Regex(r"[-+]?([0-9]+\.?[0-9]*|\.[0-9]+)")
2183+
int_literal <<= Regex("[-+]?[0-9]+")
21842184

2185-
lbrace << Literal('{').suppress()
2186-
rbrace << Literal('}').suppress()
2187-
lbracket << Literal('[').suppress()
2188-
rbracket << Literal(']').suppress()
2189-
bslash << Literal('\\')
2185+
lbrace <<= Literal('{').suppress()
2186+
rbrace <<= Literal('}').suppress()
2187+
lbracket <<= Literal('[').suppress()
2188+
rbracket <<= Literal(']').suppress()
2189+
bslash <<= Literal('\\')
21902190

2191-
space << oneOf(self._space_widths.keys())
2192-
customspace << (Suppress(Literal(r'\hspace'))
2191+
space <<= oneOf(self._space_widths.keys())
2192+
customspace <<= (Suppress(Literal(r'\hspace'))
21932193
- ((lbrace + float_literal + rbrace)
21942194
| Error(r"Expected \hspace{n}")))
21952195

21962196
unicode_range = u"\U00000080-\U0001ffff"
2197-
single_symbol << Regex(UR"([a-zA-Z0-9 +\-*/<>=:,.;!\?&'@()\[\]|%s])|(\\[%%${}\[\]_|])" %
2197+
single_symbol <<= Regex(UR"([a-zA-Z0-9 +\-*/<>=:,.;!\?&'@()\[\]|%s])|(\\[%%${}\[\]_|])" %
21982198
unicode_range)
2199-
symbol_name << (Combine(bslash + oneOf(tex2uni.keys())) +
2199+
symbol_name <<= (Combine(bslash + oneOf(tex2uni.keys())) +
22002200
FollowedBy(Regex("[^A-Za-z]").leaveWhitespace() | StringEnd()))
2201-
symbol << (single_symbol | symbol_name).leaveWhitespace()
2201+
symbol <<= (single_symbol | symbol_name).leaveWhitespace()
22022202

2203-
apostrophe << Regex("'+")
2203+
apostrophe <<= Regex("'+")
22042204

2205-
c_over_c << Suppress(bslash) + oneOf(self._char_over_chars.keys())
2205+
c_over_c <<= Suppress(bslash) + oneOf(self._char_over_chars.keys())
22062206

2207-
accent << Group(
2207+
accent <<= Group(
22082208
Suppress(bslash)
22092209
+ oneOf(self._accent_map.keys() + list(self._wide_accents))
22102210
- placeable
22112211
)
22122212

2213-
function << Suppress(bslash) + oneOf(list(self._function_names))
2213+
function <<= Suppress(bslash) + oneOf(list(self._function_names))
22142214

2215-
start_group << Optional(latexfont) + lbrace
2216-
end_group << rbrace.copy()
2217-
simple_group << Group(lbrace + ZeroOrMore(token) + rbrace)
2218-
required_group<< Group(lbrace + OneOrMore(token) + rbrace)
2219-
group << Group(start_group + ZeroOrMore(token) + end_group)
2215+
start_group <<= Optional(latexfont) + lbrace
2216+
end_group <<= rbrace.copy()
2217+
simple_group <<= Group(lbrace + ZeroOrMore(token) + rbrace)
2218+
required_group<<= Group(lbrace + OneOrMore(token) + rbrace)
2219+
group <<= Group(start_group + ZeroOrMore(token) + end_group)
22202220

2221-
font << Suppress(bslash) + oneOf(list(self._fontnames))
2222-
latexfont << Suppress(bslash) + oneOf(['math' + x for x in self._fontnames])
2221+
font <<= Suppress(bslash) + oneOf(list(self._fontnames))
2222+
latexfont <<= Suppress(bslash) + oneOf(['math' + x for x in self._fontnames])
22232223

2224-
frac << Group(
2224+
frac <<= Group(
22252225
Suppress(Literal(r"\frac"))
22262226
- ((required_group + required_group) | Error(r"Expected \frac{num}{den}"))
22272227
)
22282228

2229-
stackrel << Group(
2229+
stackrel <<= Group(
22302230
Suppress(Literal(r"\stackrel"))
22312231
- ((required_group + required_group) | Error(r"Expected \stackrel{num}{den}"))
22322232
)
22332233

2234-
binom << Group(
2234+
binom <<= Group(
22352235
Suppress(Literal(r"\binom"))
22362236
- ((required_group + required_group) | Error(r"Expected \binom{num}{den}"))
22372237
)
22382238

2239-
ambi_delim << oneOf(list(self._ambi_delim))
2240-
left_delim << oneOf(list(self._left_delim))
2241-
right_delim << oneOf(list(self._right_delim))
2242-
right_delim_safe << oneOf(list(self._right_delim - set(['}'])) + [r'\}'])
2239+
ambi_delim <<= oneOf(list(self._ambi_delim))
2240+
left_delim <<= oneOf(list(self._left_delim))
2241+
right_delim <<= oneOf(list(self._right_delim))
2242+
right_delim_safe <<= oneOf(list(self._right_delim - set(['}'])) + [r'\}'])
22432243

2244-
genfrac << Group(
2244+
genfrac <<= Group(
22452245
Suppress(Literal(r"\genfrac"))
22462246
- (((lbrace + Optional(ambi_delim | left_delim, default='') + rbrace)
22472247
+ (lbrace + Optional(ambi_delim | right_delim_safe, default='') + rbrace)
@@ -2250,27 +2250,27 @@ def __init__(self):
22502250
| Error(r"Expected \genfrac{ldelim}{rdelim}{rulesize}{style}{num}{den}"))
22512251
)
22522252

2253-
sqrt << Group(
2253+
sqrt <<= Group(
22542254
Suppress(Literal(r"\sqrt"))
22552255
- ((Optional(lbracket + int_literal + rbracket, default=None)
22562256
+ required_group)
22572257
| Error("Expected \sqrt{value}"))
22582258
)
22592259

2260-
overline << Group(
2260+
overline <<= Group(
22612261
Suppress(Literal(r"\overline"))
22622262
- (required_group | Error("Expected \overline{value}"))
22632263
)
22642264

2265-
unknown_symbol<< Combine(bslash + Regex("[A-Za-z]*"))
2265+
unknown_symbol<<= Combine(bslash + Regex("[A-Za-z]*"))
22662266

2267-
operatorname << Group(
2267+
operatorname <<= Group(
22682268
Suppress(Literal(r"\operatorname"))
22692269
- ((lbrace + ZeroOrMore(simple | unknown_symbol) + rbrace)
22702270
| Error("Expected \operatorname{value}"))
22712271
)
22722272

2273-
placeable << ( accent # Must be first
2273+
placeable <<= ( accent # Must be first
22742274
| symbol # Must be second
22752275
| c_over_c
22762276
| function
@@ -2284,39 +2284,39 @@ def __init__(self):
22842284
| operatorname
22852285
)
22862286

2287-
simple << ( space
2287+
simple <<= ( space
22882288
| customspace
22892289
| font
22902290
| subsuper
22912291
)
22922292

2293-
subsuperop << oneOf(["_", "^"])
2293+
subsuperop <<= oneOf(["_", "^"])
22942294

2295-
subsuper << Group(
2295+
subsuper <<= Group(
22962296
(Optional(placeable) + OneOrMore(subsuperop - placeable) + Optional(apostrophe))
22972297
| (placeable + Optional(apostrophe))
22982298
| apostrophe
22992299
)
23002300

2301-
token << ( simple
2301+
token <<= ( simple
23022302
| auto_delim
23032303
| unknown_symbol # Must be last
23042304
)
23052305

2306-
auto_delim << (Suppress(Literal(r"\left"))
2306+
auto_delim <<= (Suppress(Literal(r"\left"))
23072307
- ((left_delim | ambi_delim) | Error("Expected a delimiter"))
23082308
+ Group(ZeroOrMore(simple | auto_delim))
23092309
+ Suppress(Literal(r"\right"))
23102310
- ((right_delim | ambi_delim) | Error("Expected a delimiter"))
23112311
)
23122312

2313-
math << OneOrMore(token)
2313+
math <<= OneOrMore(token)
23142314

2315-
math_string << QuotedString('$', '\\', unquoteResults=False)
2315+
math_string <<= QuotedString('$', '\\', unquoteResults=False)
23162316

2317-
non_math << Regex(r"(?:(?:\\[$])|[^$])*").leaveWhitespace()
2317+
non_math <<= Regex(r"(?:(?:\\[$])|[^$])*").leaveWhitespace()
23182318

2319-
main << (non_math + ZeroOrMore(math_string + non_math)) + StringEnd()
2319+
main <<= (non_math + ZeroOrMore(math_string + non_math)) + StringEnd()
23202320

23212321
# Set actions
23222322
for key, val in locals().items():

setupext.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -970,30 +970,25 @@ def check(self):
970970
"support. pip/easy_install may attempt to install it "
971971
"after matplotlib.")
972972

973-
if sys.version_info[0] >= 3:
974-
required = [2, 0, 0]
975-
if [int(x) for x in pyparsing.__version__.split('.')] < required:
976-
return (
977-
"matplotlib requires pyparsing >= {0} on Python 3.x".format(
978-
'.'.join(str(x) for x in required)))
979-
else:
980-
required = [1, 5, 6]
981-
if [int(x) for x in pyparsing.__version__.split('.')] < required:
982-
return (
983-
"matplotlib requires pyparsing >= {0} on Python 2.x".format(
984-
'.'.join(str(x) for x in required)))
985-
if pyparsing.__version__ == "2.0.0":
973+
required = [1, 5, 6]
974+
if [int(x) for x in pyparsing.__version__.split('.')] < required:
975+
return (
976+
"matplotlib requires pyparsing >= {0}".format(
977+
'.'.join(str(x) for x in required)))
978+
979+
if pyparsing.__version__ == "2.0.0":
980+
if sys.version_info[0] == 2:
986981
return (
987982
"pyparsing 2.0.0 is not compatible with Python 2.x")
983+
else:
984+
return (
985+
"pyparsing 2.0.0 has bugs that prevent its use with "
986+
"matplotlib")
988987

989988
return "using pyparsing version %s" % pyparsing.__version__
990989

991990
def get_install_requires(self):
992-
if sys.version_info[0] >= 3:
993-
return ['pyparsing>=1.5.6']
994-
else:
995-
# pyparsing >= 2.0.0 is not compatible with Python 2
996-
return ['pyparsing>=1.5.6,!=2.0.0']
991+
return ['pyparsing>=1.5.6,!=2.0.0']
997992

998993

999994
class BackendAgg(OptionalBackendPackage):

0 commit comments

Comments
 (0)