Start pictograms branch.
[lilypond/mpolesky.git] / scripts / auxiliar / split-texidocs.py
blob161448087bbf7daeb52858c7c8bca3ffdb81b55c
1 import os
2 import sys
3 import re
4 import glob
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)
19 print language_code
20 open (dest_path % (language_code, base_name), 'w').write (match.group (0))