1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-12 15:27:14 +03:00

Fix stats display

Fixes #312
This commit is contained in:
Jonathan Harris 2018-04-07 09:53:17 +01:00
parent a0e5bcd5c6
commit 04f68b535f
2 changed files with 10 additions and 7 deletions

View File

@ -465,7 +465,7 @@ class EDLogs(FileSystemEventHandler):
if k in self.state['Rank']:
self.state['Rank'][k] = (self.state['Rank'][k][0], min(v, 100)) # perhaps not taken promotion mission yet
elif entry['event'] in ['Reputation', 'Statistics']:
payload = dict(entry)
payload = OrderedDict(entry)
payload.pop('event')
payload.pop('timestamp')
self.state[entry['event']] = payload

View File

@ -12,6 +12,7 @@ import myNotebook as nb
import companion
from companion import ship_map
from l10n import Locale
from monitor import monitor
import prefs
@ -159,10 +160,13 @@ def ships(data):
if not data['commander'].get('docked'):
# Set current system, not last docked
return ([ (str(ships[0]['id']), ship_map.get(ships[0]['name'].lower(), ships[0]['name']), ships[0].get('shipName', ''), data['lastSystem']['name'], '', str(ships[0]['value']['total'])) ] +
[ (str(ship['id']), ship_map.get(ship['name'].lower(), ship['name']), ship.get('shipName', ''), ship['starsystem']['name'], ship['station']['name'], str(ship['value']['total'])) for ship in ships[1:] if ship])
return ([ (str(ships[0]['id']), ship_map.get(ships[0]['name'].lower(), ships[0]['name']), ships[0].get('shipName', ''), data['lastSystem']['name'], '', credits(ships[0]['value']['total'])) ] +
[ (str(ship['id']), ship_map.get(ship['name'].lower(), ship['name']), ship.get('shipName', ''), ship['starsystem']['name'], ship['station']['name'], credits(ship['value']['total'])) for ship in ships[1:] if ship])
return [ (str(ship['id']), ship_map.get(ship['name'].lower(), ship['name']), ship.get('shipName', ''), ship['starsystem']['name'], ship['station']['name'], str(ship['value']['total'])) for ship in ships if ship]
return [ (str(ship['id']), ship_map.get(ship['name'].lower(), ship['name']), ship.get('shipName', ''), ship['starsystem']['name'], ship['station']['name'], credits(ship['value']['total'])) for ship in ships if ship]
def credits(value):
return Locale.stringFromNumber(value, 0) + ' Cr'
def export_ships(data, filename):
h = csv.writer(open(filename, 'wb'))
@ -175,7 +179,6 @@ class StatsDialog():
def __init__(self, app):
self.parent = app.w
self.session = app.session
self.status = app.status
self.verify = app.verify
self.showstats()
@ -188,7 +191,7 @@ class StatsDialog():
self.parent.update_idletasks()
try:
data = self.session.profile()
data = companion.session.profile()
except companion.VerificationRequired:
return prefs.AuthenticationDialog(self.parent, partial(self.verify, self.showstats))
except companion.ServerError as e:
@ -242,7 +245,7 @@ class StatsResults(tk.Toplevel):
page = self.addpage(notebook)
for thing in stats[1:3]:
self.addpagerow(page, [thing[0], thing[1] + ' CR']) # assumes things two and three are money
self.addpagerow(page, [thing[0], credits(int(thing[1]))]) # assumes things two and three are money
for thing in stats[3:]:
self.addpagerow(page, thing)
ttk.Frame(page).grid(pady=5) # bottom spacer