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

Add common.py function headers, styling

This commit is contained in:
Daniel Martí 2013-12-19 22:28:38 +01:00
parent d857e43d86
commit 7184ba0f9d

View File

@ -110,11 +110,14 @@ def read_config(opts, config_file='config.py'):
return config return config
def read_pkg_args(args, options, allow_vercodes=False): # Given the arguments in the form of multiple appid:[vc] strings, this returns
if not args: # a dictionary with the set of vercodes specified for each package.
return {} def read_pkg_args(args, allow_vercodes=False):
vercodes = {} vercodes = {}
if not args:
return vercodes
for p in args: for p in args:
if allow_vercodes and ':' in p: if allow_vercodes and ':' in p:
package, vercode = p.split(':') package, vercode = p.split(':')
@ -128,10 +131,17 @@ def read_pkg_args(args, options, allow_vercodes=False):
return vercodes return vercodes
def read_app_args(args, options, allapps, allow_vercodes=False): # On top of what read_pkg_args does, this returns the whole app metadata, but
vercodes = read_pkg_args(args, options, allow_vercodes) # limiting the builds list to the builds matching the vercodes specified.
def read_app_args(args, allapps, allow_vercodes=False):
vercodes = read_pkg_args(args, allow_vercodes)
if not vercodes:
return allapps
apps = [app for app in allapps if app['id'] in vercodes] apps = [app for app in allapps if app['id'] in vercodes]
if not apps: if not apps:
raise Exception("No packages specified") raise Exception("No packages specified")
if len(apps) != len(vercodes): if len(apps) != len(vercodes):
@ -141,20 +151,18 @@ def read_app_args(args, options, allapps, allow_vercodes=False):
print "No such package: %s" % p print "No such package: %s" % p
raise Exception("Found invalid app ids in arguments") raise Exception("Found invalid app ids in arguments")
if not vercodes:
return apps
error = False error = False
for app in apps: for app in apps:
vc = vercodes[app['id']] vc = vercodes[app['id']]
if vc: if not vc:
app['builds'] = [b for b in app['builds'] if b['vercode'] in vc] continue
if len(app['builds']) != len(vercodes[app['id']]): app['builds'] = [b for b in app['builds'] if b['vercode'] in vc]
error = True if len(app['builds']) != len(vercodes[app['id']]):
allvcs = [b['vercode'] for b in app['builds']] error = True
for v in vercodes[app['id']]: allvcs = [b['vercode'] for b in app['builds']]
if v not in allvcs: for v in vercodes[app['id']]:
print "No such vercode %s for app %s" % (v, app['id']) if v not in allvcs:
print "No such vercode %s for app %s" % (v, app['id'])
if error: if error:
raise Exception("Found invalid vercodes for some apps") raise Exception("Found invalid vercodes for some apps")