9 def read_pipe (command
):
10 child
= subprocess
.Popen (command
,
11 stdout
= subprocess
.PIPE
,
12 stderr
= subprocess
.PIPE
,
14 (output
, error
) = child
.communicate ()
15 code
= str (child
.wait ())
16 if not child
.stdout
or child
.stdout
.close ():
17 print "pipe failed: %(command)s" % locals ()
19 error
= code
+ ' ' + error
20 return (output
, error
)
22 revision_re
= re
.compile ('GIT [Cc]ommittish:\s+([a-f0-9]+)')
23 vc_diff_cmd
= 'git diff %(color_flag)s %(revision)s HEAD -- %(original)s | cat'
25 def check_translated_doc (original
, translated_file
, translated_contents
, color
=False):
26 m
= revision_re
.search (translated_contents
)
28 sys
.stderr
.write ('error: ' + translated_file
+ \
29 ": no 'GIT committish: <hash>' found.\nPlease check " + \
30 'the whole file against the original in English, then ' + \
31 'fill in HEAD committish in the header.\n')
33 revision
= m
.group (1)
36 color_flag
= '--color'
38 color_flag
= '--no-color'
39 c
= vc_diff_cmd
% vars ()
41 sys
.stderr
.write ('running: ' + c
)