-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassemble.py
executable file
·68 lines (52 loc) · 1.51 KB
/
assemble.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
import base64
import json
def encode_the_whore(path):
with open(path, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
return str(encoded_string)[2:-1]
def write_to_json(dictionary):
filename = './pmg/georges.json' if gb == 'g' else './pmg/blang.json'
with open(filename, 'r') as f:
json_in = json.load(f)
if gb == 'g':
json_in["georges"].append(dictionary)
else:
json_in["blang"].append(dictionary)
with open(filename, 'w') as f:
json.dump(json_in, f, indent=2)
def g_json(name, path):
jsonn = {
"name": name,
"image": encode_the_whore(path),
"pieces": {
"head": [200, -3, 315, 65],
"face": [210, 73, 290, 90],
"neck": [217, 164, 300, 180],
"torso": [165, 165, 375, 325],
"legs": [0, 0, 0, 0],
"hands": [178, 352, 270, 430],
"feet": [0, 0, 0, 0]
}
}
write_to_json(jsonn)
def b_json(noun, adj, location, path):
jsonn = {
"noun": noun,
"adj": adj,
"location": location,
"image": encode_the_whore(path)
}
write_to_json(jsonn)
gb = input("g for george or b for blang: ")
filename = input("filename: ")
if gb == 'g':
name = input("name: ")
g_json(name, filename)
elif gb == 'b':
noun = input("noun: ")
adj = input("adj: ")
location = input("location: ")
b_json(noun, adj, location, filename)
else:
print("Sugondese NUTZ")