[game-data-packager] 01/01: make-template: avoid looping in look_for during the build

Alexandre Detiste detiste-guest at moszumanska.debian.org
Fri Oct 9 08:26:24 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 d452beb73982f90f976744ba10bf43db54d6bf9e
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Fri Oct 9 10:25:25 2015 +0200

    make-template: avoid looping in look_for during the build
---
 game_data_packager/make_template.py | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/game_data_packager/make_template.py b/game_data_packager/make_template.py
index 3339c98..beb886e 100644
--- a/game_data_packager/make_template.py
+++ b/game_data_packager/make_template.py
@@ -45,6 +45,9 @@ MD5_SAFE_ENOUGH = 5000
 
 def guess_lang(string):
     string = string.lower()
+    path = os.path.basename(string.rstrip('/'))
+    if path in ('de', 'en', 'fr', 'it', 'ja', 'pl', 'ru'):
+        return path
     for short, long in [('de', 'german'),
                         ('es', 'spanish'),
                         ('fr', 'french'),
@@ -228,13 +231,27 @@ class GameData(object):
                 elif os.path.isfile(path):
                     size = os.path.getsize(path)
                     hf = HashedFile.from_file(name, open(path, 'rb'))
-                    if out_name in self.size:
-                        if (size == self.size[out_name] and hf.md5 == self.md5[out_name]):
-                            pass
-                        elif lang:
-                            out_name += ('?' + lang)
-                        else:
-                            out_name += ('?' + hf.md5[1:6])
+                    # avoid that look_for: overlaps in cases where
+                    # that leeds to looping during package build.
+                    #
+                    # e.g.:
+                    #   md5 English = $A
+                    #   md5 German = $B
+                    #   md5 French = $B
+                    for existing in self.size.keys():
+                        if (    size == self.size[existing]
+                            and hf.md5 == self.md5[existing]
+                            and existing.startswith(out_name)):
+                            out_name = existing
+                            break
+                    else:
+                        if out_name in self.size:
+                            if (size == self.size[out_name] and hf.md5 == self.md5[out_name]):
+                                pass
+                            elif lang:
+                                out_name += ('?' + lang)
+                            else:
+                                out_name += ('?' + hf.md5[1:6])
 
                     if is_license(fn):
                         out_name = os.path.basename(out_name)

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