6 source_files
= glob
.glob (os
.path
.join ('input', 'texidocs', '*.texidoc'))
7 dest_path
= os
.path
.join ('Documentation', '%s', 'texidocs', '%s')
9 s
= 'Translation of GIT [Cc]ommittish'
10 texidoc_chunk_re
= re
.compile (r
'^(?:%+\s*' + s
+ \
11 r
'.+)?\s*(?:texidoc|doctitle)([a-zA-Z]{2,4})\s+=(?:.|\n)*?(?=%+\s*' + \
12 s
+ r
'|$(?!.|\n))', re
.M
)
14 for file_name
in source_files
:
15 base_name
= os
.path
.basename (file_name
)
16 contents
= open (file_name
).read ()
17 for match
in texidoc_chunk_re
.finditer (contents
):
18 language_code
= match
.group (1)
20 open (dest_path
% (language_code
, base_name
), 'w').write (match
.group (0))