[game-data-packager] 01/01: degrade non-ascii characters when running with LANG=C
Alexandre Detiste
detiste-guest at moszumanska.debian.org
Wed May 6 12:29:53 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 20de8cba8f83342809a5ef94802cf7de8550ce69
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date: Wed May 6 14:23:13 2015 +0200
degrade non-ascii characters when running with LANG=C
the characters needed for "Dračí Historie" have
been added too
on a matrix printer, you can overwrite a character,
so much fun:
€ = 'C' + backspace + '='
http://users.teledisnet.be/ade15809/epson.c
---
debian/changelog | 2 ++
game_data_packager/__init__.py | 7 +++++--
game_data_packager/util.py | 7 +++++++
tools/check_syntax.py | 2 ++
4 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 25e64ca..e9cb70d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,8 @@ game-data-packager (42) UNRELEASED; urgency=medium
[ Alexandre Detiste ]
* add support for Space Quest 1,2,3,4 & 5
+ * replace non-ascii characters to closest ascii character
+ when displaying help screen with LANG=C (Closes: #784330)
-- Simon McVittie <smcv at debian.org> Sun, 03 May 2015 14:34:00 +0200
diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index 1584f13..e0ac6a9 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -52,6 +52,7 @@ from .util import (MEBIBYTE,
human_size,
PACKAGE_CACHE,
lang_score,
+ ascii_safe,
which)
from .version import GAME_PACKAGE_VERSION
@@ -2131,9 +2132,11 @@ class GameData(object):
def add_parser(self, parsers, base_parser, **kwargs):
aliases = self.aliases
+ longname = ascii_safe(self.longname)
+
parser = parsers.add_parser(self.shortname,
- help=self.longname, aliases=aliases,
- description='Package data files for %s.' % self.longname,
+ help=longname, aliases=aliases,
+ description='Package data files for %s.' % longname,
epilog=self.help_text,
formatter_class=argparse.RawDescriptionHelpFormatter,
parents=(base_parser,),
diff --git a/game_data_packager/util.py b/game_data_packager/util.py
index 8f30fe8..6ecf30f 100644
--- a/game_data_packager/util.py
+++ b/game_data_packager/util.py
@@ -20,6 +20,7 @@ import os
import shutil
import stat
import subprocess
+import sys
KIBIBYTE = 1024
MEBIBYTE = KIBIBYTE * KIBIBYTE
@@ -148,3 +149,9 @@ def lang_score(lang):
return 0
return len(langs) - langs.index(lang)
+
+def ascii_safe(string, force=False):
+ if sys.stdout.encoding != 'UTF-8' or force:
+ string = string.translate(str.maketrans('àäçčéèêëîïíł',
+ 'aacceeeeiiil'))
+ return string
diff --git a/tools/check_syntax.py b/tools/check_syntax.py
index 3ee8747..bf4880b 100755
--- a/tools/check_syntax.py
+++ b/tools/check_syntax.py
@@ -19,9 +19,11 @@ import os
import yaml
from game_data_packager import load_games
+from game_data_packager.util import ascii_safe
if __name__ == '__main__':
for name, game in load_games().items():
+ ascii_safe(game.longname, force=True).encode('ascii')
if 'DEBUG' in os.environ:
print('# %s -----------------------------------------' % name)
print(yaml.safe_dump(game.to_yaml()))
--
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