From 996f141da82acd88f1678fba72a6d9332807ebb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Mon, 2 Dec 2013 15:28:30 +0100 Subject: [PATCH] Make app and version name formats a standard --- fd-commit | 12 +++++++++--- fdroidserver/checkupdates.py | 22 +++++++++++----------- fdroidserver/common.py | 10 ++++++++++ 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/fd-commit b/fd-commit index 9b5a2dcd..8eb9f2b4 100755 --- a/fd-commit +++ b/fd-commit @@ -27,15 +27,21 @@ while read line; do [ -d metadata/$id ] && extra=metadata/$id - name= while read l; do if [[ "$l" == "Auto Name:"* ]]; then + autoname=${l##*:} + elif [[ "$l" == "Name:"* ]]; then name=${l##*:} - break fi done < "$file" - [ -n "$name" ] && fullname="$name ($id)" || fullname=$id + if [ -n "$name" ]; then + fullname="$name ($id)" + elif [ -n "$autoname" ]; then + fullname="$autoname ($id)" + else + fullname="$id" + fi newbuild=0 while read l; do diff --git a/fdroidserver/checkupdates.py b/fdroidserver/checkupdates.py index 97e0ac6e..120569e2 100644 --- a/fdroidserver/checkupdates.py +++ b/fdroidserver/checkupdates.py @@ -309,17 +309,17 @@ def main(): version, reason = check_gplay(app) if version is None and options.verbose: if reason == '404': - print "%s (%s) is not in the Play Store" % (app['Auto Name'], app['id']) + print "%s is not in the Play Store" % common.getappname(app) else: - print "%s (%s) encountered a problem: %s" % (app['Auto Name'], app['id'], reason) + print "%s encountered a problem: %s" % common.getappname(app) if version is not None: stored = app['Current Version'] if LooseVersion(stored) < LooseVersion(version): - print "%s (%s) has version %s on the Play Store, which is bigger than %s" % ( - app['Auto Name'], app['id'], version, stored) + print "%s has version %s on the Play Store, which is bigger than %s" % ( + common.getappname(app), version, stored) elif options.verbose: - print "%s (%s) has the same version %s on the Play Store" % ( - app['Auto Name'], app['id'], version) + print "%s has the same version %s on the Play Store" % ( + common.getappname(app), version) return @@ -409,9 +409,9 @@ def main(): print "ERROR: Auto Name or Current Version failed for %s due to exception: %s" % (app['id'], traceback.format_exc()) if updating: - print '...updating to version %s (%s)' % (app['Current Version'], app['Current Version Code']) - name = '%s (%s)' % (app['Auto Name'], app['id']) if app['Auto Name'] else app['id'] - ver = "%s (%s)" % (app['Current Version'], app['Current Version Code']) + print '...updating to version %s' % ver + name = common.getappname(app) + ver = common.getcvname(app) logmsg = 'Update CV of %s to %s' % (name, ver) if options.auto: @@ -445,8 +445,8 @@ def main(): newbuild['commit'] = commit app['builds'].append(newbuild) writeit = True - name = "%s (%s)" % (app['Auto Name'], app['id']) if app['Auto Name'] else app['id'] - ver = "%s (%s)" % (newbuild['version'], newbuild['vercode']) + name = common.getappname(app) + ver = common.getcvname(app) logmsg = "Update %s to %s" % (name, ver) else: print 'Invalid auto update mode' diff --git a/fdroidserver/common.py b/fdroidserver/common.py index b6c7b9c1..b82f7742 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -75,6 +75,16 @@ def getapkname(app, build): def getsrcname(app, build): return "%s_%s_src.tar.gz" % (app['id'], build['vercode']) +def getappname(app): + if app['Name']: + return '%s (%s)' % (app['Name'], app['id']) + if app['Auto Name']: + return '%s (%s)' % (app['Auto Name'], app['id']) + return app['id'] + +def getcvname(app): + return '%s (%s)' % (app['Current Version'], app['Current Version Code']) + def getvcs(vcstype, remote, local): if vcstype == 'git': return vcs_git(remote, local)