[game-data-packager] 06/11: make_template: guess that files in manual/, docs/, doc/ or help/ are docs

Simon McVittie smcv at debian.org
Tue Nov 3 23:14:48 UTC 2015


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 73a928d8da9a8b0b9c7d98d5ae220f24f8965376
Author: Simon McVittie <smcv at debian.org>
Date:   Tue Nov 3 08:48:20 2015 +0000

    make_template: guess that files in manual/, docs/, doc/ or help/ are docs
---
 game_data_packager/make_template.py | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/game_data_packager/make_template.py b/game_data_packager/make_template.py
index 700024a..dc1bfdf 100644
--- a/game_data_packager/make_template.py
+++ b/game_data_packager/make_template.py
@@ -81,15 +81,36 @@ def is_license(file):
             return True
     return False
 
+def iter_path_components(filename):
+    dirname, basename = os.path.split(filename)
+
+    if dirname == filename:
+        # the root
+        yield dirname
+    elif dirname:
+        for x in iter_path_components(dirname):
+            yield x
+
+    if basename:
+        yield basename
+
 def is_doc(file):
     file = file.split('?')[0]
+
+    for dirname in iter_path_components(file):
+        if dirname.lower() in  ('manual', 'docs', 'doc', 'help'):
+            return True
+
     name, ext = os.path.splitext(file.lower())
+
     if ext not in ('.doc', '.htm', '.html', '.pdf', '.txt', ''):
         return False
+
     for word in ('changes', 'hintbook', 'manual', 'quickstart',
                  'readme', 'refcard', 'reference', 'support'):
         if word in name:
             return True
+
     return False
 
 def is_dosbox(file):
@@ -268,7 +289,7 @@ class GameData(object):
                         out_name = os.path.basename(out_name)
                         self.license.add(out_name)
                         self.package['license'].append(out_name)
-                    elif is_doc(fn):
+                    elif is_doc(path):
                         self.doc.add(out_name)
                         self.package['doc'].append(out_name)
                     # most of the times these files are not needed

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