14 def dir_lang (file, lang):
15 path_components = [lang] + file.split ('/')[1:]
16 return os.path.join (*path_components)
18 ## Translation of GIT Commit: <hash>
19 REVISION_RE = re.compile ('.*GIT [Cc]ommittish: ([a-f0-9]+)', re.DOTALL)
20 CVS_DIFF = 'git diff %(revision)s HEAD -- %(original)s | cat'
22 def check_file (original, translated):
23 s = open (translated).read ()
24 m = REVISION_RE.match (s)
26 raise translated + ': no GIT committish: <hash> found'
27 revision = m.group (1)
29 c = CVS_DIFF % vars ()
31 sys.stderr.write ('running: ' + c)
34 def do_file (file_name, langdefs):
36 sys.stderr.write ('%s...\n' % file_name)
37 file_lang = file_name.split ('/')[0]
38 if file_lang in langdefs.LANGDICT.keys():
39 check_lang = file_lang
43 raise 'cannot determine language for: ' + file_name
45 original = dir_lang (file_name, '')
46 translated = dir_lang (file_name, check_lang)
47 check_file (original, translated)
50 sys.stdout.write (r'''
52 check-translation [--language=LANG] [--verbose] BUILDSCRIPT-DIR FILE...
54 This script is licensed under the GNU GPL.
60 p = optparse.OptionParser (usage="check-translation [--language=LANG] [--verbose] FILE...",
61 description="This script is licensed under the GNU GPL.")
62 p.add_option ("--language",
66 p.add_option ("--verbose",
70 help="the GIT directory to merge.")
72 (options, files) = p.parse_args ()
73 verbose = options.verbose
74 lang = options.language
76 return (files[0], files[1:])
79 import_path, files = do_options ()
81 sys.path.append (import_path)
87 if __name__ == '__main__':