[game-data-packager] 23/51: GameData.load_file_data: Apply doc, license to groups recursively

Simon McVittie smcv at debian.org
Fri Dec 29 01:23:36 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 d2b31f2c5810bb09f1d9577afbc50cc452b41351
Author: Simon McVittie <smcv at debian.org>
Date:   Wed Dec 27 16:59:58 2017 +0000

    GameData.load_file_data: Apply doc, license to groups recursively
    
    Signed-off-by: Simon McVittie <smcv at debian.org>
---
 game_data_packager/__init__.py | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index f7c9a7d..47f4f1a 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -813,22 +813,14 @@ class GameData(object):
         for package in self.packages.values():
             d = self.data['packages'][package.name]
 
-            for filename in d.get('doc', ()):
-                f = self.groups.get(filename)
-
-                if f is None:
-                    f = self._ensure_file(filename)
-
+            for f in self._iter_expand_groups(
+                    d.get('doc', ()), include_groups=True):
                 # WantedFile and FileGroup both have this
                 assert hasattr(f, 'doc')
                 f.doc = True
 
-            for filename in d.get('license', ()):
-                f = self.groups.get(filename)
-
-                if f is None:
-                    f = self._ensure_file(filename)
-
+            for f in self._iter_expand_groups(
+                    d.get('license', ()), include_groups=True):
                 # WantedFile and FileGroup both have this
                 assert hasattr(f, 'license')
                 f.license = True
@@ -1021,16 +1013,22 @@ class GameData(object):
             for member_name in group.group_members:
                 assert member_name in self.files or member_name in self.groups
 
-    def _iter_expand_groups(self, grouped):
+    def _iter_expand_groups(self, grouped, *, include_groups=False):
         """Given a set of strings that are either filenames or groups,
         yield the WantedFile instances for those names or the members of
         those groups, recursively.
+
+        If include_groups is true, also yield the groups themselves.
         """
         for filename in grouped:
             group = self.groups.get(filename)
 
             if group is not None:
-                for x in self._iter_expand_groups(group.group_members):
+                if include_groups:
+                    yield group
+
+                for x in self._iter_expand_groups(
+                        group.group_members, include_groups=include_groups):
                     yield x
             else:
                 yield self._ensure_file(filename)

-- 
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