mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 15:00:30 +03:00
Final touches to yaml writing
Now it writes and reads properly.
This commit is contained in:
parent
23747edb25
commit
53ed335d4b
1 changed files with 27 additions and 11 deletions
|
|
@ -663,10 +663,15 @@ def post_metadata_parse(thisinfo):
|
||||||
if isinstance(v, basestring):
|
if isinstance(v, basestring):
|
||||||
build[k] = [v]
|
build[k] = [v]
|
||||||
elif isinstance(v, bool):
|
elif isinstance(v, bool):
|
||||||
if v:
|
build[k] = ['yes' if v else 'no']
|
||||||
build[k] = ['yes']
|
elif isinstance(v, list):
|
||||||
|
build[k] = []
|
||||||
|
for e in v:
|
||||||
|
if isinstance(e, bool):
|
||||||
|
build[k].append('yes' if v else 'no')
|
||||||
else:
|
else:
|
||||||
build[k] = ['no']
|
build[k].append(e)
|
||||||
|
|
||||||
elif keyflagtype == 'script':
|
elif keyflagtype == 'script':
|
||||||
build[k] = re.sub(esc_newlines, '', v).lstrip().rstrip()
|
build[k] = re.sub(esc_newlines, '', v).lstrip().rstrip()
|
||||||
elif keyflagtype == 'bool':
|
elif keyflagtype == 'bool':
|
||||||
|
|
@ -676,6 +681,9 @@ def post_metadata_parse(thisinfo):
|
||||||
build[k] = True
|
build[k] = True
|
||||||
else:
|
else:
|
||||||
build[k] = False
|
build[k] = False
|
||||||
|
elif keyflagtype == 'string':
|
||||||
|
if isinstance(v, bool):
|
||||||
|
build[k] = 'yes' if v else 'no'
|
||||||
|
|
||||||
if not thisinfo['Description']:
|
if not thisinfo['Description']:
|
||||||
thisinfo['Description'].append('No description available')
|
thisinfo['Description'].append('No description available')
|
||||||
|
|
@ -1167,6 +1175,13 @@ def write_yaml_metadata(mf, app):
|
||||||
def w_comment(line):
|
def w_comment(line):
|
||||||
mf.write("# %s\n" % line)
|
mf.write("# %s\n" % line)
|
||||||
|
|
||||||
|
def escape(value):
|
||||||
|
if not value:
|
||||||
|
return ''
|
||||||
|
if any(c in value for c in [': ', '%', '@', '*']):
|
||||||
|
return "'" + value.replace("'", "''") + "'"
|
||||||
|
return value
|
||||||
|
|
||||||
def w_field(field, value, prefix='', t=None):
|
def w_field(field, value, prefix='', t=None):
|
||||||
if t is None:
|
if t is None:
|
||||||
t = metafieldtype(field)
|
t = metafieldtype(field)
|
||||||
|
|
@ -1174,13 +1189,11 @@ def write_yaml_metadata(mf, app):
|
||||||
if t == 'list':
|
if t == 'list':
|
||||||
v = '\n'
|
v = '\n'
|
||||||
for e in value:
|
for e in value:
|
||||||
v += prefix + ' - ' + e + '\n'
|
v += prefix + ' - ' + escape(e) + '\n'
|
||||||
elif t == 'multiline':
|
elif t == 'multiline':
|
||||||
v = ' |\n'
|
v = ' |\n'
|
||||||
lines = []
|
|
||||||
if type(value) == list:
|
|
||||||
lines = value
|
lines = value
|
||||||
else:
|
if type(value) == str:
|
||||||
lines = value.splitlines()
|
lines = value.splitlines()
|
||||||
for l in lines:
|
for l in lines:
|
||||||
if l:
|
if l:
|
||||||
|
|
@ -1196,9 +1209,12 @@ def write_yaml_metadata(mf, app):
|
||||||
w_field(field, cmds, prefix, 'multiline')
|
w_field(field, cmds, prefix, 'multiline')
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
v = ' ' + value + '\n'
|
v = ' ' + escape(value) + '\n'
|
||||||
|
|
||||||
mf.write("%s%s:%s" % (prefix, field, v))
|
mf.write(prefix)
|
||||||
|
mf.write(field)
|
||||||
|
mf.write(":")
|
||||||
|
mf.write(v)
|
||||||
|
|
||||||
global first_build
|
global first_build
|
||||||
first_build = True
|
first_build = True
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue