[game-data-packager] 37/51: GameData.to_data: Elide file attributes that are implied by groups
Simon McVittie
smcv at debian.org
Fri Dec 29 01:23:37 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 588d1f0fdde13ee0d14b9fe2c73c27847208e236
Author: Simon McVittie <smcv at debian.org>
Date: Thu Dec 28 19:45:20 2017 +0000
GameData.to_data: Elide file attributes that are implied by groups
Signed-off-by: Simon McVittie <smcv at debian.org>
---
game_data_packager/data.py | 8 ++++----
game_data_packager/game.py | 6 ++++++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/game_data_packager/data.py b/game_data_packager/data.py
index 9f689e9..32e15d2 100644
--- a/game_data_packager/data.py
+++ b/game_data_packager/data.py
@@ -421,7 +421,7 @@ class YamlLiteral(str):
yaml.add_representer(YamlLiteral, YamlLiteral.to_yaml)
class FileGroup:
- __APPLY_TO_ALL = (
+ RECURSIVELY_APPLIED = (
'doc', 'executable', 'ignorable', 'install_to', 'license',
'unsuitable',
)
@@ -431,13 +431,13 @@ class FileGroup:
self.group_members = set()
# Attributes to apply to every member of this group.
- for attr in self.__APPLY_TO_ALL:
+ for attr in self.RECURSIVELY_APPLIED:
setattr(self, attr, None)
def apply_group_attributes(self, other):
assert isinstance(other, WantedFile) or isinstance(other, FileGroup)
- for attr in self.__APPLY_TO_ALL:
+ for attr in self.RECURSIVELY_APPLIED:
assert hasattr(other, attr)
value = getattr(self, attr)
@@ -447,7 +447,7 @@ class FileGroup:
def to_data(self, expand=True, files=None, include_ignorable=False):
ret = {}
- for attr in self.__APPLY_TO_ALL:
+ for attr in self.RECURSIVELY_APPLIED:
value = getattr(self, attr)
if value is not None:
diff --git a/game_data_packager/game.py b/game_data_packager/game.py
index ae7e5c3..f621776 100644
--- a/game_data_packager/game.py
+++ b/game_data_packager/game.py
@@ -365,6 +365,12 @@ class GameData(object):
data = f.to_data(expand=expand)
+ for g in self.groups.values():
+ if filename in g.group_members:
+ for attr in FileGroup.RECURSIVELY_APPLIED:
+ if getattr(g, attr) == data.get(attr):
+ data.pop(attr, None)
+
if data or expand:
files[filename] = data
--
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