From 0f6250f7a23c8226906145ee92fa477712b56979 Mon Sep 17 00:00:00 2001 From: John Mandereau Date: Sun, 9 Aug 2009 11:43:12 +0200 Subject: [PATCH] Docs: handle file renames in translation checking All renames in documentation in English must be registered manually in python/auxiliar/buildlib.py. --- python/auxiliar/buildlib.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/python/auxiliar/buildlib.py b/python/auxiliar/buildlib.py index 04a72c7924..5ec022e16a 100644 --- a/python/auxiliar/buildlib.py +++ b/python/auxiliar/buildlib.py @@ -19,8 +19,41 @@ def read_pipe (command): error = code + ' ' + error return (output, error) +### Renamed files map to ensure continuity of file history +## Map of new_name: old_name +renames_map = { + 'application.tely': 'user/lilypond-program.tely', + 'notation.tely': 'user/lilypond.tely', + 'learning.tely': 'user/lilypond-learning.tely', + 'changes.tely': 'topdocs/NEWS.tely', +} + +manuals_subdirectories_re = \ + re.compile ('(application|essay|learning|notation)/') + +def add_old_name (file_path): + for new_path in renames_map: + if file_path.endswith (new_path): + old_file_path = file_path.replace (new_path, + renames_map[new_path]) + break + else: + if file_path.endswith ('macros.itexi'): + old_file_path = file_path.replace ('macros.itexi', + 'user/macros.itexi') + elif file_path.endswith ('.itely'): + old_file_path = manuals_subdirectories_re.sub ('user/', + file_path) + elif 'snippets/' in file_path: + old_file_path = file_path.replace ('snippets/', + '../input/lsr/') + else: + return file_path + return file_path + ' ' + old_file_path + revision_re = re.compile ('GIT [Cc]ommittish:\s+([a-f0-9]+)') -vc_diff_cmd = 'git diff --patience -M %(color_flag)s %(revision)s %(upper_revision)s -- %(original)s | cat' +vc_diff_cmd = 'git diff -M %(color_flag)s %(revision)s \ +%(upper_revision)s -- %(original_with_old_name)s | cat' no_committish_fatal_error = """error: %s: no 'GIT committish: ' found. Please check the whole file against the original in English, then fill in HEAD committish in the header. @@ -38,6 +71,7 @@ def check_translated_doc (original, translated_file, translated_contents, color_flag = '--color --color-words' else: color_flag = '--no-color' + original_with_old_name = add_old_name (original) c = vc_diff_cmd % vars () if verbose: sys.stderr.write ('running: ' + c) -- 2.39.5