mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-08 16:30:28 +03:00
Merge branch 'yaml-template' into 'master'
update: remove ruamel requirement, and improve '--create-metadata' Closes #343 See merge request !300
This commit is contained in:
commit
747ac52a62
2 changed files with 28 additions and 11 deletions
|
|
@ -1051,8 +1051,10 @@ def write_yaml(mf, app):
|
||||||
# next iteration will need to insert a newline
|
# next iteration will need to insert a newline
|
||||||
insert_newline = True
|
insert_newline = True
|
||||||
else:
|
else:
|
||||||
if (hasattr(app, field) and getattr(app, field)) or field is 'Builds':
|
if app.get(field) or field is 'Builds':
|
||||||
|
# .txt calls it 'builds' internally, everywhere else its 'Builds'
|
||||||
if field is 'Builds':
|
if field is 'Builds':
|
||||||
|
if app.get('builds'):
|
||||||
cm.update({field: _builds_to_yaml(app)})
|
cm.update({field: _builds_to_yaml(app)})
|
||||||
elif field is 'CurrentVersionCode':
|
elif field is 'CurrentVersionCode':
|
||||||
cm.update({field: _field_to_yaml(TYPE_INT, getattr(app, field))})
|
cm.update({field: _field_to_yaml(TYPE_INT, getattr(app, field))})
|
||||||
|
|
|
||||||
|
|
@ -1761,17 +1761,32 @@ def main():
|
||||||
if apk['packageName'] not in apps:
|
if apk['packageName'] not in apps:
|
||||||
if options.create_metadata:
|
if options.create_metadata:
|
||||||
with open(os.path.join('metadata', apk['packageName'] + '.yml'), 'w') as f:
|
with open(os.path.join('metadata', apk['packageName'] + '.yml'), 'w') as f:
|
||||||
app = metadata.App()
|
# this should use metadata.App() and
|
||||||
|
# metadata.write_yaml(), but since ruamel.yaml
|
||||||
|
# 0.13 is not widely distributed yet, and it's
|
||||||
|
# special tricks are not really needed here, this
|
||||||
|
# uses the plain YAML lib
|
||||||
|
app = dict()
|
||||||
if 'name' in apk:
|
if 'name' in apk:
|
||||||
app.Name = apk['name']
|
app['Name'] = apk['name']
|
||||||
app.Summary = apk['name']
|
|
||||||
else:
|
else:
|
||||||
logging.warn(apk['packageName'] + ' does not have a name! Using package name instead.')
|
logging.warning(apk['packageName'] + ' does not have a name! Using package name instead.')
|
||||||
app.Name = apk['packageName']
|
app['Name'] = apk['packageName']
|
||||||
app.Summary = apk['packageName']
|
app['Categories'] = [os.path.basename(os.getcwd())]
|
||||||
app.CurrentVersionCode = 2147483647 # Java's Integer.MAX_VALUE
|
# include some blanks as part of the template
|
||||||
app.Categories = [os.path.basename(os.path.dirname(os.getcwd()))]
|
app['AuthorName'] = ''
|
||||||
metadata.write_yaml(f, app)
|
app['Summary'] = ''
|
||||||
|
app['WebSite'] = ''
|
||||||
|
app['IssueTracker'] = ''
|
||||||
|
app['SourceCode'] = ''
|
||||||
|
app['CurrentVersionCode'] = 2147483647 # Java's Integer.MAX_VALUE
|
||||||
|
try:
|
||||||
|
import ruamel.yaml
|
||||||
|
assert ruamel.yaml # silence pyflakes
|
||||||
|
metadata.write_yaml(f, metadata.App(app))
|
||||||
|
except ImportError:
|
||||||
|
import yaml
|
||||||
|
yaml.dump(app, f, default_flow_style=False)
|
||||||
logging.info("Generated skeleton metadata for " + apk['packageName'])
|
logging.info("Generated skeleton metadata for " + apk['packageName'])
|
||||||
newmetadata = True
|
newmetadata = True
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue