Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
5896c4ef
Commit
5896c4ef
authored
May 05, 2014
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reindent long lines in marker impl
parent
e7818e76
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
12 deletions
+35
-12
pkg_resources.py
pkg_resources.py
+35
-12
No files found.
pkg_resources.py
View file @
5896c4ef
...
...
@@ -1186,9 +1186,11 @@ class MarkerEvaluation(object):
@staticmethod
def normalize_exception(exc):
"""
Given a SyntaxError from a marker evaluation, normalize the error message:
Given a SyntaxError from a marker evaluation, normalize the error
message:
- Remove indications of filename and line number.
- Replace platform-specific error messages with standard error messages.
- Replace platform-specific error messages with standard error
messages.
"""
subs = {
'unexpected EOF while parsing': 'invalid syntax',
...
...
@@ -1202,12 +1204,20 @@ class MarkerEvaluation(object):
@classmethod
def and_test(cls, nodelist):
# MUST NOT short-circuit evaluation, or invalid syntax can be skipped!
return functools.reduce(operator.and_, [cls.interpret(nodelist[i]) for i in range(1, len(nodelist),2)])
items = [
cls.interpret(nodelist[i])
for i in range(1, len(nodelist), 2)
]
return functools.reduce(operator.and_, items)
@classmethod
def test(cls, nodelist):
# MUST NOT short-circuit evaluation, or invalid syntax can be skipped!
return functools.reduce(operator.or_, [cls.interpret(nodelist[i]) for i in range(1, len(nodelist),2)])
items = [
cls.interpret(nodelist[i])
for i in range(1, len(nodelist), 2)
]
return functools.reduce(operator.or_, items)
@classmethod
def atom(cls, nodelist):
...
...
@@ -1216,12 +1226,14 @@ class MarkerEvaluation(object):
if nodelist[2][0] == token.RPAR:
raise SyntaxError("
Empty
parentheses
")
return cls.interpret(nodelist[2])
raise SyntaxError("
Language
feature
not
supported
in
environment
markers
")
msg = "
Language
feature
not
supported
in
environment
markers
"
raise SyntaxError(msg)
@classmethod
def comparison(cls, nodelist):
if len(nodelist)>4:
raise SyntaxError("
Chained
comparison
not
allowed
in
environment
markers
")
if len(nodelist) > 4:
msg = "
Chained
comparison
not
allowed
in
environment
markers
"
raise SyntaxError(msg)
comp = nodelist[2][1]
cop = comp[1]
if comp[0] == token.NAME:
...
...
@@ -1233,7 +1245,8 @@ class MarkerEvaluation(object):
try:
cop = cls.get_op(cop)
except KeyError:
raise SyntaxError(repr(cop)+"
operator
not
allowed
in
environment
markers
")
msg = repr(cop) + "
operator
not
allowed
in
environment
markers
"
raise SyntaxError(msg)
return cop(cls.evaluate(nodelist[1]), cls.evaluate(nodelist[3]))
@classmethod
...
...
@@ -1259,7 +1272,8 @@ class MarkerEvaluation(object):
Return a boolean indicating the marker result in this environment.
Raise SyntaxError if marker is invalid.
This implementation uses the 'parser' module, which is not implemented on
This implementation uses the 'parser' module, which is not implemented
on
Jython and has been superseded by the 'ast' module in Python 2.6 and
later.
"""
...
...
@@ -1313,12 +1327,21 @@ class MarkerEvaluation(object):
return op()
if kind==token.STRING:
s = nodelist[1]
if s[:1] not in "'
\
"
" or s.startswith('"""') or s.startswith("'''")
\
or '
\
\
' in s:
if not cls._safe_string(s):
raise SyntaxError(
"
Only
plain
strings
allowed
in
environment
markers
")
return s[1:-1]
raise SyntaxError("Language feature not supported in environment markers")
msg = "
Language
feature
not
supported
in
environment
markers
"
raise SyntaxError(msg)
@staticmethod
def _safe_string(cand):
return (
cand[:1] in "'
\
"
" and
not cand.startswith('"""') and
not cand.startswith("'''") and
'
\
\
' not in cand
)
invalid_marker = MarkerEvaluation.is_invalid_marker
evaluate_marker = MarkerEvaluation.evaluate_marker
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment