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

autoformatted code

This commit is contained in:
A_D 2020-10-02 09:32:59 +02:00 committed by Athanasius
parent c13caa22ef
commit a25ea9dfa9

View File

@ -1,7 +1,4 @@
import csv
import time
from collections import OrderedDict
from functools import partial
from sys import platform
from typing import TYPE_CHECKING
@ -35,10 +32,12 @@ if platform=='win32':
except: # Not supported under Wine 4.0
CalculatePopupWindowPosition = None
def status(data):
# StatsResults assumes these three things are first
res = [ [_('Cmdr'), data['commander']['name']],
res = [
[_('Cmdr'), data['commander']['name']],
[_('Balance'), str(data['commander'].get('credits', 0))], # Cmdr stats
[_('Loan'), str(data['commander'].get('debt', 0))], # Cmdr stats
]
@ -56,9 +55,9 @@ def status(data):
]
RANK_NAMES = {
# http://elite-dangerous.wikia.com/wiki/Pilots_Federation#Ranks
'combat' : [_('Harmless'), # Combat rank
'combat': [
_('Harmless'), # Combat rank
_('Mostly Harmless'), # Combat rank
_('Novice'), # Combat rank
_('Competent'), # Combat rank
@ -66,8 +65,10 @@ def status(data):
_('Master'), # Combat rank
_('Dangerous'), # Combat rank
_('Deadly'), # Combat rank
_('Elite')], # Top rank
'trade' : [_('Penniless'), # Trade rank
_('Elite'), # Top rank
],
'trade': [
_('Penniless'), # Trade rank
_('Mostly Penniless'), # Trade rank
_('Peddler'), # Trade rank
_('Dealer'), # Trade rank
@ -75,8 +76,10 @@ def status(data):
_('Broker'), # Trade rank
_('Entrepreneur'), # Trade rank
_('Tycoon'), # Trade rank
_('Elite')], # Top rank
'explore' : [_('Aimless'), # Explorer rank
_('Elite') # Top rank
],
'explore': [
_('Aimless'), # Explorer rank
_('Mostly Aimless'), # Explorer rank
_('Scout'), # Explorer rank
_('Surveyor'), # Explorer rank
@ -84,8 +87,10 @@ def status(data):
_('Pathfinder'), # Explorer rank
_('Ranger'), # Explorer rank
_('Pioneer'), # Explorer rank
_('Elite')], # Top rank
'cqc' : [_('Helpless'), # CQC rank
_('Elite') # Top rank
],
'cqc': [
_('Helpless'), # CQC rank
_('Mostly Helpless'), # CQC rank
_('Amateur'), # CQC rank
_('Semi Professional'), # CQC rank
@ -93,10 +98,12 @@ def status(data):
_('Champion'), # CQC rank
_('Hero'), # CQC rank
_('Gladiator'), # CQC rank
_('Elite')], # Top rank
_('Elite') # Top rank
],
# http://elite-dangerous.wikia.com/wiki/Federation#Ranks
'federation' : [_('None'), # No rank
'federation': [
_('None'), # No rank
_('Recruit'), # Federation rank
_('Cadet'), # Federation rank
_('Midshipman'), # Federation rank
@ -110,10 +117,12 @@ def status(data):
_('Post Captain'), # Federation rank
_('Rear Admiral'), # Federation rank
_('Vice Admiral'), # Federation rank
_('Admiral')], # Federation rank
_('Admiral') # Federation rank
],
# http://elite-dangerous.wikia.com/wiki/Empire#Ranks
'empire' : [_('None'), # No rank
'empire': [
_('None'), # No rank
_('Outsider'), # Empire rank
_('Serf'), # Empire rank
_('Master'), # Empire rank
@ -127,15 +136,18 @@ def status(data):
_('Marquis'), # Empire rank
_('Duke'), # Empire rank
_('Prince'), # Empire rank
_('King')], # Empire rank
_('King') # Empire rank
],
# http://elite-dangerous.wikia.com/wiki/Ratings
'power' : [_('None'), # No rank
'power': [
_('None'), # No rank
_('Rating 1'), # Power rank
_('Rating 2'), # Power rank
_('Rating 3'), # Power rank
_('Rating 4'), # Power rank
_('Rating 5')], # Power rank
_('Rating 5') # Power rank
],
}
ranks = data['commander'].get('rank', {})
@ -144,6 +156,7 @@ def status(data):
names = RANK_NAMES[thing]
if isinstance(rank, int):
res.append([title, rank < len(names) and names[rank] or ('Rank %d' % rank)])
else:
res.append([title, _('None')]) # No rank
@ -177,8 +190,7 @@ def ships(data):
'', str(ships[0]['value']['total'])
)] +
[(
str(ship['id']), ship_map.get(ship['name'].lower(),
ship['name']),
str(ship['id']), ship_map.get(ship['name'].lower(), ship['name']),
ship.get('shipName', ''),
ship['starsystem']['name'],
ship['station']['name'],
@ -205,7 +217,6 @@ def export_ships(data, filename):
class StatsDialog():
def __init__(self, app):
self.parent = app.w
self.status = app.status
@ -226,7 +237,8 @@ class StatsDialog():
return
except Exception as e:
if __debug__: print_exc()
if __debug__:
print_exc()
self.status['text'] = str(e)
return
@ -250,7 +262,6 @@ class StatsDialog():
class StatsResults(tk.Toplevel):
def __init__(self, parent, data):
tk.Toplevel.__init__(self, parent)
@ -270,6 +281,7 @@ class StatsResults(tk.Toplevel):
self.resizable(tk.FALSE, tk.FALSE)
if platform == 'win32':
self.attributes('-toolwindow', tk.TRUE)
elif platform == 'darwin':
# http://wiki.tcl.tk/13428
parent.call('tk::unsupported::MacWindowStyle', 'style', self, 'utility')
@ -296,6 +308,7 @@ class StatsResults(tk.Toplevel):
_('Station'), # Status dialog subtitle
_('Value'), # Status dialog subtitle - CR value of ship
])
shiplist = ships(data)
for thing in shiplist:
self.addpagerow(page, list(thing[1:-1]) + [self.credits(int(thing[-1]))]) # skip id, last item is money
@ -318,9 +331,11 @@ class StatsResults(tk.Toplevel):
if platform == 'win32' and CalculatePopupWindowPosition:
position = RECT()
GetWindowRect(GetParent(self.winfo_id()), position)
if CalculatePopupWindowPosition(POINT(parent.winfo_rootx(), parent.winfo_rooty()),
if CalculatePopupWindowPosition(
POINT(parent.winfo_rootx(), parent.winfo_rooty()),
SIZE(position.right - position.left, position.bottom - position.top),
0x10000, None, position):
0x10000, None, position
):
self.geometry("+%d+%d" % (position.left, position.top))
def addpage(self, parent, header=[], align=None):
@ -354,4 +369,3 @@ class StatsResults(tk.Toplevel):
def credits(self, value):
return Locale.stringFromNumber(value, 0) + ' Cr'