[game-data-packager] 01/01: print FILE_ID.DIZ memorabilia in --verbose mode

Alexandre Detiste detiste-guest at moszumanska.debian.org
Wed May 20 14:14:31 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 1939753f925855647e16c3afcbc6299672aeca9b
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Wed May 20 16:09:42 2015 +0200

    print FILE_ID.DIZ memorabilia in --verbose mode
    
    It's funnier to read this that to simply
    wait that the .deb got xz'ipped.
    
    Default to cp437 instead of utf-8
    (cp850 was for school assignements)
---
 game_data_packager/__init__.py | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index f7c5ea2..85e1c24 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -1484,12 +1484,24 @@ class GameData(object):
 
                 if VERBOSE and fmt in ('zip', 'unzip'):
                     with zipfile.ZipFile(found_name, 'r') as zf:
+                        encoding = provider.unpack.get('encoding', 'cp437')
                         if zf.comment:
-                            encoding = provider.unpack.get('encoding', 'utf-8')
+                            comment = zf.comment.decode(encoding, 'replace')
                             try:
-                                print(zf.comment.decode(encoding, 'replace'))
+                                print(comment)
                             except UnicodeError:
-                                logger.warning("can't decode zip comment")
+                                print(comment.encode('ascii', 'replace').decode('ascii'))
+                        if 'FILE_ID.DIZ' in zf.namelist():
+                            try:
+                                entryfile = zf.open('FILE_ID.DIZ')
+                                id_diz = entryfile.read().decode(encoding, 'replace')
+                            except NotImplementedError:
+                                id_diz = subprocess.check_output(['unzip', '-c','-q',
+                                  found_name, 'FILE_ID.DIZ']).decode(encoding, 'replace')
+                            try:
+                                print(id_diz)
+                            except UnicodeError:
+                                print(id_diz.encode('ascii', 'replace').decode('ascii'))
 
                 if fmt == 'dos2unix':
                     tmp = os.path.join(self.get_workdir(),

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