-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStargates.py
68 lines (60 loc) · 2.05 KB
/
Stargates.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
import json
import os
def writer(target,tbw):
with open(target,'w') as outfile:
json.dump(tbw,outfile)
def intFilter(strang):
return int(''.join(c for c in strang if c.isdigit()))
def stargateParse(stargate):
out = {}
out["id"] = intFilter(stargate[0])
out["pair"] = intFilter(stargate[1])
if stargate[3].count("-") == 2:
out["x"] = -1 * intFilter(stargate[3])/10
else:
out["x"] = intFilter(stargate[3])/10
if stargate[4].count("-") == 2:
out["y"] = -1 * intFilter(stargate[4])/10
else:
out["y"] = intFilter(stargate[4])/10
if stargate[5].count("-") == 2:
out["z"] = -1 * intFilter(stargate[5])/10
else:
out["z"] = intFilter(stargate[5])/10
return out
def systemParse(data,name):
lineList = [line.rstrip('\n') for line in data]
out = {}
out["stargates"] = []
grabStargate = False
counter = 0
stargate = []
out["name"] = name.split("\\")[2]
for line in lineList:
if grabStargate:
stargate.append(line)
if "typeID:" in line:
out["stargates"].append(stargateParse(stargate))
stargate = []
if "sunTypeID:" in line:
grabStargate = False
if "solarSystemID:" in line:
out["id"] = intFilter(line)
if "stargates:" in line:
grabStargate = True
return out
def stargateScrape():
out = {}
banned = ["UUA-F4", "A821-A", "J7HZ-F", "Pochven"]
path = "eve/"
regions = [f.path for f in os.scandir(path) if f.is_dir() and f.name not in banned]
for region in regions:
constellations = [f.path for f in os.scandir(region) if f.is_dir()]
for constellation in constellations:
systems = [f.path for f in os.scandir(constellation) if f.is_dir()]
for system in systems:
data = open(system + '\\solarsystem.staticdata')
parsed = systemParse(data,system)
out[parsed["id"]] = parsed
return out
writer("stargateDB.json",stargateScrape())