split.py 1006 B

1234567891011121314151617181920212223242526272829303132
  1. import os
  2. import sys
  3. border = '// ----------------------------------------------------------------------------'
  4. PythonVersion = sys.version_info[0];
  5. with open('httplib.h') as f:
  6. lines = f.readlines()
  7. inImplementation = False
  8. if PythonVersion < 3:
  9. os.makedirs('out')
  10. else:
  11. os.makedirs('out', exist_ok=True)
  12. with open('out/httplib.h', 'w') as fh:
  13. with open('out/httplib.cc', 'w') as fc:
  14. fc.write('#include "httplib.h"\n')
  15. fc.write('namespace httplib {\n')
  16. for line in lines:
  17. isBorderLine = border in line
  18. if isBorderLine:
  19. inImplementation = not inImplementation
  20. else:
  21. if inImplementation:
  22. fc.write(line.replace('inline ', ''))
  23. pass
  24. else:
  25. fh.write(line)
  26. pass
  27. fc.write('} // namespace httplib\n')