[game-data-packager] 20/51: Package.to_data: Split docs, licenses and other optional files

Simon McVittie smcv at debian.org
Fri Dec 29 01:23:35 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 d2d8e74a1b7cf05308fd18458ff8ed86f16c0ccd
Author: Simon McVittie <smcv at debian.org>
Date:   Tue Dec 26 18:31:00 2017 +0000

    Package.to_data: Split docs, licenses and other optional files
    
    Signed-off-by: Simon McVittie <smcv at debian.org>
---
 game_data_packager/data.py | 53 +++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 48 insertions(+), 5 deletions(-)

diff --git a/game_data_packager/data.py b/game_data_packager/data.py
index 8983227..18fae88 100644
--- a/game_data_packager/data.py
+++ b/game_data_packager/data.py
@@ -814,7 +814,7 @@ class Package(object):
         assert type(value) is str
         self.langs = [value]
 
-    def to_data(self, expand=True):
+    def to_data(self, expand=True, files=None, groups=None):
         ret = {}
 
         if expand:
@@ -872,19 +872,62 @@ class Package(object):
         if expand and self.install_files is not None:
             if self.install_files:
                 ret['install'] = sorted(f.name for f in self.install_files)
-            if self.optional_files:
-                ret['optional'] = sorted(f.name for f in self.optional_files)
+
             if self.activated_by_files:
                 ret['activated_by'] = sorted(
                     f.name for f in self.activated_by_files)
         else:
             if self.install:
                 ret['install'] = sorted(self.install)
-            if self.optional:
-                ret['optional'] = sorted(self.optional)
+
             if self.activated_by:
                 ret['activated_by'] = sorted(self.activated_by)
 
+        if self.optional:
+            optional = set()
+            licenses = set()
+            docs = set()
+
+            if expand and self.optional_files is not None:
+                for f in self.optional_files:
+                    if f.license:
+                        licenses.add(f.name)
+
+                    if f.doc:
+                        docs.add(f.name)
+
+                    if not f.doc and not f.license:
+                        optional.add(f.name)
+
+            elif files is not None and groups is not None:
+                for name in self.optional:
+                    if name in groups:
+                        f = groups[name]
+                    else:
+                        f = files[name]
+
+                    if f.license:
+                        licenses.add(f.name)
+
+                    if f.doc:
+                        docs.add(f.name)
+
+                    if not f.doc and not f.license:
+                        optional.add(f.name)
+
+            else:
+                # can't distinguish between docs, licenses and others
+                optional = self.optional
+
+            if optional:
+                ret['optional'] = sorted(optional)
+
+            if licenses:
+                ret['license'] = sorted(licenses)
+
+            if docs:
+                ret['doc'] = sorted(docs)
+
         for k in (
                 'copyright',
                 'copyright_notice',

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