Skip to content

Commit

Permalink
Let the user know about the API response.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgol committed Jul 8, 2016
1 parent 65776ab commit 0b061d9
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions plugins/edapi_plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,21 +415,24 @@ def askForStationData(self, system, stnName=None, station=None):
defShipyard = station.shipyard
defOutfitting = station.outfitting

def tellUserAPIResponse(defName, defValue):
if defValue == "Y":
tdenv.NOTE("{:>12} in API response", defName)
else:
tdenv.NOTE("{:>12} NOT in API response", defName)

# defaults from API response are not reliable!
if 'commodities' in self.edAPI.profile['lastStarport']:
defMarket = "Y"
else:
defMarket = "N"
if 'ships' in self.edAPI.profile['lastStarport']:
defShipyard = "Y"
else:
defShipyard = "N"
if 'modules' in self.edAPI.profile['lastStarport']:
defOutfitting = "Y"
else:
defOutfitting = "N"
checkStarport = self.edAPI.profile['lastStarport']
defMarket = "Y" if 'commodities' in checkStarport else "N"
defShipyard = "Y" if 'ships' in checkStarport else "N"
defOutfitting = "Y" if 'modules' in checkStarport else "N"
tellUserAPIResponse("'Outfitting'", defOutfitting)
tellUserAPIResponse("'ShipYard'", defShipyard)
tellUserAPIResponse("'Market'", defMarket)

def warnAPIResponse(checkName, checkYN):
# no warning if unknown
if checkYN == "?": return False
warnText = (
"The station should{s} have a {what}, "
"but the API did{d} return one."
Expand Down

0 comments on commit 0b061d9

Please sign in to comment.