1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-05 18:50:09 +02:00

yml metadata write: do not use local functions

This commit is contained in:
Michael Pöhn 2019-03-19 01:01:18 +01:00
parent 881a79fa84
commit 2683b37044
2 changed files with 85 additions and 85 deletions

View File

@ -1115,15 +1115,7 @@ def post_parse_yaml_metadata(yamldata):
build[flag] = ' && '.join(build[flag])
def write_yaml(mf, app):
"""Write metadata in yaml format.
:param mf: active file discriptor for writing
:param app: app metadata to written to the yaml file
"""
def format_yml_field(field, value, typ, width=80, offset=0):
# TODO: use CSafeDumper if available
def _format_yml_field(field, value, typ, width=80, offset=0):
bool_list_hack = ['gradle']
@ -1189,13 +1181,14 @@ def write_yaml(mf, app):
return raw_yml
def format_yml_build_entry(build):
def _format_yml_build_entry(build):
result = []
for field in build_flags:
value = getattr(build, field, None)
if value:
typ = flagtype(field)
line = format_yml_field(field, value, typ, width=0xffffffff, offset=4)
line = _format_yml_field(field, value, typ, width=0xffffffff, offset=4)
if re.match(r'^\s+$', line):
result.append('')
else:
@ -1203,6 +1196,14 @@ def write_yaml(mf, app):
result[0] = ' - ' + result[0][4:]
return '\n'.join(result)
def write_yaml(mf, app):
"""Write metadata in yaml format.
:param mf: active file discriptor for writing
:param app: app metadata to written to the yaml file
"""
result = []
for field in yaml_app_field_order:
if field == '\n':
@ -1219,9 +1220,9 @@ def write_yaml(mf, app):
first_build_entry = False
else:
result.append('')
result.append(format_yml_build_entry(build))
result.append(_format_yml_build_entry(build))
if value:
result.append(format_yml_field(field, value, yml_fieldtype(field)))
result.append(_format_yml_field(field, value, yml_fieldtype(field)))
mf.write('\n'.join(result))

View File

@ -258,7 +258,6 @@ class MetadataTest(unittest.TestCase):
NoSourceSince: 1.0.1"""))
def test_rewrite_yaml_fakeotaupdate(self):
testdir = tempfile.mkdtemp(prefix=inspect.currentframe().f_code.co_name, dir=self.tmpdir)
fdroidserver.common.config = {'accepted_formats': ['txt', 'yml']}