tradedangerous 10.17.0__py3-none-any.whl → 11.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of tradedangerous might be problematic. Click here for more details.
- tradedangerous/__init__.py +4 -4
- tradedangerous/cache.py +178 -142
- tradedangerous/cli.py +2 -7
- tradedangerous/commands/TEMPLATE.py +1 -2
- tradedangerous/commands/__init__.py +2 -4
- tradedangerous/commands/buildcache_cmd.py +6 -11
- tradedangerous/commands/buy_cmd.py +11 -12
- tradedangerous/commands/commandenv.py +16 -15
- tradedangerous/commands/exceptions.py +6 -4
- tradedangerous/commands/export_cmd.py +2 -4
- tradedangerous/commands/import_cmd.py +3 -5
- tradedangerous/commands/local_cmd.py +16 -25
- tradedangerous/commands/market_cmd.py +9 -8
- tradedangerous/commands/nav_cmd.py +17 -25
- tradedangerous/commands/olddata_cmd.py +9 -15
- tradedangerous/commands/parsing.py +9 -6
- tradedangerous/commands/rares_cmd.py +9 -10
- tradedangerous/commands/run_cmd.py +25 -26
- tradedangerous/commands/sell_cmd.py +9 -9
- tradedangerous/commands/shipvendor_cmd.py +4 -7
- tradedangerous/commands/station_cmd.py +8 -14
- tradedangerous/commands/trade_cmd.py +5 -10
- tradedangerous/commands/update_cmd.py +10 -7
- tradedangerous/commands/update_gui.py +1 -3
- tradedangerous/corrections.py +1 -3
- tradedangerous/csvexport.py +8 -8
- tradedangerous/edscupdate.py +4 -6
- tradedangerous/edsmupdate.py +4 -4
- tradedangerous/formatting.py +53 -40
- tradedangerous/fs.py +6 -6
- tradedangerous/gui.py +53 -62
- tradedangerous/jsonprices.py +8 -16
- tradedangerous/mapping.py +4 -3
- tradedangerous/mfd/__init__.py +2 -4
- tradedangerous/mfd/saitek/__init__.py +0 -1
- tradedangerous/mfd/saitek/directoutput.py +8 -11
- tradedangerous/mfd/saitek/x52pro.py +5 -7
- tradedangerous/misc/checkpricebounds.py +2 -3
- tradedangerous/misc/clipboard.py +2 -3
- tradedangerous/misc/coord64.py +2 -1
- tradedangerous/misc/derp-sentinel.py +1 -1
- tradedangerous/misc/diff-system-csvs.py +3 -0
- tradedangerous/misc/eddb.py +1 -3
- tradedangerous/misc/eddn.py +2 -2
- tradedangerous/misc/edsc.py +7 -14
- tradedangerous/misc/edsm.py +1 -8
- tradedangerous/misc/importeddbstats.py +2 -1
- tradedangerous/misc/prices-json-exp.py +7 -5
- tradedangerous/misc/progress.py +2 -2
- tradedangerous/plugins/__init__.py +2 -2
- tradedangerous/plugins/edapi_plug.py +13 -19
- tradedangerous/plugins/edcd_plug.py +4 -5
- tradedangerous/plugins/eddblink_plug.py +11 -15
- tradedangerous/plugins/edmc_batch_plug.py +3 -5
- tradedangerous/plugins/journal_plug.py +2 -1
- tradedangerous/plugins/netlog_plug.py +5 -5
- tradedangerous/plugins/spansh_plug.py +394 -170
- tradedangerous/prices.py +19 -20
- tradedangerous/submit-distances.py +3 -8
- tradedangerous/templates/TradeDangerous.sql +305 -306
- tradedangerous/trade.py +12 -5
- tradedangerous/tradecalc.py +30 -34
- tradedangerous/tradedb.py +140 -206
- tradedangerous/tradeenv.py +143 -69
- tradedangerous/tradegui.py +4 -2
- tradedangerous/transfers.py +23 -20
- tradedangerous/version.py +1 -1
- {tradedangerous-10.17.0.dist-info → tradedangerous-11.0.1.dist-info}/METADATA +2 -2
- tradedangerous-11.0.1.dist-info/RECORD +79 -0
- tradedangerous-10.17.0.dist-info/RECORD +0 -79
- {tradedangerous-10.17.0.dist-info → tradedangerous-11.0.1.dist-info}/LICENSE +0 -0
- {tradedangerous-10.17.0.dist-info → tradedangerous-11.0.1.dist-info}/WHEEL +0 -0
- {tradedangerous-10.17.0.dist-info → tradedangerous-11.0.1.dist-info}/entry_points.txt +0 -0
- {tradedangerous-10.17.0.dist-info → tradedangerous-11.0.1.dist-info}/top_level.txt +0 -0
tradedangerous/formatting.py
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
"""
|
|
2
|
+
Provides a library of mechanisms for formatting output text to ensure consistency across
|
|
3
|
+
TradeDangerous and plugin tools,
|
|
4
|
+
"""
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
2
7
|
import itertools
|
|
8
|
+
import typing
|
|
9
|
+
|
|
10
|
+
if typing.TYPE_CHECKING:
|
|
11
|
+
from typing import Any, Callable, Optional
|
|
3
12
|
|
|
4
|
-
class ColumnFormat
|
|
13
|
+
class ColumnFormat:
|
|
5
14
|
"""
|
|
6
15
|
Describes formatting of a column to be populated with data.
|
|
7
16
|
|
|
8
17
|
Member Functions:
|
|
9
18
|
|
|
10
|
-
|
|
19
|
+
text()
|
|
11
20
|
Applies all formatting (except qualifier) to the name to
|
|
12
21
|
produce a correctly sized title field.
|
|
13
22
|
|
|
@@ -47,7 +56,7 @@ class ColumnFormat(object):
|
|
|
47
56
|
]
|
|
48
57
|
rows = [ {'name':'Bob', 'dist':1.5}, {'name':'John', 'dist':23}]
|
|
49
58
|
# print titles
|
|
50
|
-
print(*[col.
|
|
59
|
+
print(*[col.text() for col in cols])
|
|
51
60
|
for row in rows:
|
|
52
61
|
print(*[col.format(row) for col in cols])
|
|
53
62
|
Produces:
|
|
@@ -56,6 +65,15 @@ class ColumnFormat(object):
|
|
|
56
65
|
John [23.00]
|
|
57
66
|
|
|
58
67
|
"""
|
|
68
|
+
name: str # name of the column
|
|
69
|
+
align: str # format's alignment specifier
|
|
70
|
+
width: int # width specifier
|
|
71
|
+
qualifier: Optional[str] # optional format type specifier e.g. '.2f', 's', 'n'
|
|
72
|
+
pre: Optional[str] # prefix to the column
|
|
73
|
+
post: Optional[str] # postfix to the column
|
|
74
|
+
key: Callable # function to retrieve the printable name of the item
|
|
75
|
+
pred: Callable # predicate: return False to leave this column blank
|
|
76
|
+
|
|
59
77
|
def __init__(
|
|
60
78
|
self,
|
|
61
79
|
name,
|
|
@@ -66,7 +84,7 @@ class ColumnFormat(object):
|
|
|
66
84
|
post=None,
|
|
67
85
|
key=lambda item: item,
|
|
68
86
|
pred=lambda item: True,
|
|
69
|
-
):
|
|
87
|
+
) -> None:
|
|
70
88
|
self.name = name
|
|
71
89
|
self.align = align
|
|
72
90
|
self.width = max(int(width), len(name))
|
|
@@ -76,29 +94,17 @@ class ColumnFormat(object):
|
|
|
76
94
|
self.post = post or ''
|
|
77
95
|
self.pred = pred
|
|
78
96
|
|
|
79
|
-
def
|
|
80
|
-
return '{pre}{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return '{pre}{value:{align}{width}{qual}}{post}'.format(
|
|
89
|
-
value=self.key(value),
|
|
90
|
-
align=self.align, width=self.width,
|
|
91
|
-
qual=self.qualifier,
|
|
92
|
-
pre=self.pre, post=self.post,
|
|
93
|
-
)
|
|
94
|
-
else:
|
|
95
|
-
return '{pre}{value:{align}{width}}{post}'.format(
|
|
96
|
-
value="",
|
|
97
|
-
align=self.align, width=self.width,
|
|
98
|
-
pre=self.pre, post=self.post,
|
|
99
|
-
)
|
|
97
|
+
def __str__(self) -> str:
|
|
98
|
+
return f'{self.pre}{self.name:{self.align}{self.width}}{self.post}'
|
|
99
|
+
text = __str__
|
|
100
|
+
|
|
101
|
+
def format(self, value: str) -> str:
|
|
102
|
+
""" Returns the string formatted with a specific value"""
|
|
103
|
+
if not self.pred(value):
|
|
104
|
+
return f'{self.pre}{"":{self.align}{self.width}}{self.post}'
|
|
105
|
+
return f'{self.pre}{self.key(value):{self.align}{self.width}{self.qualifier}}{self.post}'
|
|
100
106
|
|
|
101
|
-
class RowFormat
|
|
107
|
+
class RowFormat:
|
|
102
108
|
"""
|
|
103
109
|
Describes an ordered collection of ColumnFormats
|
|
104
110
|
for dispay data from rows, such that calling
|
|
@@ -117,7 +123,7 @@ class RowFormat(object):
|
|
|
117
123
|
insert(pos, newCol)
|
|
118
124
|
Inserts a ColumnFormatter at position pos in the list
|
|
119
125
|
|
|
120
|
-
|
|
126
|
+
text()
|
|
121
127
|
Returns a list of all the column headings
|
|
122
128
|
|
|
123
129
|
format(rowData):
|
|
@@ -125,14 +131,17 @@ class RowFormat(object):
|
|
|
125
131
|
of the columns
|
|
126
132
|
|
|
127
133
|
"""
|
|
128
|
-
|
|
134
|
+
columns: list[ColumnFormat]
|
|
135
|
+
prefix: str
|
|
136
|
+
|
|
137
|
+
def __init__(self, prefix: Optional[str] = None):
|
|
129
138
|
self.columns = []
|
|
130
139
|
self.prefix = prefix or ""
|
|
131
140
|
|
|
132
|
-
def addColumn(self, *args, **kwargs):
|
|
141
|
+
def addColumn(self, *args, **kwargs) -> None:
|
|
133
142
|
self.append(ColumnFormat(*args, **kwargs))
|
|
134
143
|
|
|
135
|
-
def append(self, column, after=None):
|
|
144
|
+
def append(self, column: ColumnFormat, after: Optional[str] = None) -> 'RowFormat':
|
|
136
145
|
columns = self.columns
|
|
137
146
|
if after:
|
|
138
147
|
for idx, col in enumerate(columns, 1):
|
|
@@ -142,19 +151,22 @@ class RowFormat(object):
|
|
|
142
151
|
columns.append(column)
|
|
143
152
|
return self
|
|
144
153
|
|
|
145
|
-
def insert(self, pos, column):
|
|
154
|
+
def insert(self, pos: int, column: Optional[ColumnFormat]) -> None:
|
|
146
155
|
if column is not None:
|
|
147
156
|
self.columns.insert(pos, column)
|
|
148
157
|
|
|
149
|
-
def
|
|
150
|
-
return self.prefix
|
|
158
|
+
def __str__(self) -> str:
|
|
159
|
+
return f"{self.prefix} {' '.join(str(col) for col in self.columns)}"
|
|
160
|
+
|
|
161
|
+
text = __str__ # alias
|
|
151
162
|
|
|
152
|
-
def heading(self):
|
|
153
|
-
|
|
163
|
+
def heading(self) -> tuple[str, str]:
|
|
164
|
+
""" Returns a title and the appropriate underline for that text. """
|
|
165
|
+
headline = f"{self}"
|
|
154
166
|
return headline, '-' * len(headline)
|
|
155
167
|
|
|
156
|
-
def format(self,
|
|
157
|
-
return self.prefix
|
|
168
|
+
def format(self, row_data: Optional[Any]) -> str:
|
|
169
|
+
return f"{self.prefix} {' '.join(col.format(row_data) for col in self.columns)}"
|
|
158
170
|
|
|
159
171
|
def max_len(iterable, key=lambda item: item):
|
|
160
172
|
iterable, readahead = itertools.tee(iter(iterable))
|
|
@@ -164,6 +176,7 @@ def max_len(iterable, key=lambda item: item):
|
|
|
164
176
|
return 0
|
|
165
177
|
return max(len(key(item)) for item in iterable)
|
|
166
178
|
|
|
179
|
+
|
|
167
180
|
if __name__ == '__main__':
|
|
168
181
|
rowFmt = RowFormat(). \
|
|
169
182
|
append(ColumnFormat("Name", '<', '8', key=lambda row: row['name'])). \
|
|
@@ -175,7 +188,7 @@ if __name__ == '__main__':
|
|
|
175
188
|
]
|
|
176
189
|
|
|
177
190
|
def present():
|
|
178
|
-
rowTitle = rowFmt.
|
|
191
|
+
rowTitle = rowFmt.text()
|
|
179
192
|
print(rowTitle)
|
|
180
193
|
print('-' * len(rowTitle))
|
|
181
194
|
for row in rows:
|
|
@@ -188,4 +201,4 @@ if __name__ == '__main__':
|
|
|
188
201
|
print("Adding age ColumnFormat:")
|
|
189
202
|
|
|
190
203
|
rowFmt.append(after='Name', col=ColumnFormat("Age", '>', 3, pre='|', post='|', key=lambda row: row['age']))
|
|
191
|
-
present()
|
|
204
|
+
present()
|
tradedangerous/fs.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""This module should handle filesystem related operations
|
|
2
2
|
"""
|
|
3
3
|
from shutil import copy as shcopy
|
|
4
|
-
from os import makedirs
|
|
4
|
+
from os import makedirs
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
|
|
7
7
|
__all__ = ['copy', 'copyallfiles', 'touch', 'ensurefolder']
|
|
@@ -25,7 +25,7 @@ def copy(src, dst):
|
|
|
25
25
|
|
|
26
26
|
def copy_if_newer(src, dst):
|
|
27
27
|
"""
|
|
28
|
-
copy src to dst if src is newer
|
|
28
|
+
copy src to dst if src is newer
|
|
29
29
|
takes string or Path object as input
|
|
30
30
|
returns Path(dst) on success
|
|
31
31
|
returns Path(src) if not newer
|
|
@@ -33,11 +33,11 @@ def copy_if_newer(src, dst):
|
|
|
33
33
|
"""
|
|
34
34
|
srcPath = pathify(src).resolve()
|
|
35
35
|
dstPath = pathify(dst)
|
|
36
|
-
if dstPath.exists() and
|
|
36
|
+
if dstPath.exists() and dstPath.stat().st_mtime >= srcPath.stat().st_mtime:
|
|
37
37
|
return srcPath
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
|
|
39
|
+
shcopy(str(srcPath), str(dstPath))
|
|
40
|
+
return dstPath
|
|
41
41
|
|
|
42
42
|
def copyallfiles(srcdir, dstdir):
|
|
43
43
|
"""
|
tradedangerous/gui.py
CHANGED
|
@@ -31,12 +31,6 @@
|
|
|
31
31
|
# individual always-on-top for every window
|
|
32
32
|
# Data retrieval from CMDR's journal
|
|
33
33
|
|
|
34
|
-
from __future__ import absolute_import
|
|
35
|
-
from __future__ import with_statement
|
|
36
|
-
from __future__ import print_function
|
|
37
|
-
from __future__ import division
|
|
38
|
-
from __future__ import unicode_literals
|
|
39
|
-
from pkg_resources import resource_filename
|
|
40
34
|
import os
|
|
41
35
|
import sys
|
|
42
36
|
import traceback
|
|
@@ -47,7 +41,6 @@ from pathlib import Path
|
|
|
47
41
|
from appJar import gui
|
|
48
42
|
import appJar
|
|
49
43
|
|
|
50
|
-
|
|
51
44
|
# from tkinter import *
|
|
52
45
|
# import tkinter.font as font
|
|
53
46
|
# import tkinter.scrolledtext as scrolledtext
|
|
@@ -60,8 +53,6 @@ from .version import __version__
|
|
|
60
53
|
|
|
61
54
|
from . import tradedb
|
|
62
55
|
from .plugins import PluginException
|
|
63
|
-
from pycparser.ply.yacc import MAXINT
|
|
64
|
-
from pkg_resources import _sset_none
|
|
65
56
|
|
|
66
57
|
# ==================
|
|
67
58
|
# BEGIN appJar fixes
|
|
@@ -96,8 +87,9 @@ def setSpinBoxPos(self, title, pos, callFunction = True):
|
|
|
96
87
|
vals = self._getSpinBoxValsAsList(vals)
|
|
97
88
|
pos = int(pos)
|
|
98
89
|
if pos < 0 or pos >= len(vals):
|
|
99
|
-
raise
|
|
100
|
-
|
|
90
|
+
raise RuntimeError(
|
|
91
|
+
f"Invalid position: {pos}. No position in SpinBox: {title}={vals}"
|
|
92
|
+
)
|
|
101
93
|
# pos = len(vals) - 1 - pos
|
|
102
94
|
val = vals[pos]
|
|
103
95
|
self._setSpinBoxVal(spin, val, callFunction)
|
|
@@ -140,10 +132,10 @@ def _configOptionBoxList(self, title, options, kind):
|
|
|
140
132
|
# get the longest string length
|
|
141
133
|
try:
|
|
142
134
|
maxSize = len(str(max(options, key = len)))
|
|
143
|
-
except:
|
|
135
|
+
except: # noqa: E722
|
|
144
136
|
try:
|
|
145
137
|
maxSize = len(str(max(options)))
|
|
146
|
-
except:
|
|
138
|
+
except: # noqa: E722
|
|
147
139
|
maxSize = 0
|
|
148
140
|
|
|
149
141
|
# increase if ticks
|
|
@@ -220,9 +212,9 @@ def changeCWD():
|
|
|
220
212
|
"""
|
|
221
213
|
Opens a folder select dialog for choosing the current working directory.
|
|
222
214
|
"""
|
|
223
|
-
cwd = filedialog.askdirectory(title = "Select the top-level folder for TD to work in...",
|
|
215
|
+
cwd = filedialog.askdirectory(title = "Select the top-level folder for TD to work in...",
|
|
224
216
|
initialdir = argVals['--cwd'])
|
|
225
|
-
#cwd = win.directoryBox("Select the top-level folder for TD to work in...", dirName = argVals['--cwd'])
|
|
217
|
+
# cwd = win.directoryBox("Select the top-level folder for TD to work in...", dirName = argVals['--cwd'])
|
|
226
218
|
if cwd:
|
|
227
219
|
argVals['--cwd'] = str(Path(cwd))
|
|
228
220
|
widgets['cwd']['text'] = argVals['--cwd']
|
|
@@ -231,13 +223,14 @@ def changeDB():
|
|
|
231
223
|
"""
|
|
232
224
|
Opens a file select dialog for choosing the database file.
|
|
233
225
|
"""
|
|
234
|
-
db = filedialog.askopenfilename(title = "Select the TD database file to use...",
|
|
226
|
+
db = filedialog.askopenfilename(title = "Select the TD database file to use...",
|
|
235
227
|
initialdir = str(Path(argVals['--db']).parent),
|
|
236
228
|
filetypes = [('Data Base File', '*.db')])
|
|
237
229
|
if db:
|
|
238
230
|
argVals['--db'] = str(Path(db))
|
|
239
231
|
widgets['db']['text'] = argVals['--db']
|
|
240
232
|
|
|
233
|
+
|
|
241
234
|
# A dict of all arguments in TD (mostly auto-generated)
|
|
242
235
|
# Manually add the global arguments for now, maybe figure out how to auto-populate them as well.
|
|
243
236
|
allArgs = {
|
|
@@ -300,16 +293,16 @@ def buildArgDicts():
|
|
|
300
293
|
# print(arg.args[0])
|
|
301
294
|
argVals[arg.args[0]] = arg.kwargs.get('default') or None
|
|
302
295
|
|
|
303
|
-
allArgs[cmd]['req'][arg.args[0]] = {kwarg
|
|
296
|
+
allArgs[cmd]['req'][arg.args[0]] = {kwarg: arg.kwargs[kwarg] for kwarg in arg.kwargs}
|
|
304
297
|
allArgs[cmd]['req'][arg.args[0]]['widget'] = chooseType(arg)
|
|
305
298
|
# print(allArgs[cmd]['req'])
|
|
306
299
|
|
|
307
300
|
if index.switches:
|
|
308
301
|
for arg in index.switches:
|
|
309
302
|
try:
|
|
310
|
-
argVals[arg.args[0]] =
|
|
303
|
+
argVals[arg.args[0]] = arg.kwargs.get('default') or None
|
|
311
304
|
|
|
312
|
-
allArgs[cmd]['opt'][arg.args[0]] = {kwarg
|
|
305
|
+
allArgs[cmd]['opt'][arg.args[0]] = {kwarg: arg.kwargs[kwarg] for kwarg in arg.kwargs}
|
|
313
306
|
allArgs[cmd]['opt'][arg.args[0]]['widget'] = chooseType(arg)
|
|
314
307
|
|
|
315
308
|
if arg.args[0] == '--option':
|
|
@@ -324,51 +317,49 @@ def buildArgDicts():
|
|
|
324
317
|
|
|
325
318
|
except AttributeError:
|
|
326
319
|
for argGrp in arg.arguments:
|
|
327
|
-
argVals[argGrp.args[0]] =
|
|
320
|
+
argVals[argGrp.args[0]] = argGrp.kwargs.get('default') or None
|
|
328
321
|
|
|
329
|
-
allArgs[cmd]['opt'][argGrp.args[0]] = {kwarg
|
|
322
|
+
allArgs[cmd]['opt'][argGrp.args[0]] = {kwarg: argGrp.kwargs[kwarg] for kwarg in argGrp.kwargs}
|
|
330
323
|
allArgs[cmd]['opt'][argGrp.args[0]]['widget'] = chooseType(argGrp)
|
|
331
324
|
|
|
332
325
|
allArgs[cmd]['opt'][argGrp.args[0]]['excludes'] = [excl.args[0] for excl in arg.arguments
|
|
333
326
|
if excl.args[0] != argGrp.args[0]]
|
|
334
327
|
if argGrp.args[0] == '--plug':
|
|
335
328
|
# Currently only the 'import' cmd has the '--plug' option,
|
|
336
|
-
# but this could no longer be the case in future.
|
|
329
|
+
# but this could no longer be the case in the future.
|
|
337
330
|
if cmd == 'import':
|
|
338
331
|
allArgs[cmd]['opt'][argGrp.args[0]]['plugins'] = importPlugs
|
|
339
|
-
|
|
340
|
-
# print(allArgs)
|
|
341
|
-
# print(argVals)
|
|
332
|
+
|
|
342
333
|
|
|
343
334
|
def optWindow():
|
|
344
335
|
"""
|
|
345
336
|
Opens a window listing all of the options for the currently selected plugin.
|
|
346
337
|
"""
|
|
347
338
|
# with win.subWindow("Plugin Options", modal = True) as sw:
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
339
|
+
# win.emptyCurrentContainer()
|
|
340
|
+
# optDict = {}
|
|
341
|
+
# if argVals['--option']:
|
|
342
|
+
# for option in enumerate(argVals['--option'].split(',')):
|
|
343
|
+
# if '=' in option[1]:
|
|
344
|
+
# optDict[option[1].split('=')[0]] = option[1].split('=')[1]
|
|
345
|
+
# else:
|
|
346
|
+
# if option[1] != '':
|
|
347
|
+
# optDict[option[1]] = True
|
|
348
|
+
# # print(optDict)
|
|
349
|
+
# if not win.combo('--plug'):
|
|
350
|
+
# win.message('No import plugin chosen.', width = 170, colspan = 10)
|
|
351
|
+
# else:
|
|
352
|
+
# plugOpts = allArgs['import']['opt']['--option']['options'][win.combo('--plug')]
|
|
353
|
+
# for option in plugOpts:
|
|
354
|
+
# # print(option + ': ' + plugOpts[option])
|
|
355
|
+
# if '=' in plugOpts[option]:
|
|
356
|
+
# win.entry(option, optDict.get(option) or '', label = True, sticky = 'ew', colspan = 10, tooltip = plugOpts[option])
|
|
357
|
+
# else:
|
|
358
|
+
# win.check(option, optDict.get(option) or False, sticky = 'ew', colspan = 10, tooltip = plugOpts[option])
|
|
359
|
+
# # print(plugOpts)
|
|
360
|
+
# win.button("Done", setOpts, column = 8)
|
|
361
|
+
# win.button("Cancel", sw.hide, row = 'p', column = 9)
|
|
362
|
+
# sw.show()
|
|
372
363
|
|
|
373
364
|
def chooseType(arg):
|
|
374
365
|
"""
|
|
@@ -637,7 +628,7 @@ def updateCommandBox(args = None):
|
|
|
637
628
|
# Setup the CLI interface and build the main window
|
|
638
629
|
def main(argv = None):
|
|
639
630
|
|
|
640
|
-
class IORedirector
|
|
631
|
+
class IORedirector:
|
|
641
632
|
|
|
642
633
|
def __init__(self, TEXT_INFO):
|
|
643
634
|
self.TEXT_INFO = TEXT_INFO
|
|
@@ -672,7 +663,7 @@ def main(argv = None):
|
|
|
672
663
|
argStr = argStr.rsplit(',', 1)[0]
|
|
673
664
|
win.entry('--option', argStr)
|
|
674
665
|
sw.hide()
|
|
675
|
-
|
|
666
|
+
|
|
676
667
|
#TODO: Implement in tk
|
|
677
668
|
def optionsWin():
|
|
678
669
|
"""
|
|
@@ -703,7 +694,7 @@ def main(argv = None):
|
|
|
703
694
|
win.button("Done", setOpts, column = 8)
|
|
704
695
|
win.button("Cancel", sw.hide, row = 'p', column = 9)
|
|
705
696
|
sw.show()
|
|
706
|
-
|
|
697
|
+
|
|
707
698
|
#TODO: Implement in tk
|
|
708
699
|
def updArgs(name):
|
|
709
700
|
"""
|
|
@@ -749,7 +740,7 @@ def main(argv = None):
|
|
|
749
740
|
win.setEntry(exclude, '', callFunction = False)
|
|
750
741
|
elif widgetType == 'check':
|
|
751
742
|
win.check(exclude, False, callFunction = False)
|
|
752
|
-
|
|
743
|
+
|
|
753
744
|
#TODO: REMOVE
|
|
754
745
|
def updCmd():
|
|
755
746
|
"""
|
|
@@ -774,7 +765,7 @@ def main(argv = None):
|
|
|
774
765
|
win.label('Optional:', sticky = 'w')
|
|
775
766
|
for key in allArgs[cmd]['opt']:
|
|
776
767
|
makeWidgets(key, allArgs[cmd]['opt'][key])
|
|
777
|
-
|
|
768
|
+
|
|
778
769
|
def runTD():
|
|
779
770
|
"""
|
|
780
771
|
Executes the TD command selected in the GUI.
|
|
@@ -881,7 +872,7 @@ def main(argv = None):
|
|
|
881
872
|
|
|
882
873
|
win.message('outputText', '')
|
|
883
874
|
threading.Thread(target = runTrade, name = "TDThread", daemon = True).start()
|
|
884
|
-
|
|
875
|
+
|
|
885
876
|
# TODO: replace
|
|
886
877
|
def makeWidgets(name, arg, sticky = 'ew', label = True, **kwargs):
|
|
887
878
|
kwargs['sticky'] = sticky
|
|
@@ -961,7 +952,7 @@ def main(argv = None):
|
|
|
961
952
|
|
|
962
953
|
|
|
963
954
|
buildArgDicts()
|
|
964
|
-
|
|
955
|
+
|
|
965
956
|
# window = Tk()
|
|
966
957
|
# window.title('Trade Dangerous GUI (Beta), TD v.%s' % (__version__,))
|
|
967
958
|
# window.iconbitmap(resource_filename(__name__, "../tradedangerouscrest.ico"))
|
|
@@ -1007,23 +998,23 @@ def main(argv = None):
|
|
|
1007
998
|
stretch = 'none', sticky = 'ew', width = 10, row = 0, column = 0, colspan = 5)
|
|
1008
999
|
with win.scrollPane('req', disabled = 'horizontal', row = 1, column = 0, colspan = 10) as pane:
|
|
1009
1000
|
pane.configure(width = 200, height = 75)
|
|
1010
|
-
|
|
1001
|
+
|
|
1011
1002
|
with win.scrollPane('opt', disabled = 'horizontal', row = 2, column = 0, colspan = 10) as pane:
|
|
1012
1003
|
pane.configure(width = 200, height = 345)
|
|
1013
|
-
|
|
1004
|
+
|
|
1014
1005
|
with win.tabbedFrame('tabFrame', disabled = 'horizontal', row = 1, column = 10, rowspan = 2, colspan = 40) as tabFrame:
|
|
1015
1006
|
with win.tab('Help'):
|
|
1016
1007
|
with win.scrollPane('helpPane', disabled = 'horizontal') as pane:
|
|
1017
1008
|
pane.configure(width = 560, height = 420)
|
|
1018
1009
|
win.message('helpText', cmdHelp['help'])
|
|
1019
1010
|
win.widgetManager.get(WIDGET_NAMES.Message, 'helpText').config(width = 560)
|
|
1020
|
-
|
|
1011
|
+
|
|
1021
1012
|
with win.tab('Output'):
|
|
1022
1013
|
with win.scrollPane('outPane', disabled = 'horizontal') as pane:
|
|
1023
1014
|
pane.configure(width = 560, height = 420)
|
|
1024
1015
|
win.message('outputText', '')
|
|
1025
1016
|
win.widgetManager.get(WIDGET_NAMES.Message, 'outputText').config(width = 560)
|
|
1026
|
-
|
|
1017
|
+
|
|
1027
1018
|
makeWidgets('--link-ly', allArgs['--link-ly'], sticky = 'w', width = 4, row = 3, column = 2)
|
|
1028
1019
|
|
|
1029
1020
|
makeWidgets('--quiet', allArgs['--quiet'], sticky = 'e', disabled = ':', width = 1, row = 3, column = 46)
|
|
@@ -1034,12 +1025,12 @@ def main(argv = None):
|
|
|
1034
1025
|
|
|
1035
1026
|
win.button('Run', runTD, tooltip = 'Execute the selected command.',
|
|
1036
1027
|
sticky = 'w', row = 3, column = 49)
|
|
1037
|
-
|
|
1028
|
+
|
|
1038
1029
|
makeWidgets('--cwd', allArgs['--cwd'], width = 4, row = 4, column = 0)
|
|
1039
1030
|
with win.scrollPane('CWD', disabled = 'vertical', row = 4, column = 1, colspan = 49) as pane:
|
|
1040
1031
|
pane.configure(width = 500, height = 20)
|
|
1041
1032
|
widgets['cwd'] = win.label('cwd', argVals['--cwd'], sticky = 'w')
|
|
1042
|
-
|
|
1033
|
+
|
|
1043
1034
|
makeWidgets('--db', allArgs['--db'], width = 4, row = 5, column = 0)
|
|
1044
1035
|
with win.scrollPane('DB', disabled = 'vertical', row = 5, column = 1, colspan = 49) as pane:
|
|
1045
1036
|
pane.configure(width = 500, height = 20)
|
tradedangerous/jsonprices.py
CHANGED
|
@@ -24,7 +24,7 @@ def lookup_system(tdb, tdenv, name, x, y, z):
|
|
|
24
24
|
pass
|
|
25
25
|
|
|
26
26
|
if system:
|
|
27
|
-
if
|
|
27
|
+
if system.posX != x or system.posY != y or system.posZ != z:
|
|
28
28
|
raise Exception("System {} position mismatch: "
|
|
29
29
|
"Got {},{},{} expected {},{},{}".format(
|
|
30
30
|
name,
|
|
@@ -33,16 +33,9 @@ def lookup_system(tdb, tdenv, name, x, y, z):
|
|
|
33
33
|
))
|
|
34
34
|
return system
|
|
35
35
|
|
|
36
|
-
newSystem = "@{} [{}, {}, {}]".format(
|
|
37
|
-
name, x, y, z
|
|
38
|
-
)
|
|
39
|
-
|
|
40
36
|
candidates = []
|
|
41
37
|
for candidate in tdb.systemByID.values():
|
|
42
|
-
if
|
|
43
|
-
candidate.posY == y and
|
|
44
|
-
candidate.posZ == z
|
|
45
|
-
):
|
|
38
|
+
if candidate.posX == x and candidate.posY == y and candidate.posZ == z:
|
|
46
39
|
candidates.append(candidate)
|
|
47
40
|
|
|
48
41
|
if len(candidates) == 1:
|
|
@@ -61,10 +54,9 @@ def lookup_system(tdb, tdenv, name, x, y, z):
|
|
|
61
54
|
))
|
|
62
55
|
return candidates[0]
|
|
63
56
|
|
|
64
|
-
if
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
)
|
|
57
|
+
if candidates:
|
|
58
|
+
options = ', '.join([s.name for s in candidates])
|
|
59
|
+
raise RuntimeError(f"System {system.name} matches co-ordinates for systems: {options}")
|
|
68
60
|
|
|
69
61
|
if tdenv.addUnknown:
|
|
70
62
|
return tdb.addLocalSystem(name, x, y, z)
|
|
@@ -91,7 +83,7 @@ def lookup_station(
|
|
|
91
83
|
|
|
92
84
|
# Now set the parameters
|
|
93
85
|
tdb.updateLocalStation(
|
|
94
|
-
|
|
86
|
+
station, lsFromStar, blackMarket, maxPadSize
|
|
95
87
|
)
|
|
96
88
|
return station
|
|
97
89
|
|
|
@@ -116,7 +108,7 @@ def load_prices_json(
|
|
|
116
108
|
|
|
117
109
|
try:
|
|
118
110
|
blackMarket = stnData['bm'].upper()
|
|
119
|
-
if not
|
|
111
|
+
if blackMarket not in [ 'Y', 'N' ]:
|
|
120
112
|
blackMarket = '?'
|
|
121
113
|
except KeyError:
|
|
122
114
|
blackMarket = '?'
|
|
@@ -137,7 +129,7 @@ def load_prices_json(
|
|
|
137
129
|
return
|
|
138
130
|
if system.dbname != sysName and tdenv.detail:
|
|
139
131
|
print("NOTE: Treating '{}' as '{}'".format(
|
|
140
|
-
|
|
132
|
+
sysName, system.dbname
|
|
141
133
|
))
|
|
142
134
|
tdenv.DEBUG1("- System: {}", system.dbname)
|
|
143
135
|
|
tradedangerous/mapping.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Mapping class for FDEV-IDs to TD names
|
|
3
3
|
#
|
|
4
4
|
|
|
5
|
-
class FDEVMappingBase
|
|
5
|
+
class FDEVMappingBase:
|
|
6
6
|
"""
|
|
7
7
|
Base class to map FDEV-IDs to TD names, do not use directly.
|
|
8
8
|
|
|
@@ -67,7 +67,8 @@ class FDEVMappingBase(object):
|
|
|
67
67
|
else:
|
|
68
68
|
entries[ID] = {}
|
|
69
69
|
for i, val in enumerate(line[1:], start=1):
|
|
70
|
-
if val:
|
|
70
|
+
if val:
|
|
71
|
+
entries[ID][self.colNames[i]] = val
|
|
71
72
|
self.tdenv.DEBUG2("{}: {}".format(ID, str(entries[ID]).replace("{", "{{").replace("}", "}}")))
|
|
72
73
|
self.entries = entries
|
|
73
74
|
self.tdenv.DEBUG1("Loaded {:n} {}-Mappings".format(len(entries), self.tableName))
|
|
@@ -126,6 +127,6 @@ class FDEVMappingOutfitting(FDEVMappingBase):
|
|
|
126
127
|
Maps ID to EDDN outfitting
|
|
127
128
|
"""
|
|
128
129
|
tableName = "FDevOutfitting"
|
|
129
|
-
colNames = [ 'id', 'category'
|
|
130
|
+
colNames = [ 'id', 'category', 'name', 'mount',
|
|
130
131
|
'guidance', 'ship', 'class', 'rating'
|
|
131
132
|
]
|
tradedangerous/mfd/__init__.py
CHANGED
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
# You are free to use, redistribute, or even print and eat a copy of
|
|
3
3
|
# this software so long as you include this copyright notice.
|
|
4
4
|
# I guarantee there is at least one bug neither of us knew about.
|
|
5
|
-
|
|
5
|
+
# ---------------------------------------------------------------------
|
|
6
6
|
# TradeDangerous :: Modules :: Multi-function display wrapper
|
|
7
7
|
#
|
|
8
8
|
# Multi-Function Display wrappers
|
|
9
9
|
|
|
10
|
-
from __future__ import absolute_import, with_statement, print_function, division, unicode_literals
|
|
11
|
-
|
|
12
10
|
######################################################################
|
|
13
11
|
# imports
|
|
14
12
|
|
|
@@ -28,7 +26,7 @@ class MissingDeviceError(Exception):
|
|
|
28
26
|
######################################################################
|
|
29
27
|
# classes
|
|
30
28
|
|
|
31
|
-
class DummyMFD
|
|
29
|
+
class DummyMFD:
|
|
32
30
|
"""
|
|
33
31
|
Base class for the MFD drivers, implemented as no-ops so that
|
|
34
32
|
you can always use all MFD functions without conditionals.
|