mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-08 00:10:29 +03:00
make Build class act more like a dict
This makes it a lot easier to work with Build instances with parsing and dumping libraries, since they expect only core Python types (dict, list, tuple, str, etc)
This commit is contained in:
parent
14f204cfe1
commit
4625651192
1 changed files with 18 additions and 2 deletions
|
|
@ -25,6 +25,7 @@ import cgi
|
||||||
import logging
|
import logging
|
||||||
import textwrap
|
import textwrap
|
||||||
import io
|
import io
|
||||||
|
import pprint
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
# use libyaml if it is available
|
# use libyaml if it is available
|
||||||
|
|
@ -309,7 +310,7 @@ build_flags = set(build_flags_order + ['version', 'vercode'])
|
||||||
|
|
||||||
class Build():
|
class Build():
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, copydict=None):
|
||||||
self.disable = False
|
self.disable = False
|
||||||
self.commit = None
|
self.commit = None
|
||||||
self.subdir = None
|
self.subdir = None
|
||||||
|
|
@ -342,6 +343,16 @@ class Build():
|
||||||
|
|
||||||
self._modified = set()
|
self._modified = set()
|
||||||
|
|
||||||
|
if copydict:
|
||||||
|
for k, v in copydict.items():
|
||||||
|
self.set_flag(k, v)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return pprint.pformat(self.__dict__)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return self.__str__()
|
||||||
|
|
||||||
def get_flag(self, f):
|
def get_flag(self, f):
|
||||||
if f not in build_flags:
|
if f not in build_flags:
|
||||||
warn_or_exception('Unrecognised build flag: ' + f)
|
warn_or_exception('Unrecognised build flag: ' + f)
|
||||||
|
|
@ -893,7 +904,12 @@ def post_metadata_parse(app):
|
||||||
if type(v) in (float, int):
|
if type(v) in (float, int):
|
||||||
app.__dict__[k] = str(v)
|
app.__dict__[k] = str(v)
|
||||||
|
|
||||||
|
builds = []
|
||||||
for build in app.builds:
|
for build in app.builds:
|
||||||
|
if not isinstance(build, Build):
|
||||||
|
build = Build(build)
|
||||||
|
builds.append(build)
|
||||||
|
|
||||||
for k in build._modified:
|
for k in build._modified:
|
||||||
v = build.__dict__[k]
|
v = build.__dict__[k]
|
||||||
if type(v) in (float, int):
|
if type(v) in (float, int):
|
||||||
|
|
@ -919,7 +935,7 @@ def post_metadata_parse(app):
|
||||||
if not app.Description:
|
if not app.Description:
|
||||||
app.Description = 'No description available'
|
app.Description = 'No description available'
|
||||||
|
|
||||||
app.builds = sorted_builds(app.builds)
|
app.builds = sorted_builds(builds)
|
||||||
|
|
||||||
|
|
||||||
# Parse metadata for a single application.
|
# Parse metadata for a single application.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue