1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-09-19 19:40:17 +02:00

Remove unnecessary indenting

This commit is contained in:
Daniel Martí 2013-10-10 16:45:17 +02:00
parent f9eda50276
commit 697011f086

View File

@ -488,103 +488,106 @@ def make_index(apps, apks, repodir, archive, categories):
for app in apps: for app in apps:
if app['Disabled'] is None: if app['Disabled'] is not None:
continue
# Get a list of the apks for this app... # Get a list of the apks for this app...
apklist = [] apklist = []
for apk in apks: for apk in apks:
if apk['id'] == app['id']: if apk['id'] == app['id']:
apklist.append(apk) apklist.append(apk)
if len(apklist) != 0: if len(apklist) == 0:
apel = doc.createElement("application") continue
apel.setAttribute("id", app['id'])
root.appendChild(apel)
addElement('id', app['id'], doc, apel) apel = doc.createElement("application")
if 'added' in app: apel.setAttribute("id", app['id'])
addElement('added', time.strftime('%Y-%m-%d', app['added']), doc, apel) root.appendChild(apel)
if 'lastupdated' in app:
addElement('lastupdated', time.strftime('%Y-%m-%d', app['lastupdated']), doc, apel)
addElement('name', app['Name'], doc, apel)
addElement('summary', app['Summary'], doc, apel)
addElement('icon', app['icon'], doc, apel)
def linkres(link):
for app in apps:
if app['id'] == link:
return ("fdroid.app:" + link, app['Name'])
raise MetaDataException("Cannot resolve app id " + link)
addElement('desc',
common.description_html(app['Description'], linkres), doc, apel)
addElement('license', app['License'], doc, apel)
if 'Category' in app:
# We put the first (primary) category in LAST, which will have
# the desired effect of making clients that only understand one
# category see that one.
cats = app['Category'].split(';')
cats.reverse()
for cat in cats:
addElement('category', cat, doc, apel)
addElement('web', app['Web Site'], doc, apel)
addElement('source', app['Source Code'], doc, apel)
addElement('tracker', app['Issue Tracker'], doc, apel)
if app['Donate'] != None:
addElement('donate', app['Donate'], doc, apel)
if app['Bitcoin'] != None:
addElement('bitcoin', app['Bitcoin'], doc, apel)
if app['FlattrID'] != None:
addElement('flattr', app['FlattrID'], doc, apel)
# These elements actually refer to the current version (i.e. which addElement('id', app['id'], doc, apel)
# one is recommended. They are historically mis-named, and need if 'added' in app:
# changing, but stay like this for now to support existing clients. addElement('added', time.strftime('%Y-%m-%d', app['added']), doc, apel)
addElement('marketversion', app['Current Version'], doc, apel) if 'lastupdated' in app:
addElement('marketvercode', app['Current Version Code'], doc, apel) addElement('lastupdated', time.strftime('%Y-%m-%d', app['lastupdated']), doc, apel)
addElement('name', app['Name'], doc, apel)
addElement('summary', app['Summary'], doc, apel)
addElement('icon', app['icon'], doc, apel)
def linkres(link):
for app in apps:
if app['id'] == link:
return ("fdroid.app:" + link, app['Name'])
raise MetaDataException("Cannot resolve app id " + link)
addElement('desc',
common.description_html(app['Description'], linkres), doc, apel)
addElement('license', app['License'], doc, apel)
if 'Category' in app:
# We put the first (primary) category in LAST, which will have
# the desired effect of making clients that only understand one
# category see that one.
cats = app['Category'].split(';')
cats.reverse()
for cat in cats:
addElement('category', cat, doc, apel)
addElement('web', app['Web Site'], doc, apel)
addElement('source', app['Source Code'], doc, apel)
addElement('tracker', app['Issue Tracker'], doc, apel)
if app['Donate'] != None:
addElement('donate', app['Donate'], doc, apel)
if app['Bitcoin'] != None:
addElement('bitcoin', app['Bitcoin'], doc, apel)
if app['FlattrID'] != None:
addElement('flattr', app['FlattrID'], doc, apel)
if app['AntiFeatures']: # These elements actually refer to the current version (i.e. which
addElement('antifeatures', app['AntiFeatures'], doc, apel) # one is recommended. They are historically mis-named, and need
if app['Requires Root']: # changing, but stay like this for now to support existing clients.
addElement('requirements', 'root', doc, apel) addElement('marketversion', app['Current Version'], doc, apel)
addElement('marketvercode', app['Current Version Code'], doc, apel)
# Sort the apk list into version order, just so the web site if app['AntiFeatures']:
# doesn't have to do any work by default... addElement('antifeatures', app['AntiFeatures'], doc, apel)
apklist = sorted(apklist, key=lambda apk: apk['versioncode'], reverse=True) if app['Requires Root']:
addElement('requirements', 'root', doc, apel)
# Check for duplicates - they will make the client unhappy... # Sort the apk list into version order, just so the web site
for i in range(len(apklist) - 1): # doesn't have to do any work by default...
if apklist[i]['versioncode'] == apklist[i+1]['versioncode']: apklist = sorted(apklist, key=lambda apk: apk['versioncode'], reverse=True)
print "ERROR - duplicate versions"
print apklist[i]['apkname']
print apklist[i+1]['apkname']
sys.exit(1)
for apk in apklist: # Check for duplicates - they will make the client unhappy...
apkel = doc.createElement("package") for i in range(len(apklist) - 1):
apel.appendChild(apkel) if apklist[i]['versioncode'] == apklist[i+1]['versioncode']:
addElement('version', apk['version'], doc, apkel) print "ERROR - duplicate versions"
addElement('versioncode', str(apk['versioncode']), doc, apkel) print apklist[i]['apkname']
addElement('apkname', apk['apkname'], doc, apkel) print apklist[i+1]['apkname']
if 'srcname' in apk: sys.exit(1)
addElement('srcname', apk['srcname'], doc, apkel)
for hash_type in ['sha256']: for apk in apklist:
if not hash_type in apk: apkel = doc.createElement("package")
continue apel.appendChild(apkel)
hashel = doc.createElement("hash") addElement('version', apk['version'], doc, apkel)
hashel.setAttribute("type", hash_type) addElement('versioncode', str(apk['versioncode']), doc, apkel)
hashel.appendChild(doc.createTextNode(apk[hash_type])) addElement('apkname', apk['apkname'], doc, apkel)
apkel.appendChild(hashel) if 'srcname' in apk:
addElement('sig', apk['sig'], doc, apkel) addElement('srcname', apk['srcname'], doc, apkel)
addElement('size', str(apk['size']), doc, apkel) for hash_type in ['sha256']:
addElement('sdkver', str(apk['sdkversion']), doc, apkel) if not hash_type in apk:
if 'added' in apk: continue
addElement('added', time.strftime('%Y-%m-%d', apk['added']), doc, apkel) hashel = doc.createElement("hash")
perms = "" hashel.setAttribute("type", hash_type)
if len(apk['permissions']) > 0: hashel.appendChild(doc.createTextNode(apk[hash_type]))
addElement('permissions', ','.join(apk['permissions']), doc, apkel) apkel.appendChild(hashel)
if 'nativecode' in apk and len(apk['nativecode']) > 0: addElement('sig', apk['sig'], doc, apkel)
addElement('nativecode', ','.join(apk['nativecode']), doc, apkel) addElement('size', str(apk['size']), doc, apkel)
if len(apk['features']) > 0: addElement('sdkver', str(apk['sdkversion']), doc, apkel)
addElement('features', ','.join(apk['features']), doc, apkel) if 'added' in apk:
addElement('added', time.strftime('%Y-%m-%d', apk['added']), doc, apkel)
perms = ""
if len(apk['permissions']) > 0:
addElement('permissions', ','.join(apk['permissions']), doc, apkel)
if 'nativecode' in apk and len(apk['nativecode']) > 0:
addElement('nativecode', ','.join(apk['nativecode']), doc, apkel)
if len(apk['features']) > 0:
addElement('features', ','.join(apk['features']), doc, apkel)
of = open(os.path.join(repodir, 'index.xml'), 'wb') of = open(os.path.join(repodir, 'index.xml'), 'wb')
if options.pretty: if options.pretty: