forked from AeonLucid/POGOProtos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
assist.py
40 lines (27 loc) · 1.22 KB
/
assist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
import os
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-m", "--message", help="Message to prodecure files for.")
args = parser.parse_args()
def underscore_to_camelcase(value):
def camelcase():
while True:
yield str.capitalize
c = camelcase()
return "".join(c.next()(x) if x else '_' for x in value.split("_"))
if not args.message:
print "Specify a message."
def initialize_file(package, message, path):
with open(path, 'a') as opened_file:
opened_file.write('syntax = "proto3";\n')
opened_file.write('package %s;\n\n' % package)
opened_file.write('message %s {\n' % message)
opened_file.write('\t// Initialized by assist.py\n')
opened_file.write('}\n')
print "Created %s" % path
message = underscore_to_camelcase(args.message)
request_path = os.path.join("POGOProtos\Networking\Requests\Messages", "%sMessage.proto" % message)
response_path = os.path.join("POGOProtos\Networking\Responses", "%sResponse.proto" % message)
initialize_file("POGOProtos.Networking.Requests.Messages", "%sMessage" % message, request_path)
initialize_file("POGOProtos.Networking.Responses", "%sResponse" % message, response_path)