diff --git a/README.md b/README.md index e6e37e7..14b69a1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # edsmAround Shitty code to see what's around in Elite Dangerous. Uses EDSM data. +To use, open the file and modify the Sector Name. Then run with python3 diff --git a/edsmAround.py b/edsmAround.py index 1971001..ed5db64 100644 --- a/edsmAround.py +++ b/edsmAround.py @@ -2,15 +2,16 @@ import requests as r import re import json - #IMPORTANT BITS ###This is the name of the sector you want to search into (Do not use caps!) name = "Cleeque" + +### don't touch any of this. Or do, I'm a comment, not a cop. postFixList =["AA-A","BA-A","CL-Y","DL-Y","EG-Y","FG-Y","YE-A","ZE-A"] - +###Call to EDSM API, don't run this script too much in a short timeframe. def apiCall(systemName): systems = r.get("https://www.edsm.net/api-v1/systems", params={'systemName' : systemName}) return systems @@ -21,81 +22,42 @@ patternh = re.compile(".*[ABCDEFGYZ][ACELGGZ]-[AYDE] [h].*") patterng = re.compile(".*[ABCDEFGYZ][ACELGGZ]-[AYDE] [g].*") -listeH = [] -listeG = [] +listH = [] +listG = [] #fetch sector + postfix data from edsm for p in postFixList: for s in json.loads(apiCall(name +" "+p).content): if patternh.match(s['name']): - print(f"adding {s['name']} to list") - listeH.append(s['name']) + #print(f"adding {s['name']} to list") + listH.append(s['name']) elif patterng.match(s['name']): - print(f"adding {s['name']} to list") - listeG.append(s['name']) - # also prepare dictionnary for after + #print(f"adding {s['name']} to list") + listG.append(s['name']) + + # also prepare dictionnary for later lh[p] = [] lmaxh[p] = 0 lg[p] = [] lmaxg[p] = 0 - -# lh = {"AA-A" : [], -# "BA-A" : [], -# "CL-Y" : [], -# "DL-Y" : [], -# "EG-Y" : [], -# "FG-Y" : [], -# "YE-A" : [], -# "ZE-A" : []} - -# lmaxh = {"AA-A" : 0, -# "BA-A" : 0, -# "CL-Y" : 0, -# "DL-Y" : 0, -# "EG-Y" : 0, -# "FG-Y" : 0, -# "YE-A" : 0, -# "ZE-A" : 0} - -# lg = {"AA-A" : [], -# "BA-A" : [], -# "CL-Y" : [], -# "DL-Y" : [], -# "EG-Y" : [], -# "FG-Y" : [], -# "YE-A" : [], -# "ZE-A" : []} - -# lmaxg = {"AA-A" : 0, -# "BA-A" : 0, -# "CL-Y" : 0, -# "DL-Y" : 0, -# "EG-Y" : 0, -# "FG-Y" : 0, -# "YE-A" : 0, -# "ZE-A" : 0} - -#h systems + lcandidates[p] = [] -for s in listeH: - # print(f"now dealing with {s}") + +#Sorting H systems into postfix dict entries +for s in listH: for pre in postFixList: if pre in s: - length = len(f"{name} {pre} h") + length = len(f"{name} {pre} h") ##TODO replace this bullshit cur = int(s[length:]) if cur > lmaxh[pre]: lmaxh[pre] = cur - # print(s) lh[pre].append(s) - - - - -for s in listeG: +#Same with G systems +for s in listG: for pre in postFixList: if pre in s: length = len(f"{name} {pre} g") @@ -105,27 +67,13 @@ for s in listeG: lg[pre].append(s) - -# print(lh) -print("These are the H sized systems") +print("These are the H sized systems known to EDSM") print(lmaxh) -# -# print(lg) -print("These are the G sized systems") +print("These are the G sized systems known to EDSM") print(lmaxg) -#generate other systems for H - -lcandidates = {"AA-A" : [], - "BA-A" : [], - "CL-Y" : [], - "DL-Y" : [], - "EG-Y" : [], - "FG-Y" : [], - "YE-A" : [], - "ZE-A" : []} - +#generate all the systems for H and adds it to the candidate dict only if its not on EDSM for i in postFixList: maxi = lmaxh[i] @@ -134,6 +82,8 @@ for i in postFixList: if sys not in lh[i]: lcandidates[i].append(sys) +#same for G systems + for i in postFixList: maxi = lmaxg[i] for j in range(maxi): @@ -141,59 +91,11 @@ for i in postFixList: if sys not in lg[i]: lcandidates[i].append(sys) +#Finally writes the results to a JSON file. with open(f"{name}-RESULTS.json",'w') as f: f.write(json.dumps(lcandidates, indent=4)) - # length = len(f"{name} {pre} h") - # print(pre) - # if pre in s: - # cur = int(s[length:]) - # if cur > lmaxh[pre]: - # lmaxh[pre] = cur - -# listeNonEDSM = [] -# -# #fill with all systems -# -# for i in ['A','B','C','D','E','F','G','Y','Z']: -# print(i) -# for j in ['A','C','E','L','G','G','Z']: -# for k in ['A','Y','D','E']: -# for l in range(0,600): -# listeNonEDSM.append(f"{name} {i}{j}-{k} h{l}") -# listeNonEDSM.append(f"{name} {i}{j}-{k} g{l}") -# -# -# -# listeNonEDSM = [x for x in listeNonEDSM if x not in listeCompat] -# -# -# [print(s) for s in listeNonEDSM] - - - - -# maxi = 0 -# listeNbr = [] -# for system in listeCompat: -# inte = int(system[system.rfind('h')+1:]) -# listeNbr.append(inte) -# if inte > maxi: -# maxi = inte -# -# potential = [] -# -# for i in range(0, maxi): -# if i not in listeNbr: -# potential.append(i) -# -# for i in range(0, len(potential)-10, 10): -# print(potential[i:i+10]) -# -# # - -