[game-data-packager] 01/01: missing_langs: move logic to core & data to yaml files, ...
Alexandre Detiste
detiste-guest at moszumanska.debian.org
Sun Jun 28 08:30:10 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 c136a5f1e5282860e768af918f18b8131600d8ea
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date: Sun Jun 28 10:28:46 2015 +0200
missing_langs: move logic to core & data to yaml files,...
use it in the help text, remove hardcoded values
from babel.py
---
data/nomouth.yaml | 1 +
data/rtcw.yaml | 1 +
doc/tags.txt | 1 +
game_data_packager/__init__.py | 24 +++++++++++++++++++-----
tools/babel.py | 17 ++++++-----------
5 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/data/nomouth.yaml b/data/nomouth.yaml
index e4c877e..1ff08bd 100644
--- a/data/nomouth.yaml
+++ b/data/nomouth.yaml
@@ -7,6 +7,7 @@ gameid: ihnm
steam:
id: 245390
path: common/IHNMAIMS
+missing_langs: [ru]
help_text: |
In the French & German versions,
diff --git a/data/rtcw.yaml b/data/rtcw.yaml
index d46aea5..f30910f 100644
--- a/data/rtcw.yaml
+++ b/data/rtcw.yaml
@@ -4,6 +4,7 @@ copyright: © 2001 id Software, Inc. and Activision Publishing, Inc.
engine: rtcw
genre: First-person shooter
try_repack_from: [/usr/local/games/wolfenstein]
+missing_langs: [de,es,it]
# Like Jedi Academy, there isn't much point in compressing this .deb.
compress_deb: false
diff --git a/doc/tags.txt b/doc/tags.txt
index a48cc1d..28bf044 100644
--- a/doc/tags.txt
+++ b/doc/tags.txt
@@ -11,6 +11,7 @@ steam:
id: int
path: string
try_repack_from: list
+missing_langs: list
help_text: string
disabled_help_text: string
diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index 3d3ad92..88f0d06 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -508,6 +508,10 @@ class GameData(object):
# The game engine used to run the game (package name)
self.engine = None
+ # Game translations known to exists, but missing in 'packages:'
+ # list of ISO-639 codes
+ self.missing_langs = []
+
# The game genre
# http://en.wikipedia.org/wiki/List_of_video_game_genres
self.genre = None
@@ -546,10 +550,12 @@ class GameData(object):
self.argument_parser = None
for k in ('longname', 'copyright', 'compress_deb', 'help_text',
- 'steam', 'gog', 'origin', 'engine', 'genre'):
+ 'steam', 'gog', 'origin', 'engine', 'genre', 'missing_langs'):
if k in self.data:
setattr(self, k, self.data[k])
+ assert type(self.missing_langs) is list
+
if 'aliases' in self.data:
self.aliases = set(self.data['aliases'])
@@ -729,6 +735,9 @@ class GameData(object):
assert (not package.better_version or
package.better_version in self.packages), package.better_version
+ # check for stale missing_langs
+ assert not set(package.langs).intersection(self.missing_langs)
+
for filename, wanted in self.files.items():
if wanted.unpack:
assert 'format' in wanted.unpack, filename
@@ -763,10 +772,10 @@ class GameData(object):
prepend = '\npackages possible for this game:\n'
help = []
for package in self.packages.values():
- type = { 'demo' : 1,
- 'full' : 2,
- 'expansion' : 3}.get(package.type)
- help.append({ 'type' : type,
+ game_type = { 'demo' : 1,
+ 'full' : 2,
+ 'expansion' : 3}.get(package.type)
+ help.append({ 'type' : game_type,
'year' : package.copyright or self.copyright,
'name' : package.name,
'longname': package.longname or self.longname})
@@ -774,6 +783,11 @@ class GameData(object):
prepend += " %-40s %s\n" % (h['name'],h['longname'])
self.help_text = prepend + '\n' + self.help_text
+ if self.missing_langs:
+ self.help_text += ('\nThe following languages are not '
+ 'yet supported: %s\n' %
+ ','.join(self.missing_langs))
+
# advertise where to buy games
# if it's not already in the help_text
gog_url = self.gog.get('url')
diff --git a/tools/babel.py b/tools/babel.py
index 559ff1d..01143b3 100755
--- a/tools/babel.py
+++ b/tools/babel.py
@@ -43,16 +43,12 @@ for name, game in load_games().items():
stats['shortname'] = name
stats['longname'] = ascii_safe(game.longname, force=True)
stats['total'] = len(game.packages)
+ stats['missing_langs'] = game.missing_langs
+ for l in game.missing_langs:
+ if l not in langs:
+ langs[l] = 0
games.append(stats)
-if 'ru' not in langs:
- langs['ru'] = 0
-
-missing = {
- 'nomouth': ['ru'],
- 'rtcw': ['de','es','it'],
-}
-
games = sorted(games, key=lambda k: (k['genre'], k['shortname'], k['longname']))
langs_order = [k for k, v in sorted(langs.items(), key=lambda kv: (-kv[1], kv[0]))]
@@ -84,10 +80,9 @@ for game in games:
html.write(' <td>%s</td>\n' % game['longname'])
for lang in langs_order:
count = game.get(lang,None)
- if lang in ('total', 'en') or count in ('*', 'm'):
+ if lang in ('total', 'en') or count == '*':
html.write(' <td bgcolor="lightgreen">%s</td>\n' % count)
- elif lang in missing.get(game['shortname'],[]):
- assert not count
+ elif lang in game['missing_langs']:
html.write(' <td bgcolor="orange">!</td>\n')
elif count:
html.write(' <td bgcolor="green">%s</td>\n' % count)
--
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