staff-symbol-referencer.cc: Junk redundant functions.
[lilypond.git] / buildscripts / buildlib.py
blob11dbf96a164dc9a3faa7c54fbb36bd5616bc929d
1 #!@PYTHON@
3 import subprocess
4 import re
6 verbose = False
8 def read_pipe (command):
9 child = subprocess.Popen (command,
10 stdout = subprocess.PIPE,
11 stderr = subprocess.PIPE,
12 shell = True)
13 (output, error) = child.communicate ()
14 code = str (child.wait ())
15 if not child.stdout or child.stdout.close ():
16 print "pipe failed: %(command)s" % locals ()
17 if code != '0':
18 error = code + ' ' + error
19 return (output, error)
21 revision_re = re.compile ('GIT [Cc]ommittish: ([a-f0-9]+)')
22 vc_diff_cmd = 'git diff %(color_flag)s %(revision)s HEAD -- %(original)s | cat'
24 def check_translated_doc (original, translated_contents, color=False):
25 m = revision_re.search (translated_contents)
26 if not m:
27 sys.stderr.write ('error: ' + translated + \
28 ": no 'GIT committish: <hash>' found.\nPlease check " + \
29 'the whole file against the original in English, then ' + \
30 'fill in HEAD committish in the header.\n')
31 sys.exit (1)
32 revision = m.group (1)
34 if color:
35 color_flag = '--color'
36 else:
37 color_flag = '--no-color'
38 c = vc_diff_cmd % vars ()
39 if verbose:
40 sys.stderr.write ('running: ' + c)
41 return read_pipe (c)