eliminate app.builds everywhere, it should be app['Builds']

The .txt format was the last place where the lowercase "builds" was used,
this converts references everywhere to be "Builds".  This makes it possible
to load metadata YAML files with any YAML parser, then have it possible to
use fdroidserver methods on that data, like metadata.write_metadata().

The test files in tests/metadata/dump/*.yaml were manually edited by cutting
the builds: block and putting it the sort order for Builds: so the contents
should be unchanged.

```
sed -i \
 -e 's/app\.builds/app.get('Builds', \[\])/g' \
 -e "s/app\.get(Builds, \[\]) =/app\['Builds'] =/g" \
 -e "s/app\.get(Builds, \[\]) =/app\['Builds'] =/g" \
 -e "s/app\.get(Builds, \[\])/app.get('Builds', \[\])/g" \
 -e "s/app\.get('Builds', \[\])\.append/app\['Builds'\].append/g" \
 -e "s/app\['builds'\]/app.get('Builds', [])/g" \
 */*.*
```
This commit is contained in:
Hans-Christoph Steiner 2020-12-09 16:01:21 +01:00
parent 877779195f
commit bf25b4ca03
18 changed files with 275 additions and 279 deletions

View file

@ -641,10 +641,10 @@ def read_app_args(appid_versionCode_pairs, allapps, allow_vercodes=False):
vc = vercodes[appid]
if not vc:
continue
app.builds = [b for b in app.builds if b.versionCode in vc]
if len(app.builds) != len(vercodes[appid]):
app['Builds'] = [b for b in app.get('Builds', []) if b.versionCode in vc]
if len(app.get('Builds', [])) != len(vercodes[appid]):
error = True
allvcs = [b.versionCode for b in app.builds]
allvcs = [b.versionCode for b in app.get('Builds', [])]
for v in vercodes[appid]:
if v not in allvcs:
logging.critical(_("No such versionCode {versionCode} for app {appid}")
@ -1538,8 +1538,8 @@ def parse_androidmanifests(paths, app):
flavour = None
temp_app_id = None
temp_version_name = None
if app.builds and 'gradle' in app.builds[-1] and app.builds[-1].gradle:
flavour = app.builds[-1].gradle[-1]
if len(app.get('Builds', [])) > 0 and 'gradle' in app['Builds'][-1] and app['Builds'][-1].gradle:
flavour = app['Builds'][-1].gradle[-1]
if path.endswith('.gradle') or path.endswith('.gradle.kts'):
with open(path, 'r') as f: