[game-data-packager] 39/51: make_template: Add strip_paths option

Simon McVittie smcv at debian.org
Fri Dec 29 01:23:37 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 e57c271b847d248f4da39fd734ebc4b4402eeb99
Author: Simon McVittie <smcv at debian.org>
Date:   Thu Dec 28 19:59:27 2017 +0000

    make_template: Add strip_paths option
    
    Typical use:
    game-data-packager make-template --strip-path='Data Files' \
    setup_tes_morrowind_goty_2.0.0.7.exe
---
 game_data_packager/make_template.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/game_data_packager/make_template.py b/game_data_packager/make_template.py
index 5f507c6..f805afa 100644
--- a/game_data_packager/make_template.py
+++ b/game_data_packager/make_template.py
@@ -139,12 +139,13 @@ def is_runtime(path):
     return False
 
 class Template:
-    def __init__(self, game):
+    def __init__(self, game, strip_paths=()):
         self.game = game
         self.plugin = None
         self.gog = dict()
 
         self.data = dict()
+        self.strip_paths = strip_paths
 
         self.has_dosbox = False
 
@@ -273,6 +274,10 @@ class Template:
             # We are creating a new WantedFile
             assert existing is None
 
+            for prefix in self.strip_paths:
+                if out_name.startswith(prefix + '/'):
+                    out_name = out_name[len(prefix) + 1:]
+
             if out_name not in self.game.files:
                 pass
             elif lang and out_name + '?' + lang not in self.game.files:
@@ -826,6 +831,9 @@ def main():
                 'based on an existing .deb file or installed directory',
             prog='game-data-packager guess-contents')
     parser.add_argument('args', nargs='+', metavar='DEB|DIRECTORY|FILE')
+    parser.add_argument(
+        '--strip-path', action='append', dest='strip_paths', default=[],
+        help='Strip a prefix from all filenames (may be repeated)')
     parser.add_argument('-l', '--lower', action='store_true', dest='lower',
             help='make all files lowercase')
     parser.add_argument('-e', '--execute', action='store_true', dest='execute',
@@ -848,7 +856,7 @@ def main():
             copyright='© 1970 FIXME',
             packages={},
         ))
-    template = Template(game)
+    template = Template(game, strip_paths=args.strip_paths)
 
     # "./run make-template setup_<game>.exe gog_<game>.deb"
     # will merge files lists

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