8 def read_pipe (command
):
9 child
= subprocess
.Popen (command
,
10 stdout
= subprocess
.PIPE
,
11 stderr
= subprocess
.PIPE
,
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 ()
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
)
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')
32 revision
= m
.group (1)
35 color_flag
= '--color'
37 color_flag
= '--no-color'
38 c
= vc_diff_cmd
% vars ()
40 sys
.stderr
.write ('running: ' + c
)