1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-09-11 23:23:27 +02:00

Some more txt parsing tweaks after profiling

This commit is contained in:
Daniel Martí 2015-12-03 11:06:27 +01:00
parent 490da2da22
commit 97c991c4b6

View File

@ -209,9 +209,9 @@ def metafieldtype(name):
return 'buildv2' return 'buildv2'
if name == 'Use Built': if name == 'Use Built':
return 'obsolete' return 'obsolete'
if name not in app_fields: if name in app_fields:
return 'unknown' return 'string'
return 'string' return 'unknown'
# In the order in which they are laid out on files # In the order in which they are laid out on files
@ -1065,7 +1065,7 @@ def parse_txt_metadata(metadatapath):
buildlines.append(line.lstrip()) buildlines.append(line.lstrip())
bl = ''.join(buildlines) bl = ''.join(buildlines)
add_buildflag(bl, build) add_buildflag(bl, build)
buildlines = [] del buildlines[:]
else: else:
if not build.commit and not build.disable: if not build.commit and not build.disable:
raise MetaDataException("No commit specified for {0} in {1}" raise MetaDataException("No commit specified for {0} in {1}"
@ -1094,26 +1094,27 @@ def parse_txt_metadata(metadatapath):
if f == 'Market Version Code': if f == 'Market Version Code':
f = 'Current Version Code' f = 'Current Version Code'
fieldtype = metafieldtype(f) ftype = metafieldtype(f)
if fieldtype not in ['build', 'buildv2']: if ftype not in ['build', 'buildv2']:
add_comments(f) add_comments(f)
if fieldtype == 'multiline': if ftype == 'multiline':
mode = 1 mode = 1
if v: if v:
raise MetaDataException("Unexpected text on same line as " + f + " in " + linedesc) raise MetaDataException("Unexpected text on same line as " + f + " in " + linedesc)
elif fieldtype == 'string': elif ftype == 'string':
app.set_field(f, v) app.set_field(f, v)
elif fieldtype == 'list': elif ftype == 'list':
app.set_field(f, split_list_values(v)) app.set_field(f, split_list_values(v))
elif fieldtype == 'build': elif ftype == 'build':
if v.endswith("\\"): if v.endswith("\\"):
mode = 2 mode = 2
buildlines = [v[:-1]] del buildlines[:]
buildlines.append(v[:-1])
else: else:
build = parse_buildline([v]) build = parse_buildline([v])
app.builds.append(build) app.builds.append(build)
add_comments('build:' + app.builds[-1].vercode) add_comments('build:' + app.builds[-1].vercode)
elif fieldtype == 'buildv2': elif ftype == 'buildv2':
build = Build() build = Build()
vv = v.split(',') vv = v.split(',')
if len(vv) != 2: if len(vv) != 2:
@ -1125,9 +1126,9 @@ def parse_txt_metadata(metadatapath):
raise MetaDataException('Duplicate build recipe found for vercode %s in %s' % ( raise MetaDataException('Duplicate build recipe found for vercode %s in %s' % (
build.vercode, linedesc)) build.vercode, linedesc))
vc_seen[build.vercode] = True vc_seen[build.vercode] = True
buildlines = [] del buildlines[:]
mode = 3 mode = 3
elif fieldtype == 'obsolete': elif ftype == 'obsolete':
pass # Just throw it away! pass # Just throw it away!
else: else:
raise MetaDataException("Unrecognised field type for " + f + " in " + linedesc) raise MetaDataException("Unrecognised field type for " + f + " in " + linedesc)