[game-data-packager] 05/51: Package: Output fewer redundant fields in to_data(expand=False)
Simon McVittie
smcv at debian.org
Fri Dec 29 01:23:34 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch master
in repository game-data-packager.
commit b2ffb0a5aa17342cc6e27bdc9e0cfd7b95201fd3
Author: Simon McVittie <smcv at debian.org>
Date: Tue Dec 26 16:54:09 2017 +0000
Package: Output fewer redundant fields in to_data(expand=False)
Signed-off-by: Simon McVittie <smcv at debian.org>
---
game_data_packager/data.py | 39 ++++++++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 11 deletions(-)
diff --git a/game_data_packager/data.py b/game_data_packager/data.py
index 968cdd2..33e31b2 100644
--- a/game_data_packager/data.py
+++ b/game_data_packager/data.py
@@ -771,15 +771,31 @@ class Package(object):
self.langs = [value]
def to_data(self, expand=True):
- ret = {
- 'architecture': self.architecture,
- 'component': self.component,
- 'install_to': self.install_to,
- 'name': self.name,
- 'section': self.section,
- 'type': self.type,
- 'version': self.version,
- }
+ ret = {}
+
+ if expand:
+ ret['name'] = self.name
+ ret['type'] = self.type
+
+ if expand or self.architecture != 'all':
+ ret['architecture'] = self.architecture
+
+ if expand or self.component != 'local':
+ ret['component'] = self.component
+
+ if expand or self.install_to != self.default_install_to:
+ ret['install_to'] = self.install_to
+
+ if expand or self.section != 'games':
+ ret['section'] = self.section
+
+ if expand or self.version != GAME_PACKAGE_VERSION:
+ version = self.version
+
+ if version.endswith('+' + GAME_PACKAGE_VERSION):
+ version = version[:-(len(GAME_PACKAGE_VERSION) + 1)]
+
+ ret['version'] = version
for k in (
'aliases',
@@ -805,8 +821,9 @@ class Package(object):
# sorting order, so do a Schwartzian transform to get a
# stable order
tmp = sorted([(str(x), x.to_data()) for x in related])
- tmp = [x[1] for x in tmp]
- ret[relation] = tmp
+ if tmp:
+ tmp = [x[1] for x in tmp]
+ ret[relation] = tmp
if expand and self.install_files is not None:
if self.install_files:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git
More information about the Pkg-games-commits
mailing list