Commit a2107a92 authored by Kirill Smelkov's avatar Kirill Smelkov

Handle %(__buildout_space_n__)s & co in .installed.cfg

For example here is how it occurs in .installed.cfg for ERP5 SR:

    [jupyter]
    eggs = jupyter
            jupyter_client
            jupyter_console
            ...
            jupyterlab
            jupyterlab-launcher%(__buildout_space_n__)s

and without the fix it breaks as

    configparser.InterpolationMissingOptionError: Bad value substitution: option 'eggs' in section 'zzz' contains an interpolation key '__buildout_space_n__' which is not a valid option name. Raw value: '\naaa\nbbb%(__buildout_space_n__)s'
parent 98687ba0
...@@ -72,7 +72,14 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo ...@@ -72,7 +72,14 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo
bom[bkey] = info bom[bkey] = info
idb = configparser.ConfigParser() _ = {
'__buildout_space__': ' ',
'__buildout_space_n__': '\n',
'__buildout_space_r__': '\r',
'__buildout_space_f__': '\f',
'__buildout_space_v__': '\v',
}
idb = configparser.ConfigParser(defaults=_)
idb.read('%s/.installed.cfg' % installed_software_path) idb.read('%s/.installed.cfg' % installed_software_path)
...@@ -157,6 +164,8 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo ...@@ -157,6 +164,8 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo
eggdev = part['_d'] eggdev = part['_d']
eggs = part.get('eggs', part.name).split('\n') eggs = part.get('eggs', part.name).split('\n')
for eggname in eggs: for eggname in eggs:
if eggname == '': # happens when %(__buildout_space_n__)s is appended to eggname
continue # because software.cfg contained vspace
m = _egg_re.match(eggname) m = _egg_re.match(eggname)
assert m is not None, eggname assert m is not None, eggname
eggname = m.group('name') # neoppod[admin, ctl, master] -> neoppod eggname = m.group('name') # neoppod[admin, ctl, master] -> neoppod
......
...@@ -225,6 +225,23 @@ msgpack 0.5.4 http://downloads.sourceforge.net/project ...@@ -225,6 +225,23 @@ msgpack 0.5.4 http://downloads.sourceforge.net/project
msgpack 0.6.2 https://pypi.org/project/msgpack/0.6.2/ msgpack 0.6.2 https://pypi.org/project/msgpack/0.6.2/
""") """)
# %(__buildout_space_...) in egg can be read
case1("""\
[zzz]
recipe = zc.recipe.egg
_d = /ROOT/develop-eggs
_e = /ROOT/eggs
eggs =
aaa
bbb%(__buildout_space_n__)s
-- /ROOT/eggs/aaa-1.2.3.egg/x --
-- /ROOT/eggs/bbb-5.6.7.egg/x --
""", """
>>> eggs:
aaa 1.2.3.egg https://pypi.org/project/aaa/1.2.3.egg/
bbb 5.6.7.egg https://pypi.org/project/bbb/5.6.7.egg/
""")
# %20 in URL # %20 in URL
case1("""\ case1("""\
[zabbix-agent] [zabbix-agent]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment