[game-data-packager] 01/01: let GDP have a look inside unknown zip file

Alexandre Detiste detiste-guest at moszumanska.debian.org
Thu Apr 2 08:32:39 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 6bfbcfcca72f2751e538a8ad57cec0ba362aab6a
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Thu Apr 2 10:30:41 2015 +0200

    let GDP have a look inside unknown zip file
    
    this act as a catch all for .zip wrappers
    and other unknown .zip archives
    "GamersHell adds extra cruft and wraps it in a zip file"
    
    this doesn't recurse: unknown .zip in unknown .zip
    doesn't work
---
 game_data_packager/__init__.py | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index 3f893ae..b13ca55 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -1004,6 +1004,11 @@ class GameData(object):
 
         if really_should_match_something:
             logger.warning('file "%s" does not match any known file', path)
+            # ... still G-D-P should try to process any random .zip
+            # file thrown at it, like the .zip provided by GamersHell
+            if os.path.splitext(path)[1].lower() == '.zip':
+                with zipfile.ZipFile(path, 'r') as zf:
+                    self.consider_zip(path, zf)
 
     def _log_not_any_of(self, path, size, hashes, why, candidates):
         message = ('found %s but it is not one of the expected ' +
@@ -1091,14 +1096,20 @@ class GameData(object):
         logger.debug('%s: %s', package.name, result)
         return result
 
-    def consider_zip(self, name, zf, provider):
-        should_provide = set(provider.provides)
+    def consider_zip(self, name, zf, provider=None):
+        if provider is None:
+            filenames = self.files
+            should_provide = set()
+        else:
+            filenames = provider.provides
+            should_provide = set(filenames)
+
 
         for entry in zf.infolist():
             if not entry.file_size:
                 continue
 
-            for filename in provider.provides:
+            for filename in filenames:
                 wanted = self.files.get(filename)
 
                 if wanted is None:

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