From 2ca04af3199ca5feb312050e306f9f7d31ccaf84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Rapinat?= Date: Sat, 1 Dec 2012 10:10:44 +0000 Subject: [PATCH] start to use choice lists (argsparser) svn: r20716 --- po/update_po.py | 53 ++++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/po/update_po.py b/po/update_po.py index 1e4eaad6f..fce84258b 100644 --- a/po/update_po.py +++ b/po/update_po.py @@ -367,12 +367,12 @@ def main(): # need at least one argument (sv.po, de.po, etc ...) # lang.po files maintenance - update.add_argument("-m", "--merge", - type=int, dest="merge", default=[file for file in os.listdir('.') if file.endswith('.po')], + update.add_argument("-m", "--merge", dest="merge", + choices=[file for file in os.listdir('.') if file.endswith('.po')], help="merge lang.po files with last catalog") - update.add_argument("-k", "--check", - type=int, dest="check", default=[file for file in os.listdir('.') if file.endswith('.po')], + update.add_argument("-k", "--check", dest="check", + choices=[file for file in os.listdir('.') if file.endswith('.po')], help="check lang.po files") # testing stage @@ -410,10 +410,10 @@ def main(): if args.clean: clean() - if args.merge and sys.argv[2:] in namespace.merge: + if args.merge: merge(sys.argv[2:]) - if args.check and sys.argv[2:] in namespace.check: + if args.check: check(sys.argv[2:]) if args.untranslated and sys.argv[2:]: @@ -595,36 +595,31 @@ def clean(): os.unlink('tmpfiles') print ("Remove 'tmpfiles'") -def merge(args): +def merge(arg): """ Merge messages with 'gramps.pot' """ - for arg in args: - if arg[-3:] == '.po': - print ('Merge %(lang)s with current template' % {'lang': arg}) - os.system('''%(msgmerge)s --no-wrap %(lang)s gramps.pot -o updated_%(lang)s''' \ - % {'msgmerge': msgmergeCmd, 'lang': arg}) - print ("Updated file: 'updated_%(lang)s'." % {'lang': arg}) - else: - print ("Please, try to set an argument with .po extension like " - "'%(arg)s.po'." % {'arg': arg}) + + arg = arg[0] + + print ('Merge %(lang)s with current template' % {'lang': arg}) + os.system('''%(msgmerge)s --no-wrap %(lang)s gramps.pot -o updated_%(lang)s''' \ + % {'msgmerge': msgmergeCmd, 'lang': arg}) + print ("Updated file: 'updated_%(lang)s'." % {'lang': arg}) -def check(args): +def check(arg): """ Check the translation file """ - print (args) - for arg in args: - if arg[-3:] == '.po': - print ("Checked file: '%(lang.po)s'. See '%(txt)s.txt'." \ - % {'lang.po': arg, 'txt': arg[:-3]}) - os.system('''%(python)s ./check_po --skip-fuzzy ./%(lang.po)s > %(lang)s.txt''' \ - % {'python': pythonCmd, 'lang.po': arg, 'lang': arg[:-3]}) - os.system('''%(msgfmt)s -c -v %(lang.po)s''' - % {'msgfmt': msgfmtCmd, 'lang.po': arg}) - else: - print ("Please, try to set an argument with .po extension like " - "'%(arg)s.po'." % {'arg': arg}) + + arg = arg[0] + + print ("Checked file: '%(lang.po)s'. See '%(txt)s.txt'." \ + % {'lang.po': arg, 'txt': arg[:-3]}) + os.system('''%(python)s ./check_po --skip-fuzzy ./%(lang.po)s > %(lang)s.txt''' \ + % {'python': pythonCmd, 'lang.po': arg, 'lang': arg[:-3]}) + os.system('''%(msgfmt)s -c -v %(lang.po)s''' + % {'msgfmt': msgfmtCmd, 'lang.po': arg}) def untranslated(args): """