w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

cutout.py
Go to the documentation of this file.
1 import argparse
2 import subprocess
3 import os
4 import re
5 
6 if __name__== '__main__':
7  parser = argparse.ArgumentParser()
8  parser.add_argument('input')
9  parser.add_argument('output')
10 
11  args = parser.parse_known_args()
12  print (args[0].output)
13 
14  cpp = args[1]
15  ret = subprocess.run(cpp + [args[0].input], stdout=subprocess.PIPE)
16 
17  stdout = ret.stdout.decode('utf8')
18 
19  with open(args[0].output, 'w') as out:
20  write = True
21  for l in stdout.split('\n'):
22  l = l.strip('\r')
23  if l.startswith('CUT_OUT_BEGIN'):
24  write = False
25 
26  if write and l:
27  stripped = re.sub('^\s+', '', l)
28  stripped = re.sub('\s*,\s*', ',', stripped)
29  if not stripped.isspace() and stripped:
30  out.write('%s\n' % stripped)
31 
32  if l.startswith('CUT_OUT_END'):
33  write = True
#define open
Definition: win32lib.h:86