X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=buildscripts%2Fcheck_translation.py;h=090b1fbe8a73811af2dd98c0d2c74f2078ca6aa3;hb=0387f04497978e37b335a8b99eec905499d6ad0f;hp=6952b2c34fcf53bdb661c3f30ddec43db19b95fc;hpb=41e45dd730c075e78065dfa78e5e54be664d905e;p=lilypond.git diff --git a/buildscripts/check_translation.py b/buildscripts/check_translation.py index 6952b2c34f..090b1fbe8a 100644 --- a/buildscripts/check_translation.py +++ b/buildscripts/check_translation.py @@ -1,11 +1,15 @@ -#!@PYTHON@ +#!/usr/bin/env python import __main__ import optparse import os import sys +import langdefs +import buildlib + verbose = 0 +use_colors = False lang = 'C' C = lang @@ -32,10 +36,14 @@ def do_file (file_name, lang_codes, buildlib): original = dir_lang (file_name, '', lang_dir_index) translated_contents = open (file_name).read () - (diff_string, error) = buildlib.check_translated_doc (original, translated_contents, color=not update_mode) + (diff_string, error) \ + = buildlib.check_translated_doc (original, + file_name, + translated_contents, + color=use_colors and not update_mode) if error: - sys.stderr.write ('warning: %s: %s' % (file_name, error)) + sys.stderr.write ('warning: %s: %s' % (file_name, error)) if update_mode: if error or len (diff_string) >= os.path.getsize (original): @@ -53,13 +61,13 @@ def do_file (file_name, lang_codes, buildlib): def usage (): sys.stdout.write (r''' Usage: -check-translation [--language=LANG] [--verbose] [--update] BUILDSCRIPT-DIR FILE... +check-translation [--language=LANG] [--verbose] [--update] FILE... This script is licensed under the GNU GPL. ''') def do_options (): - global lang, verbose, update_mode + global lang, verbose, update_mode, use_colors p = optparse.OptionParser (usage="check-translation [--language=LANG] [--verbose] FILE...", description="This script is licensed under the GNU GPL.") @@ -67,11 +75,16 @@ def do_options (): action='store', default='site', dest="language") + p.add_option ("--no-color", + action='store_false', + default=True, + dest="color", + help="do not print ANSI-cooured output") p.add_option ("--verbose", action='store_true', default=False, dest="verbose", - help="the GIT directory to merge.") + help="print details, including executed shell commands") p.add_option ('-u', "--update", action='store_true', default=False, @@ -81,26 +94,24 @@ def do_options (): (options, files) = p.parse_args () verbose = options.verbose lang = options.language + use_colors = options.color update_mode = options.update_mode - return (files[0], files[1:]) + return files def main (): global update_mode, text_editor - import_path, files = do_options () - if 'EDITOR' in os.environ.keys (): + files = do_options () + if 'EDITOR' in os.environ: text_editor = os.environ['EDITOR'] else: update_mode = False - sys.path.append (import_path) - import langdefs - import buildlib buildlib.verbose = verbose for i in files: - do_file (i, langdefs.LANGDICT.keys(), buildlib) + do_file (i, langdefs.LANGDICT.keys (), buildlib) if __name__ == '__main__': main ()