diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 7754ae4b..f463b55d 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -1760,33 +1760,32 @@ def main(): for apk in apks: if apk['packageName'] not in apps: if options.create_metadata: + import yaml with open(os.path.join('metadata', apk['packageName'] + '.yml'), 'w') as f: # 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 os.path.exists('template.yml'): + with open('template.yml') as fp: + app = yaml.load(fp) + else: + app = dict() + app['Categories'] = [os.path.basename(os.getcwd())] + # include some blanks as part of the template + app['AuthorName'] = '' + app['Summary'] = '' + app['WebSite'] = '' + app['IssueTracker'] = '' + app['SourceCode'] = '' + app['CurrentVersionCode'] = 2147483647 # Java's Integer.MAX_VALUE if 'name' in apk and apk['name'] != '': app['Name'] = apk['name'] else: logging.warning(apk['packageName'] + ' does not have a name! Using package name instead.') app['Name'] = apk['packageName'] - app['Categories'] = [os.path.basename(os.getcwd())] - # include some blanks as part of the template - app['AuthorName'] = '' - 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) + yaml.dump(app, f, default_flow_style=False) logging.info("Generated skeleton metadata for " + apk['packageName']) newmetadata = True else: