Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos.buildout
Commits
d32669a0
Commit
d32669a0
authored
Mar 17, 2013
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formatting and minor refactoring of defau;t globals arg.
parent
c39cdf2a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
13 deletions
+17
-13
src/zc/buildout/configparser.py
src/zc/buildout/configparser.py
+17
-13
No files found.
src/zc/buildout/configparser.py
View file @
d32669a0
...
...
@@ -111,7 +111,7 @@ option_start = re.compile(
leading_blank_lines = re.compile(r"^(
\
s*
\
n)+")
def parse(fp, fpname, exp_globals=
None
):
def parse(fp, fpname, exp_globals=
dict
):
"""Parse a sectioned setup file.
The sections in setup files contain a title line at the top,
...
...
@@ -176,18 +176,22 @@ def parse(fp, fpname, exp_globals=None):
if expression:
# normalize tail comments to Python style
tail = tail.replace(';', '#') if tail else ''
# un-escape literal # and ; . Do not use a string-escape decode
# un-escape literal # and ; . Do not use a
# string-escape decode
expr = expression.replace(r'
\
x23
','#').replace(r'x3b', ';')
# rebuild a valid Python expression wrapped in a list
expr = head + expr + tail
# lazily populate context only expression
if not context:
context = exp_globals()
if exp_globals else {}
context = exp_globals()
# evaluated expression is in list: get first element
section_condition = eval(expr, context)[0]
# finally, ignore section when an expression evaluates to false
# finally, ignore section when an expression
# evaluates to false
if not section_condition:
logger.debug('Ignoring section %(sectname)r with [expression]: %(expression)r' % locals())
logger.debug(
'Ignoring section %(sectname)r with [expression]:'
' %(expression)r' % locals())
continue
if sectname in sections:
...
...
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