added interactive mode and proably thargoids.

This commit is contained in:
TanguyPcFixe 2024-05-25 14:07:03 +02:00
parent 9ef40206bf
commit 711ff34420

View File

@ -3,6 +3,7 @@ import re
import json
from datetime import datetime as dt
from math import floor
import sys
#IMPORTANT BITS
@ -20,13 +21,6 @@ postFixList =["WP-X"]
###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})
@ -63,6 +57,64 @@ def maxSystemValue(systemList):
return currentMax
###interactive part
if (len(sys.argv) > 1):
for arg in sys.argv:
if arg == "-i":
print("Starting interactive mode.")
print("Please input a sector name with only the first letter capitalized (ex : Byoomiae) ")
sectorNamePattern = re.compile("^[A-Z][a-z]+$")
possibleSectorName = input()
while not sectorNamePattern.match(possibleSectorName):
print("The sector name you have entered is incorrect. Please try again")
possibleSectorName = input()
sectorName = possibleSectorName
print(f"Entered Sector name is {sectorName}")
print("Please enter the postFix you want to use. PostFix are the letters after the sector name (AA-A, RD-A). Write one per line, in all caps, with the hyphen. Send an empty line to finish")
possiblePostFix = input()
postFixList = []
while possiblePostFix != "":
postFixPattern = re.compile("^[A-Z][A-Z]-[A-Z]$")
if postFixPattern.match(possiblePostFix):
if possiblePostFix not in postFixList:
postFixList.append(possiblePostFix)
print(f"added {possiblePostFix} to the list of patterns. Current list is {postFixList}")
else:
print(f"PostFix already in list! Current list is {postFixList}")
possiblePostFix = input()
else:
print("This postFix doesn't look right. Try again")
possiblePostFix = input()
if postFixList == []:
print("postFix list empty. Exiting!")
exit()
print("Please enter the weights you want to use. One letter per line, in lowercase, send an empty line to finish.")
possibleWeights = input()
weightsToQuery = []
while possibleWeights != "":
weightPattern = re.compile("^[a-h]$")
if weightPattern.match(possibleWeights):
if possibleWeights not in weightsToQuery:
weightsToQuery.append(possibleWeights)
print(f"added {possibleWeights} to the list of weights. Current list is {weightsToQuery}")
else:
print(f"Weight already in list! Current list is {weightsToQuery}")
possibleWeights = input()
else:
print("This weight doesn't look right. Try again")
possibleWeights = input()
if weightsToQuery == []:
print("weight list empty. Exiting!")
exit()
print("Starting search!")
#dict of dict of systems keyed by postfix, keyed by weight ( dict["AA-A"]["g"] gives back all the AA-A GXXX systems)
sysWeightDict = {}