GenOp.py 734 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #coding=gbk
  2. #!/usr/bin/env python
  3. from __future__ import with_statement
  4. from xml.dom.minidom import Document
  5. import os
  6. import zlib
  7. SEARCH_DIR = "./"
  8. HEAD_STR = "require \""
  9. TAIL_STR = "\"\n"
  10. SRC_TXT = "./lua/ProtoOp_pb.lua"
  11. def main():
  12. f_out = open(SRC_TXT, 'w')
  13. f_in = open("ProtoOp.proto")
  14. line = f_in.readline()
  15. while line:
  16. opPos = line.find("OP_")
  17. if opPos == -1:
  18. line = f_in.readline()
  19. continue
  20. endPos = line.find(";")
  21. code = line[opPos:endPos]
  22. f_out.write(code + "\n")
  23. #print code
  24. line = f_in.readline()
  25. f_out.close()
  26. f_in.close()
  27. if __name__ == "__main__":
  28. main()