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
Łukasz Nowak
slapos.buildout
Commits
cfaff2c3
Commit
cfaff2c3
authored
Oct 25, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for escaping $ with $$
parent
029a1540
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
16 deletions
+84
-16
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+16
-16
src/zc/buildout/tests.py
src/zc/buildout/tests.py
+68
-0
No files found.
src/zc/buildout/buildout.py
View file @
cfaff2c3
...
...
@@ -703,7 +703,7 @@ class Buildout(DictMixin):
if
part
in
install_parts
:
old_options
=
installed_part_options
[
part
].
copy
()
installed_files
=
old_options
.
pop
(
'__buildout_installed__'
)
new_options
=
self
.
get
(
part
)
new_options
=
self
.
get
(
part
)
.
copy
()
if
old_options
==
new_options
:
# The options are the same, but are all of the
# installed files still there? If not, we should
...
...
@@ -1397,11 +1397,15 @@ class Options(DictMixin):
def
_dosub
(
self
,
option
,
v
):
__doing__
=
'Getting option %s:%s.'
,
self
.
name
,
option
seen
=
[(
self
.
name
,
option
)]
v
=
'$$'
.
join
([
self
.
_sub
(
s
,
seen
)
for
s
in
v
.
split
(
'$$'
)])
v
=
'$$'
.
join
([
self
.
_sub
(
s
,
seen
,
last
=
False
)
for
s
in
v
.
split
(
'$$'
)])
self
.
_cooked
[
option
]
=
v
def
get
(
self
,
option
,
default
=
None
,
seen
=
None
):
def
get
(
self
,
option
,
default
=
None
,
seen
=
None
,
last
=
True
):
try
:
if
last
:
return
self
.
_data
[
option
].
replace
(
'$${'
,
'${'
)
else
:
return
self
.
_data
[
option
]
except
KeyError
:
pass
...
...
@@ -1424,16 +1428,20 @@ class Options(DictMixin):
)
else
:
seen
.
append
(
key
)
v
=
'$$'
.
join
([
self
.
_sub
(
s
,
seen
)
for
s
in
v
.
split
(
'$$'
)])
v
=
'$$'
.
join
([
self
.
_sub
(
s
,
seen
,
last
=
False
)
for
s
in
v
.
split
(
'$$'
)])
seen
.
pop
()
self
.
_data
[
option
]
=
v
if
last
:
return
v
.
replace
(
'$${'
,
'${'
)
else
:
return
v
_template_split
=
re
.
compile
(
'([$]{[^}]*})'
).
split
_simple
=
re
.
compile
(
'[-a-zA-Z0-9 ._]+$'
).
match
_valid
=
re
.
compile
(
'
\
${[-
a
-zA-Z0-9 ._]*:[-a-zA-Z0-9 ._]+}$'
).
match
def
_sub
(
self
,
template
,
seen
):
def
_sub
(
self
,
template
,
seen
,
last
=
True
):
value
=
self
.
_template_split
(
template
)
subs
=
[]
for
ref
in
value
[
1
::
2
]:
...
...
@@ -1463,7 +1471,7 @@ class Options(DictMixin):
section
=
self
.
name
elif
section
!=
'buildout'
:
self
.
_dependency
.
add
(
section
)
v
=
self
.
buildout
[
section
].
get
(
option
,
None
,
seen
)
v
=
self
.
buildout
[
section
].
get
(
option
,
None
,
seen
,
last
=
last
)
if
v
is
None
:
if
option
==
'_buildout_section_name_'
:
v
=
self
.
name
...
...
@@ -1476,14 +1484,6 @@ class Options(DictMixin):
return
''
.
join
([
''
.
join
(
v
)
for
v
in
zip
(
value
[::
2
],
subs
)])
def
__getitem__
(
self
,
key
):
try
:
v
=
self
.
_data
[
key
]
if
v
.
startswith
(
SERIALISED_VALUE_MAGIC
):
v
=
loads
(
v
)
return
v
except
KeyError
:
pass
v
=
self
.
get
(
key
)
if
v
is
None
:
raise
MissingOption
(
"Missing option: %s:%s"
%
(
self
.
name
,
key
))
...
...
src/zc/buildout/tests.py
View file @
cfaff2c3
...
...
@@ -1007,6 +1007,7 @@ Uninstall recipes need to be called when a part is removed too:
uninstalling
Installing demo.
installing
Unused options for demo: 'x'.
>>> write('buildout.cfg', '''
...
...
@@ -2742,6 +2743,73 @@ def increment_on_command_line():
recipe='zc.buildout:debug'
"""
def
bug_664539_simple_buildout
():
r"""
>>> write('buildout.cfg', '''
... [buildout]
... parts = escape
...
... [escape]
... recipe = zc.buildout:debug
... foo = $${nonexistent:option}
... ''')
>>> print_(system(buildout), end='')
Installing escape.
foo='${nonexistent:option}'
recipe='zc.buildout:debug'
"""
def
bug_664539_reference
():
r"""
>>> write('buildout.cfg', '''
... [buildout]
... parts = escape
...
... [escape]
... recipe = zc.buildout:debug
... foo = ${:bar}
... bar = $${nonexistent:option}
... ''')
>>> print_(system(buildout), end='')
Installing escape.
bar='${nonexistent:option}'
foo='${nonexistent:option}'
recipe='zc.buildout:debug'
"""
def
bug_664539_complex_buildout
():
r"""
>>> write('buildout.cfg', '''
... [buildout]
... parts = escape
...
... [escape]
... recipe = zc.buildout:debug
... foo = ${level1:foo}
...
... [level1]
... recipe = zc.buildout:debug
... foo = ${level2:foo}
...
... [level2]
... recipe = zc.buildout:debug
... foo = $${nonexistent:option}
... ''')
>>> print_(system(buildout), end='')
Installing level2.
foo='${nonexistent:option}'
recipe='zc.buildout:debug'
Installing level1.
foo='${nonexistent:option}'
recipe='zc.buildout:debug'
Installing escape.
foo='${nonexistent:option}'
recipe='zc.buildout:debug'
"""
def
test_constrained_requirement
():
"""
zc.buildout.easy_install._constrained_requirement(constraint, requirement)
...
...
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