From: Hans-Christoph Steiner Date: Thu, 27 Apr 2017 19:12:49 +0000 (+0200) Subject: downcase all 'localized' key names to match the rest of index-v1 X-Git-Tag: 0.8~69^2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=cdef5bcd92eb15ce2c24fbb02af14883f00f95a5;p=fdroidserver.git downcase all 'localized' key names to match the rest of index-v1 This is a little omission. keys that are used in metadata/*.yml all start with an UpperCase letter, but in fdroidserver, index-v1.json, and fdroidclient, it is all camelCase with lowercase first letter. The keys from the 'localized' section are currently never in metadata/*.yml, so these keys never get downcase. This change will break fdroidclient versions that do not also have this change, but since we're in alpha, that should be fine. If support for a 'localized' section is added to metadata/*.yml, then the keys there should probably be UpperCase CamelCase to match the other keys. --- diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 629d1b4a..2d3864d8 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -93,12 +93,12 @@ default_config = { 'keystore': 'keystore.jks', 'smartcardoptions': [], 'char_limits': { - 'Author': 256, - 'Name': 30, - 'Summary': 80, - 'Description': 4000, - 'Video': 256, - 'WhatsNew': 500, + 'author': 256, + 'name': 30, + 'summary': 80, + 'description': 4000, + 'video': 256, + 'whatsNew': 500, }, 'keyaliases': {}, 'repo_url': "https://MyFirstFDroidRepo.org/fdroid/repo", diff --git a/fdroidserver/lint.py b/fdroidserver/lint.py index b9c0eaf8..125a9638 100644 --- a/fdroidserver/lint.py +++ b/fdroidserver/lint.py @@ -163,13 +163,13 @@ def check_ucm_tags(app): def check_char_limits(app): limits = config['char_limits'] - if len(app.Summary) > limits['Summary']: + if len(app.Summary) > limits['summary']: yield "Summary of length %s is over the %i char limit" % ( - len(app.Summary), limits['Summary']) + len(app.Summary), limits['summary']) - if len(app.Description) > limits['Description']: + if len(app.Description) > limits['description']: yield "Description of length %s is over the %i char limit" % ( - len(app.Description), limits['Description']) + len(app.Description), limits['description']) def check_old_links(app): diff --git a/fdroidserver/update.py b/fdroidserver/update.py index d08bb25b..f89513d6 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -575,7 +575,7 @@ def _set_localized_text_entry(app, locale, key, f): def _set_author_entry(app, key, f): - limit = config['char_limits']['Author'] + limit = config['char_limits']['author'] with open(f) as fp: text = fp.read()[:limit] if len(text) > 0: @@ -612,33 +612,33 @@ def copy_triple_t_store_metadata(apps): locale = segments[-2] for f in files: if f == 'fulldescription': - _set_localized_text_entry(app, locale, 'Description', + _set_localized_text_entry(app, locale, 'description', os.path.join(root, f)) continue elif f == 'shortdescription': - _set_localized_text_entry(app, locale, 'Summary', + _set_localized_text_entry(app, locale, 'summary', os.path.join(root, f)) continue elif f == 'title': - _set_localized_text_entry(app, locale, 'Name', + _set_localized_text_entry(app, locale, 'name', os.path.join(root, f)) continue elif f == 'video': - _set_localized_text_entry(app, locale, 'Video', + _set_localized_text_entry(app, locale, 'video', os.path.join(root, f)) continue elif f == 'whatsnew': - _set_localized_text_entry(app, segments[-1], 'WhatsNew', + _set_localized_text_entry(app, segments[-1], 'whatsNew', os.path.join(root, f)) continue elif f == 'contactEmail': - _set_author_entry(app, 'AuthorEmail', os.path.join(root, f)) + _set_author_entry(app, 'authorEmail', os.path.join(root, f)) continue elif f == 'contactPhone': - _set_author_entry(app, 'AuthorPhone', os.path.join(root, f)) + _set_author_entry(app, 'authorPhone', os.path.join(root, f)) continue elif f == 'contactWebsite': - _set_author_entry(app, 'AuthorWebSite', os.path.join(root, f)) + _set_author_entry(app, 'authorWebSite', os.path.join(root, f)) continue base, extension = common.get_extension(f) @@ -664,7 +664,8 @@ def insert_localized_app_metadata(apps): and adds them to the app metadata. The screenshots and graphic must be PNG or JPEG files ending with ".png", ".jpg", or ".jpeg" and must be in the following layout: - + # TODO replace these docs with link to All_About_Descriptions_Graphics_and_Screenshots + # TODO mention that the 'localized' section is not in metadata.yml, so key names are like Java vars: camelCase with first letter lowercase. repo/packageName/locale/featureGraphic.png repo/packageName/locale/phoneScreenshots/1.png repo/packageName/locale/phoneScreenshots/2.png @@ -709,23 +710,23 @@ def insert_localized_app_metadata(apps): destdir = os.path.join('repo', packageName, locale) for f in files: if f == 'full_description.txt': - _set_localized_text_entry(apps[packageName], locale, 'Description', + _set_localized_text_entry(apps[packageName], locale, 'description', os.path.join(root, f)) continue elif f == 'short_description.txt': - _set_localized_text_entry(apps[packageName], locale, 'Summary', + _set_localized_text_entry(apps[packageName], locale, 'summary', os.path.join(root, f)) continue elif f == 'title.txt': - _set_localized_text_entry(apps[packageName], locale, 'Name', + _set_localized_text_entry(apps[packageName], locale, 'name', os.path.join(root, f)) continue elif f == 'video.txt': - _set_localized_text_entry(apps[packageName], locale, 'Video', + _set_localized_text_entry(apps[packageName], locale, 'video', os.path.join(root, f)) continue elif f == str(apps[packageName]['CurrentVersionCode']) + '.txt': - _set_localized_text_entry(apps[packageName], segments[-2], 'WhatsNew', + _set_localized_text_entry(apps[packageName], segments[-2], 'whatsNew', os.path.join(root, f)) continue diff --git a/tests/update.TestCase b/tests/update.TestCase index b9154b06..1d6dd846 100755 --- a/tests/update.TestCase +++ b/tests/update.TestCase @@ -52,11 +52,11 @@ class UpdateTest(unittest.TestCase): self.assertEqual(1, len(app['localized'])) if packageName == 'info.guardianproject.urzip': self.assertEqual(5, len(app['localized']['en-US'])) - self.assertEqual('full description\n', app['localized']['en-US']['Description']) - self.assertEqual('title\n', app['localized']['en-US']['Name']) - self.assertEqual('short description\n', app['localized']['en-US']['Summary']) - self.assertEqual('video\n', app['localized']['en-US']['Video']) - self.assertEqual('100\n', app['localized']['en-US']['WhatsNew']) + self.assertEqual('full description\n', app['localized']['en-US']['description']) + self.assertEqual('title\n', app['localized']['en-US']['name']) + self.assertEqual('short description\n', app['localized']['en-US']['summary']) + self.assertEqual('video\n', app['localized']['en-US']['video']) + self.assertEqual('100\n', app['localized']['en-US']['whatsNew']) elif packageName == 'org.videolan.vlc': self.assertEqual('icon.png', app['localized']['en-US']['icon']) self.assertEqual(9, len(app['localized']['en-US']['phoneScreenshots']))