mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-09-18 19:20:08 +02:00
update: remove ruamel requirement, and improve '--create-metadata'
If ruamel.yaml is not available, this will fallback to using PyYAML. This also adds some blank fields to the newly created template to make it easy for human editors to fill in. closes #343
This commit is contained in:
parent
4a15208b84
commit
3e6b7062b6
@ -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…
Reference in New Issue
Block a user