update and add more comments

svn: r20782
This commit is contained in:
Jérôme Rapinat 2012-12-13 20:43:32 +00:00
parent dbd8edaae6
commit c2443c74d4
2 changed files with 27 additions and 16 deletions

View File

@ -548,6 +548,7 @@ def analyze_msgs( args, fname, msgs, nr_templates = None, nth = 0 ):
for c in checks: for c in checks:
c.summary() c.summary()
c.diag()
po_coverage = (1.0 - (float(nr_untranslated) / float(nr_msgs))) * 100 po_coverage = (1.0 - (float(nr_untranslated) / float(nr_msgs))) * 100
print "%-20s%5.2f%%" % ( "PO Coverage:", po_coverage ) print "%-20s%5.2f%%" % ( "PO Coverage:", po_coverage )
@ -564,14 +565,13 @@ def analyze_msgs( args, fname, msgs, nr_templates = None, nth = 0 ):
else: else:
print text + ' (previous gramps.pot)' print text + ' (previous gramps.pot)'
def main(): def main():
parser = ArgumentParser( description='This program validates a PO file for GRAMPS.') parser = ArgumentParser( description='This program validates a PO file for GRAMPS.')
parser.add_argument("-s", dest="summary", parser.add_argument("-s", dest="summary",
choices=[file for file in os.listdir('.') if file.endswith('.po')], choices=[file for file in os.listdir('.') if file.endswith('.po')],
default=False, help="only give the summary") default=False, help="the summary of check, and if need, it gives details")
args = parser.parse_args() args = parser.parse_args()

View File

@ -52,6 +52,7 @@ import os
import sys import sys
from argparse import ArgumentParser from argparse import ArgumentParser
# Windows OS
if sys.platform == 'win32': if sys.platform == 'win32':
# GetText Win 32 obtained from http://gnuwin32.sourceforge.net/packages/gettext.htm # GetText Win 32 obtained from http://gnuwin32.sourceforge.net/packages/gettext.htm
@ -61,6 +62,9 @@ if sys.platform == 'win32':
msgattribCmd = os.path.join('C:', 'Program Files(x86)', 'gettext', 'bin', 'msgattrib.exe') msgattribCmd = os.path.join('C:', 'Program Files(x86)', 'gettext', 'bin', 'msgattrib.exe')
xgettextCmd = os.path.join('C:', 'Program Files(x86)', 'gettext', 'bin', 'xgettext.exe') xgettextCmd = os.path.join('C:', 'Program Files(x86)', 'gettext', 'bin', 'xgettext.exe')
pythonCmd = os.path.join(sys.prefix, 'bin', 'python.exe') pythonCmd = os.path.join(sys.prefix, 'bin', 'python.exe')
# Others OS
elif sys.platform == 'linux2' or os.name == 'darwin': elif sys.platform == 'linux2' or os.name == 'darwin':
msgmergeCmd = 'msgmerge' msgmergeCmd = 'msgmerge'
msgfmtCmd = 'msgfmt' msgfmtCmd = 'msgfmt'
@ -71,8 +75,13 @@ else:
print ("ERROR: unknown system, don't know msgmerge, ... commands") print ("ERROR: unknown system, don't know msgmerge, ... commands")
sys.exit(0) sys.exit(0)
# List of available languages, useful for grouped actions
# need files with po extension
LANG = [file for file in os.listdir('.') if file.endswith('.po')] LANG = [file for file in os.listdir('.') if file.endswith('.po')]
# add a special 'all' argument (for 'check' and 'merge' arguments)
LANG.append("all") LANG.append("all")
# visual polish on the languages list
LANG.sort() LANG.sort()
def tests(): def tests():
@ -116,7 +125,7 @@ def tests():
except: except:
print ('Please, install python') print ('Please, install python')
# See also 'get_string' from Gramps 2.0 (sample with SAX)
def TipsParse(filename, mark): def TipsParse(filename, mark):
""" """
Experimental alternative to 'intltool-extract' for 'tips.xml'. Experimental alternative to 'intltool-extract' for 'tips.xml'.
@ -205,6 +214,7 @@ def HolidaysParse(filename, mark):
if key.attrib.get(mark): if key.attrib.get(mark):
line = key.attrib line = key.attrib
string = line.items string = line.items
# mapping via the line dict (_name is the key)
name = 'char *s = N_("%(_name)s");\n' % line name = 'char *s = N_("%(_name)s");\n' % line
holidays.write(name) holidays.write(name)
holidays.close() holidays.close()
@ -394,7 +404,6 @@ def main():
args = parser.parse_args() args = parser.parse_args()
namespace, extra = parser.parse_known_args() namespace, extra = parser.parse_known_args()
#print(args, '\n\t\t###\n', vars(args), '\n\t\t###\n', sys.argv[2:])
if args.test: if args.test:
tests() tests()
@ -415,11 +424,13 @@ def main():
clean() clean()
if args.merge: if args.merge:
#retrieve() windows os?
if sys.argv[2:] == ['all']: if sys.argv[2:] == ['all']:
sys.argv[2:] = LANG sys.argv[2:] = LANG
merge(sys.argv[2:]) merge(sys.argv[2:])
if args.check: if args.check:
#retrieve() windows os?
if sys.argv[2:] == ['all']: if sys.argv[2:] == ['all']:
sys.argv[2:] = LANG sys.argv[2:] = LANG
check(sys.argv[2:]) check(sys.argv[2:])