]> git.donarmstrong.com Git - lilypond.git/blob - buildscripts/buildlib.py
Add support for max-systems-per-page.
[lilypond.git] / buildscripts / buildlib.py
1 #!@PYTHON@
2
3 import subprocess
4 import re
5
6 verbose = False
7
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)
20
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'
23
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)
33
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)