[game-data-packager] 01/02: add size() function to compute package min & max possible sizes

Alexandre Detiste detiste-guest at moszumanska.debian.org
Mon Oct 12 08:55:22 UTC 2015


This is an automated email from the git hooks/post-receive script.

detiste-guest pushed a commit to branch master
in repository game-data-packager.

commit 6a53c32b83bf654834e635b2a02b81f8faf80fb0
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Mon Oct 12 10:47:19 2015 +0200

    add size() function to compute package min & max possible sizes
---
 game_data_packager/__init__.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index 70c6923..4ac8921 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -566,6 +566,26 @@ class GameData(object):
             'files': files,
         }
 
+    def size(self, package):
+        size_min = 0
+        size_max = 0
+        for filename in package._install:
+           file = self.files[filename]
+           if file.alternatives:
+               # 'or 0' is a workaround for the files without known size
+               size_min += min(set(self.files[a].size or 0 for a in file.alternatives))
+               size_max += max(set(self.files[a].size or 0 for a in file.alternatives))
+           else:
+               size_min += file.size
+               size_max += file.size
+        for filename in package._optional:
+           file = self.files[filename]
+           if file.alternatives:
+               size_max += max(set(self.files[a].size for a in file.alternatives))
+           else:
+               size_max += file.size
+        return (size_min, size_max)
+
     def _populate_package(self, package, d):
         for k in ('expansion_for', 'expansion_for_ext', 'longname', 'symlinks', 'install_to',
                 'install_to_docdir', 'install_contents_of', 'debian', 'description',

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