-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat.py
More file actions
executable file
·39 lines (35 loc) · 816 Bytes
/
format.py
File metadata and controls
executable file
·39 lines (35 loc) · 816 Bytes
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
#! /usr/bin/python
import sys
def object(obj, level = 0):
print "{"
level += 1
if type(obj) == dict:
iter = obj.iteritems()
else:
iter = enumerate(obj)
for key, val in iter:
if type(key) == str:
key = "".join(key.title().split(" "))
key = key[0].lower() + key[1:]
print "\t" * level + key + ' =',
else:
print "\t" * level + '[' + str(key) + '] =',
if type(val) == dict:
object(val, level)
elif type(val) == int:
if key == "hex":#Special Case
print hex(val) + ";"
else:
print str(val) + ";"
elif type(val) == float:
print str(val) + ";"
elif type(val) == bool:
print str(val).lower()+";"
elif type(val) == str:
print '"' + str(val) + '";'
elif type(val) == list:
object(val, level)
else:
print "nil;"
level -= 1
print "\t" * level + "};"