split.py 995 B

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