tradedangerous 12.7.6__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.
- py.typed +1 -0
- trade.py +49 -0
- tradedangerous/__init__.py +43 -0
- tradedangerous/cache.py +1381 -0
- tradedangerous/cli.py +136 -0
- tradedangerous/commands/TEMPLATE.py +74 -0
- tradedangerous/commands/__init__.py +244 -0
- tradedangerous/commands/buildcache_cmd.py +102 -0
- tradedangerous/commands/buy_cmd.py +427 -0
- tradedangerous/commands/commandenv.py +372 -0
- tradedangerous/commands/exceptions.py +94 -0
- tradedangerous/commands/export_cmd.py +150 -0
- tradedangerous/commands/import_cmd.py +222 -0
- tradedangerous/commands/local_cmd.py +243 -0
- tradedangerous/commands/market_cmd.py +207 -0
- tradedangerous/commands/nav_cmd.py +252 -0
- tradedangerous/commands/olddata_cmd.py +270 -0
- tradedangerous/commands/parsing.py +221 -0
- tradedangerous/commands/rares_cmd.py +298 -0
- tradedangerous/commands/run_cmd.py +1521 -0
- tradedangerous/commands/sell_cmd.py +262 -0
- tradedangerous/commands/shipvendor_cmd.py +60 -0
- tradedangerous/commands/station_cmd.py +68 -0
- tradedangerous/commands/trade_cmd.py +181 -0
- tradedangerous/commands/update_cmd.py +67 -0
- tradedangerous/corrections.py +55 -0
- tradedangerous/csvexport.py +234 -0
- tradedangerous/db/__init__.py +27 -0
- tradedangerous/db/adapter.py +192 -0
- tradedangerous/db/config.py +107 -0
- tradedangerous/db/engine.py +259 -0
- tradedangerous/db/lifecycle.py +332 -0
- tradedangerous/db/locks.py +208 -0
- tradedangerous/db/orm_models.py +500 -0
- tradedangerous/db/paths.py +113 -0
- tradedangerous/db/utils.py +661 -0
- tradedangerous/edscupdate.py +565 -0
- tradedangerous/edsmupdate.py +474 -0
- tradedangerous/formatting.py +210 -0
- tradedangerous/fs.py +156 -0
- tradedangerous/gui.py +1146 -0
- tradedangerous/mapping.py +133 -0
- tradedangerous/mfd/__init__.py +103 -0
- tradedangerous/mfd/saitek/__init__.py +3 -0
- tradedangerous/mfd/saitek/directoutput.py +678 -0
- tradedangerous/mfd/saitek/x52pro.py +195 -0
- tradedangerous/misc/checkpricebounds.py +287 -0
- tradedangerous/misc/clipboard.py +49 -0
- tradedangerous/misc/coord64.py +83 -0
- tradedangerous/misc/csvdialect.py +57 -0
- tradedangerous/misc/derp-sentinel.py +35 -0
- tradedangerous/misc/diff-system-csvs.py +159 -0
- tradedangerous/misc/eddb.py +81 -0
- tradedangerous/misc/eddn.py +349 -0
- tradedangerous/misc/edsc.py +437 -0
- tradedangerous/misc/edsm.py +121 -0
- tradedangerous/misc/importeddbstats.py +54 -0
- tradedangerous/misc/prices-json-exp.py +179 -0
- tradedangerous/misc/progress.py +194 -0
- tradedangerous/plugins/__init__.py +249 -0
- tradedangerous/plugins/edcd_plug.py +371 -0
- tradedangerous/plugins/eddblink_plug.py +861 -0
- tradedangerous/plugins/edmc_batch_plug.py +133 -0
- tradedangerous/plugins/spansh_plug.py +2647 -0
- tradedangerous/prices.py +211 -0
- tradedangerous/submit-distances.py +422 -0
- tradedangerous/templates/Added.csv +37 -0
- tradedangerous/templates/Category.csv +17 -0
- tradedangerous/templates/RareItem.csv +143 -0
- tradedangerous/templates/TradeDangerous.sql +338 -0
- tradedangerous/tools.py +40 -0
- tradedangerous/tradecalc.py +1302 -0
- tradedangerous/tradedb.py +2320 -0
- tradedangerous/tradeenv.py +313 -0
- tradedangerous/tradeenv.pyi +109 -0
- tradedangerous/tradeexcept.py +131 -0
- tradedangerous/tradeorm.py +183 -0
- tradedangerous/transfers.py +192 -0
- tradedangerous/utils.py +243 -0
- tradedangerous/version.py +16 -0
- tradedangerous-12.7.6.dist-info/METADATA +106 -0
- tradedangerous-12.7.6.dist-info/RECORD +87 -0
- tradedangerous-12.7.6.dist-info/WHEEL +5 -0
- tradedangerous-12.7.6.dist-info/entry_points.txt +3 -0
- tradedangerous-12.7.6.dist-info/licenses/LICENSE +373 -0
- tradedangerous-12.7.6.dist-info/top_level.txt +2 -0
- tradegui.py +24 -0
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
#!/usr/bin/env python3.6
|
|
2
|
+
# Deprecated
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
This tool looks for changes in the EDSC service since the most
|
|
6
|
+
recent "modified" date in the System table or the date supplied
|
|
7
|
+
on the command line.
|
|
8
|
+
|
|
9
|
+
It then tries to do some validation but also requires user
|
|
10
|
+
confirmation.
|
|
11
|
+
|
|
12
|
+
For each star that appears to be new, it copies the name into
|
|
13
|
+
the clipboard so you can paste it into the "SEARCH" box in the
|
|
14
|
+
game to verify that the name is correct.
|
|
15
|
+
|
|
16
|
+
Additionally it shows you the distance from "current system"
|
|
17
|
+
to the star as a way to verify the co-ordinates.
|
|
18
|
+
|
|
19
|
+
This helps to catch cases where people have typo'd system names,
|
|
20
|
+
but given the right coordinates; it also helps catch cases where
|
|
21
|
+
people have used the star name from in-system which sometimes
|
|
22
|
+
differs from the star name in the galaxy map.
|
|
23
|
+
|
|
24
|
+
For each star you can type "y" to accept the star, "n" to skip it
|
|
25
|
+
or "q" to stop recording.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
import argparse
|
|
29
|
+
import misc.clipboard
|
|
30
|
+
import misc.edsc
|
|
31
|
+
import os
|
|
32
|
+
import random
|
|
33
|
+
import re
|
|
34
|
+
import sys
|
|
35
|
+
import tradedb
|
|
36
|
+
import tradeenv
|
|
37
|
+
|
|
38
|
+
DEFAULT_DATE = "2015-04-01 00:00:00"
|
|
39
|
+
|
|
40
|
+
# Systems we know are bad.
|
|
41
|
+
ignore = [
|
|
42
|
+
"ADAM NAPAT",
|
|
43
|
+
"ALRAI SECTOR IR-W C1-29",
|
|
44
|
+
"ALRAI SECTOR OI-T B3-6 A",
|
|
45
|
+
"AN SEXSTANS",
|
|
46
|
+
"ARIETIS SECTOR WO-R 84-4",
|
|
47
|
+
"COL 285 SECTOR GI-P B20-4 A",
|
|
48
|
+
"COL 285 SECTOR GU-T 818-2",
|
|
49
|
+
"COL 285 SECTOR GU-T 818-5",
|
|
50
|
+
"COL 285 SECTOR HU-T 818-1",
|
|
51
|
+
"COL 285 SECTOR ZJ-Y B140-1",
|
|
52
|
+
"CORE SYS SECTOR DL-Y D117",
|
|
53
|
+
"CORE SYS SECTOR HH-V B2-7",
|
|
54
|
+
"CRU7CIS SECTOR EQ-Y B2",
|
|
55
|
+
"CRUCIS SECTO GB-X B1-0",
|
|
56
|
+
"CRUCIS SECTOR FM-V B2-0",
|
|
57
|
+
"CRUCIS SECTOR YE-A D142",
|
|
58
|
+
"CRUSCIC SECTOR EL-Y C19",
|
|
59
|
+
"CRUSIS SECTOR MD-S B4-3",
|
|
60
|
+
"CRUSIS SECTOR ND-S B4-1",
|
|
61
|
+
"DQ TUCANE",
|
|
62
|
+
"ED TUCANAE",
|
|
63
|
+
"FLECHS",
|
|
64
|
+
"GD 139",
|
|
65
|
+
"HYADES SECTOR WF-M B8-3",
|
|
66
|
+
"22 LYNCIS",
|
|
67
|
+
"ALANI",
|
|
68
|
+
"BODB DJEDI",
|
|
69
|
+
"DJALI",
|
|
70
|
+
"HIP 101110",
|
|
71
|
+
"NJUNG",
|
|
72
|
+
"PANTAA CEZISA",
|
|
73
|
+
"TAVYTERE",
|
|
74
|
+
"DITIBI",
|
|
75
|
+
"COL 285 SECTOR EC-R B18-5",
|
|
76
|
+
"DITIBI (FIXED)",
|
|
77
|
+
"HYADES",
|
|
78
|
+
"HAREMID",
|
|
79
|
+
"HYADES SECTOR VO-Q V5-1",
|
|
80
|
+
"XI HUGAN",
|
|
81
|
+
"LP 634-18",
|
|
82
|
+
"SHU WEI SECTOR MN-S B4-4",
|
|
83
|
+
"SHU WEI SECTOR MN-S B4-9",
|
|
84
|
+
"THETA CARINE",
|
|
85
|
+
"CORE SYS HH-M A7-3",
|
|
86
|
+
"OI-T B3-9",
|
|
87
|
+
"IDZ DL-X B1-1",
|
|
88
|
+
"PHE ZHUA",
|
|
89
|
+
"LP 937-98",
|
|
90
|
+
"WREGOE QC-X B45-2",
|
|
91
|
+
"ALRAI SECTOR JW-B A6-1",
|
|
92
|
+
"BEI DOU SECTOR JV-C B2-2",
|
|
93
|
+
"BLANCO 1 SECTOR EG-Y D8",
|
|
94
|
+
"HERCULIS SECTOR ZE-A B86",
|
|
95
|
+
"LFT 16653",
|
|
96
|
+
"LP 649-73",
|
|
97
|
+
"OMAGATE",
|
|
98
|
+
"PISCIUM SECTOR YU-Y C171",
|
|
99
|
+
"PLAA EURK AX-A B0",
|
|
100
|
+
"PRAEA EUQ GR-O B13-0",
|
|
101
|
+
"PRAEA EUQ GV-W C",
|
|
102
|
+
"PRAEA EUQ SX-U S2-18",
|
|
103
|
+
"SYNUEFAI FL-V D3-7",
|
|
104
|
+
"SYNUEFAI NM-",
|
|
105
|
+
"COL 285 SECTOR BG-Y B16-1",
|
|
106
|
+
"SYNUEFE NA-O D13-16",
|
|
107
|
+
"HIP 623536",
|
|
108
|
+
"SYNUEFUE D2-26",
|
|
109
|
+
"WREGOE AZ-D B45-4",
|
|
110
|
+
"MINIMAR",
|
|
111
|
+
"MV URSAE MAJORIS",
|
|
112
|
+
"PLAA EURK BU-Q B5-0",
|
|
113
|
+
"COL 285 SECTOR LP-S B-19-1",
|
|
114
|
+
"COL 285 SECTOR LP-S B-19-2",
|
|
115
|
+
"CORE SYS SECTOR CB-0 A6-5",
|
|
116
|
+
"ARIETIS SECTOR JD-F A12-3",
|
|
117
|
+
"ICZ-KI-S B4-3",
|
|
118
|
+
"HIP 8153",
|
|
119
|
+
"HYADES SECTOR MS-X B4-4",
|
|
120
|
+
"UCAC3 70-2386",
|
|
121
|
+
"HYADES KX-T C3-24",
|
|
122
|
+
"ICZ ZF-O B2-6",
|
|
123
|
+
"ZELAND",
|
|
124
|
+
]
|
|
125
|
+
|
|
126
|
+
class UsageError(Exception):
|
|
127
|
+
""" Raised when command line usage is invalid. """
|
|
128
|
+
pass
|
|
129
|
+
|
|
130
|
+
def parse_arguments():
|
|
131
|
+
parser = argparse.ArgumentParser(
|
|
132
|
+
description='Review and validate incoming EDSC star data. '
|
|
133
|
+
'Confirmed distances are submitted back to EDSC to '
|
|
134
|
+
'increase confidence ratings.',
|
|
135
|
+
epilog='Confirmed systems are written to tmp/new.systems.csv.',
|
|
136
|
+
)
|
|
137
|
+
parser.add_argument(
|
|
138
|
+
'refSystem',
|
|
139
|
+
help='*Exact* name of the system you are *currently* in, '
|
|
140
|
+
'used as a reference system for distance validations.',
|
|
141
|
+
type=str,
|
|
142
|
+
metavar='"REFERENCE SYSTEM"',
|
|
143
|
+
default=None,
|
|
144
|
+
nargs='?',
|
|
145
|
+
)
|
|
146
|
+
parser.add_argument(
|
|
147
|
+
'--cmdr',
|
|
148
|
+
required=False,
|
|
149
|
+
help='Specify your commander name.',
|
|
150
|
+
type=str,
|
|
151
|
+
default=os.environ.get('CMDR', None),
|
|
152
|
+
)
|
|
153
|
+
parser.add_argument(
|
|
154
|
+
'--confidence',
|
|
155
|
+
required=False,
|
|
156
|
+
help='Specify minimum confidence level.',
|
|
157
|
+
type=int,
|
|
158
|
+
default=2,
|
|
159
|
+
)
|
|
160
|
+
grp = parser.add_mutually_exclusive_group()
|
|
161
|
+
if grp: # for indentation
|
|
162
|
+
grp.add_argument(
|
|
163
|
+
'--random',
|
|
164
|
+
action='store_true',
|
|
165
|
+
required=False,
|
|
166
|
+
help='Show systems in random order, maximum of --max-systems.',
|
|
167
|
+
)
|
|
168
|
+
grp.add_argument(
|
|
169
|
+
'--distance',
|
|
170
|
+
action='store_true',
|
|
171
|
+
required=False,
|
|
172
|
+
help='Select upto 10 systems by proximity.',
|
|
173
|
+
)
|
|
174
|
+
parser.add_argument(
|
|
175
|
+
'--max-systems',
|
|
176
|
+
dest='maxSystems',
|
|
177
|
+
help='Maximum systems to query with --random/--distance.',
|
|
178
|
+
required=False,
|
|
179
|
+
type=int,
|
|
180
|
+
default=10
|
|
181
|
+
)
|
|
182
|
+
parser.add_argument(
|
|
183
|
+
'--add-to-local-db', '-A',
|
|
184
|
+
action='store_true',
|
|
185
|
+
required=False,
|
|
186
|
+
help='Add accepted systems to the local database.',
|
|
187
|
+
dest='add',
|
|
188
|
+
)
|
|
189
|
+
parser.add_argument(
|
|
190
|
+
'--test',
|
|
191
|
+
required=False,
|
|
192
|
+
help='Use the EDSC test database.',
|
|
193
|
+
action='store_true',
|
|
194
|
+
default=False,
|
|
195
|
+
)
|
|
196
|
+
parser.add_argument(
|
|
197
|
+
'--date',
|
|
198
|
+
required=False,
|
|
199
|
+
help='Use specified date (YYYY-MM-DD HH:MM:SS format) for '
|
|
200
|
+
'start of update search. '
|
|
201
|
+
'Default is to use the last System modified date.',
|
|
202
|
+
type=str,
|
|
203
|
+
default=None,
|
|
204
|
+
)
|
|
205
|
+
parser.add_argument(
|
|
206
|
+
'--no-splash', '-NS',
|
|
207
|
+
required=False,
|
|
208
|
+
action='store_false',
|
|
209
|
+
help="Don't display the 'splash' text on startup.",
|
|
210
|
+
dest='splash',
|
|
211
|
+
default=True,
|
|
212
|
+
)
|
|
213
|
+
parser.add_argument(
|
|
214
|
+
'--summary',
|
|
215
|
+
required=False,
|
|
216
|
+
help='Check for and report on new systems but do no work.',
|
|
217
|
+
action='store_true',
|
|
218
|
+
)
|
|
219
|
+
parser.add_argument(
|
|
220
|
+
'--detail', '-v',
|
|
221
|
+
help='Increase level of detail in output.',
|
|
222
|
+
default=0,
|
|
223
|
+
required=False,
|
|
224
|
+
action='count',
|
|
225
|
+
)
|
|
226
|
+
parser.add_argument(
|
|
227
|
+
'--debug', '-w',
|
|
228
|
+
help='Enable/raise level of diagnostic output.',
|
|
229
|
+
default=0,
|
|
230
|
+
required=False,
|
|
231
|
+
action='count',
|
|
232
|
+
)
|
|
233
|
+
parser.add_argument(
|
|
234
|
+
'--ref',
|
|
235
|
+
help='Reference system (for --distance).',
|
|
236
|
+
default=None,
|
|
237
|
+
dest='refSys',
|
|
238
|
+
type=str,
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
argv = parser.parse_args(sys.argv[1:])
|
|
242
|
+
dateRe = re.compile(r'^20\d\d-(0\d|1[012])-([012]\d|3[01]) ([01]\d|2[0123]):[0-5]\d:[0-5]\d$')
|
|
243
|
+
if not argv.summary:
|
|
244
|
+
if not argv.cmdr:
|
|
245
|
+
raise UsageError("No --cmdr specified / no CMDR environment variable")
|
|
246
|
+
if not argv.refSystem:
|
|
247
|
+
raise UsageError(
|
|
248
|
+
"Must specify a reference system name (when not using "
|
|
249
|
+
"--summary). Be sure to put the name in double quotes, "
|
|
250
|
+
"e.g. \"SOL\" or \"I BOOTIS\".\n"
|
|
251
|
+
)
|
|
252
|
+
if not argv.date:
|
|
253
|
+
argv.date = DEFAULT_DATE
|
|
254
|
+
if not dateRe.match(argv.date):
|
|
255
|
+
raise UsageError(
|
|
256
|
+
"Invalid date: '{}', expecting YYYY-MM-DD HH:MM:SS format."
|
|
257
|
+
.format(argv.date)
|
|
258
|
+
)
|
|
259
|
+
if not argv.distance and argv.refSys:
|
|
260
|
+
raise UsageError("--ref requires --distance")
|
|
261
|
+
|
|
262
|
+
return argv
|
|
263
|
+
|
|
264
|
+
def is_change(tdb, sysinfo):
|
|
265
|
+
""" Check if a system's EDSC data is different than TDs """
|
|
266
|
+
name = sysinfo['name'] = sysinfo['name'].upper()
|
|
267
|
+
if name.startswith("PLAA EURIK"):
|
|
268
|
+
return False
|
|
269
|
+
if name in ignore:
|
|
270
|
+
return False
|
|
271
|
+
try:
|
|
272
|
+
x, y, z = sysinfo['coord']
|
|
273
|
+
place = tdb.systemByName[name]
|
|
274
|
+
if place.posX == x and place.posY == y and place.posZ == z:
|
|
275
|
+
return False
|
|
276
|
+
except KeyError:
|
|
277
|
+
place = None
|
|
278
|
+
sysinfo['place'] = place
|
|
279
|
+
return True
|
|
280
|
+
|
|
281
|
+
def has_position_changed(place, name, x, y, z):
|
|
282
|
+
if not place:
|
|
283
|
+
return False
|
|
284
|
+
|
|
285
|
+
print("! @{} [{},{},{}] changed to @{} [{},{},{}]".format(
|
|
286
|
+
name, x, y, z,
|
|
287
|
+
place.dbname, place.posX, place.posY, place.posZ
|
|
288
|
+
))
|
|
289
|
+
|
|
290
|
+
return True
|
|
291
|
+
|
|
292
|
+
def check_database(tdb, name, x, y, z):
|
|
293
|
+
# is it in the database?
|
|
294
|
+
cur = tdb.query("""
|
|
295
|
+
SELECT name, pos_x, pos_y, pos_z
|
|
296
|
+
FROM System
|
|
297
|
+
WHERE pos_x BETWEEN ? and ?
|
|
298
|
+
AND pos_y BETWEEN ? and ?
|
|
299
|
+
AND pos_z BETWEEN ? and ?
|
|
300
|
+
""", [
|
|
301
|
+
x - 0.5, x + 0.5,
|
|
302
|
+
y - 0.5, y + 0.5,
|
|
303
|
+
z - 0.5, z + 0.5,
|
|
304
|
+
])
|
|
305
|
+
for mname, mx, my, mz in cur:
|
|
306
|
+
print(
|
|
307
|
+
"! @{} [{},{},{}] matches coords for "
|
|
308
|
+
"@{} [{},{},{}]".format(
|
|
309
|
+
name, x, y, z,
|
|
310
|
+
mname, mx, my, mz
|
|
311
|
+
), file=sys.stderr)
|
|
312
|
+
|
|
313
|
+
def get_distance(tdb, startSys, x, y, z):
|
|
314
|
+
distance = tdb.calculateDistance(
|
|
315
|
+
startSys.posX, startSys.posY, startSys.posZ,
|
|
316
|
+
x, y, z
|
|
317
|
+
)
|
|
318
|
+
return float("{:.2f}".format(distance))
|
|
319
|
+
|
|
320
|
+
def submit_distance(argv, name, distance, refSys=None, refDist=None):
|
|
321
|
+
p0 = name.upper()
|
|
322
|
+
ref = argv.startSys.name().upper()
|
|
323
|
+
print("Sending: {}->{}: {}ly by {}".format(
|
|
324
|
+
p0, ref, distance, argv.cmdr
|
|
325
|
+
))
|
|
326
|
+
sub = misc.edsc.StarSubmission(
|
|
327
|
+
star=p0,
|
|
328
|
+
distances={ref: distance},
|
|
329
|
+
commander=argv.cmdr,
|
|
330
|
+
test=argv.test,
|
|
331
|
+
)
|
|
332
|
+
if refSys and refDist:
|
|
333
|
+
if isinstance(refSys, tradedb.System):
|
|
334
|
+
refName = refSys.name()
|
|
335
|
+
else:
|
|
336
|
+
refName = refSys
|
|
337
|
+
sub.add_distance(refName, refDist)
|
|
338
|
+
r = sub.submit()
|
|
339
|
+
result = misc.edsc.StarSubmissionResult(
|
|
340
|
+
star=name.upper(),
|
|
341
|
+
response=r,
|
|
342
|
+
)
|
|
343
|
+
print(str(result))
|
|
344
|
+
|
|
345
|
+
def get_extras():
|
|
346
|
+
extras = set()
|
|
347
|
+
try:
|
|
348
|
+
with open("data/extra-stars.txt", "r", encoding="utf-8") as fh:
|
|
349
|
+
for line in fh:
|
|
350
|
+
name = line.partition('#')[0].strip().upper()
|
|
351
|
+
if name:
|
|
352
|
+
extras.add(name)
|
|
353
|
+
except FileNotFoundError:
|
|
354
|
+
pass
|
|
355
|
+
return extras
|
|
356
|
+
|
|
357
|
+
def add_to_extras(argv, name):
|
|
358
|
+
with open("data/extra-stars.txt", "a", encoding="utf-8") as fh:
|
|
359
|
+
print(name.upper(), file=fh)
|
|
360
|
+
print("Added {} to data/extra-stars.txt".format(name))
|
|
361
|
+
|
|
362
|
+
def main():
|
|
363
|
+
argv = parse_arguments()
|
|
364
|
+
tdenv = tradeenv.TradeEnv(properties=argv)
|
|
365
|
+
tdb = tradedb.TradeDB(tdenv)
|
|
366
|
+
|
|
367
|
+
if not argv.summary:
|
|
368
|
+
try:
|
|
369
|
+
argv.startSys = tdb.lookupSystem(argv.refSystem)
|
|
370
|
+
except (LookupError, tradedb.AmbiguityError):
|
|
371
|
+
raise UsageError(
|
|
372
|
+
"Unrecognized system '{}'. Reference System must be an "
|
|
373
|
+
"*exact* name for a system that TD already knows.\n"
|
|
374
|
+
"Did you forget to put double-quotes around the reference "
|
|
375
|
+
"system name?"
|
|
376
|
+
.format(argv.refSystem)
|
|
377
|
+
)
|
|
378
|
+
|
|
379
|
+
print("start date: {}".format(argv.date))
|
|
380
|
+
|
|
381
|
+
edsq = misc.edsc.StarQuery(
|
|
382
|
+
test=argv.test,
|
|
383
|
+
confidence=argv.confidence,
|
|
384
|
+
date=argv.date,
|
|
385
|
+
)
|
|
386
|
+
data = edsq.fetch()
|
|
387
|
+
|
|
388
|
+
if edsq.status['statusnum'] != 0:
|
|
389
|
+
raise Exception("Query failed: {} ({})".format(
|
|
390
|
+
edsq.status['msg'],
|
|
391
|
+
edsq.status['statusnum'],
|
|
392
|
+
))
|
|
393
|
+
|
|
394
|
+
systems = data['systems']
|
|
395
|
+
print("{} results".format(len(systems)))
|
|
396
|
+
# Filter out systems we already know that match the EDSC data.
|
|
397
|
+
systems = [
|
|
398
|
+
sysinfo for sysinfo in systems if is_change(tdb, sysinfo)
|
|
399
|
+
]
|
|
400
|
+
print("{} deltas".format(len(systems)))
|
|
401
|
+
|
|
402
|
+
if argv.summary or len(systems) <= 0:
|
|
403
|
+
return
|
|
404
|
+
|
|
405
|
+
systems = [
|
|
406
|
+
sysinfo for sysinfo in systems if 'coord' in sysinfo
|
|
407
|
+
]
|
|
408
|
+
|
|
409
|
+
if argv.random:
|
|
410
|
+
num = min(len(systems), argv.maxSystems)
|
|
411
|
+
systems = random.sample(systems, num)
|
|
412
|
+
|
|
413
|
+
if argv.refSys:
|
|
414
|
+
refSys = tdb.lookupPlace(argv.refSys)
|
|
415
|
+
else:
|
|
416
|
+
refSys = None
|
|
417
|
+
startSys = argv.startSys
|
|
418
|
+
for sysinfo in systems:
|
|
419
|
+
x, y, z = sysinfo['coord']
|
|
420
|
+
sysinfo['distance'] = get_distance(tdb, startSys, x, y, z)
|
|
421
|
+
if refSys:
|
|
422
|
+
sysinfo['refdist'] = get_distance(tdb, refSys, x, y, z)
|
|
423
|
+
else:
|
|
424
|
+
sysinfo['refdist'] = None
|
|
425
|
+
|
|
426
|
+
if argv.distance:
|
|
427
|
+
if refSys:
|
|
428
|
+
systems.sort(key=lambda sysinfo: sysinfo['refdist'])
|
|
429
|
+
else:
|
|
430
|
+
systems.sort(key=lambda sysinfo: sysinfo['distance'])
|
|
431
|
+
systems = systems[:argv.maxSystems]
|
|
432
|
+
|
|
433
|
+
if argv.splash:
|
|
434
|
+
print(
|
|
435
|
+
"\n"
|
|
436
|
+
"===============================================================\n"
|
|
437
|
+
"\n"
|
|
438
|
+
" The tool will now take you through the stars returned by EDSC\n"
|
|
439
|
+
" that are new or different from your local System.csv.\n"
|
|
440
|
+
"\n"
|
|
441
|
+
" You will be prompted with the name and predicted distance from\n"
|
|
442
|
+
" your current system so you can check for mistakes.\n"
|
|
443
|
+
"\n"
|
|
444
|
+
" The name will be copied into your clipboard so you can alt-tab\n"
|
|
445
|
+
" into the game and paste the name into the Galaxy Map's SEARCH\n"
|
|
446
|
+
" box (under NAVIGATION). Let the map zoom to the system.\n"
|
|
447
|
+
"\n"
|
|
448
|
+
" Check the name and distance, then use the appropriate action.\n"
|
|
449
|
+
"\n"
|
|
450
|
+
" (Use the -NS option to skip this text in future)\n"
|
|
451
|
+
"\n"
|
|
452
|
+
"===============================================================\n"
|
|
453
|
+
"\n"
|
|
454
|
+
)
|
|
455
|
+
|
|
456
|
+
input("Hit enter to continue: ")
|
|
457
|
+
|
|
458
|
+
print("""At the prompt enter:
|
|
459
|
+
q
|
|
460
|
+
to indicate you've suffered enough,
|
|
461
|
+
y
|
|
462
|
+
to accept the name/value and confirm with EDSC,
|
|
463
|
+
n (or anything else)
|
|
464
|
+
to skip the name/value (no confirmation),
|
|
465
|
+
=name (e.g. =SOL)
|
|
466
|
+
to accept the distance but correct spelling,
|
|
467
|
+
~dist (e.g. ~104.49)
|
|
468
|
+
to submit a distance correction for the system,
|
|
469
|
+
""")
|
|
470
|
+
print()
|
|
471
|
+
|
|
472
|
+
extras = get_extras()
|
|
473
|
+
|
|
474
|
+
clip = misc.clipboard.SystemNameClip()
|
|
475
|
+
total = len(systems)
|
|
476
|
+
current = 0
|
|
477
|
+
with open("tmp/new.systems.csv", "w", encoding="utf-8") as output:
|
|
478
|
+
for sysinfo in systems:
|
|
479
|
+
current += 1
|
|
480
|
+
name = sysinfo['name']
|
|
481
|
+
created = sysinfo['createdate']
|
|
482
|
+
x, y, z = sysinfo['coord']
|
|
483
|
+
|
|
484
|
+
print(
|
|
485
|
+
"\n"
|
|
486
|
+
"-----------------------------------------------\n"
|
|
487
|
+
"{syidlab:.<12}: {syid}\n"
|
|
488
|
+
"{conflab:.<12}: {conf}\n"
|
|
489
|
+
"{crealab:.<12}: {crcm} {crts}\n"
|
|
490
|
+
"{updtlab:.<12}: {upcm} {upts}\n"
|
|
491
|
+
.format(
|
|
492
|
+
syidlab="ID",
|
|
493
|
+
conflab="Confidence",
|
|
494
|
+
crealab="Created",
|
|
495
|
+
updtlab="Updated",
|
|
496
|
+
syid=sysinfo['id'],
|
|
497
|
+
conf=sysinfo['cr'],
|
|
498
|
+
crcm=sysinfo['commandercreate'],
|
|
499
|
+
crts=created,
|
|
500
|
+
upcm=sysinfo.get('commanderupdate', '[never]'),
|
|
501
|
+
upts=sysinfo.get('updatedate', ''),
|
|
502
|
+
)
|
|
503
|
+
)
|
|
504
|
+
if refSys:
|
|
505
|
+
print("{reflab:.<12}: {refdist}ly\n".format(
|
|
506
|
+
reflab="Ref Dist",
|
|
507
|
+
refdist=sysinfo['refdist'],
|
|
508
|
+
))
|
|
509
|
+
|
|
510
|
+
check_database(tdb, name, x, y, z)
|
|
511
|
+
|
|
512
|
+
change = has_position_changed(sysinfo['place'], name, x, y, z)
|
|
513
|
+
if change:
|
|
514
|
+
oldDist = startSys.distanceTo(sysinfo['place'])
|
|
515
|
+
print("Old Distance: {:.2f}ly".format(oldDist))
|
|
516
|
+
|
|
517
|
+
distance = sysinfo['distance']
|
|
518
|
+
clip.copy_text(name)
|
|
519
|
+
prompt = "{}/{}: '{}': {:.2f}ly? ".format(
|
|
520
|
+
current, total,
|
|
521
|
+
name,
|
|
522
|
+
distance,
|
|
523
|
+
)
|
|
524
|
+
ok = input(prompt)
|
|
525
|
+
if ok.lower() == 'q':
|
|
526
|
+
break
|
|
527
|
+
if ok.startswith('~'):
|
|
528
|
+
correction = float(ok[1:])
|
|
529
|
+
submit_distance(argv, name, correction)
|
|
530
|
+
if name.upper() not in extras:
|
|
531
|
+
add_to_extras(argv, name)
|
|
532
|
+
continue
|
|
533
|
+
if ok.startswith('='):
|
|
534
|
+
name = ok[1:].strip().upper()
|
|
535
|
+
if name not in extras:
|
|
536
|
+
add_to_extras(argv, name)
|
|
537
|
+
ok = 'y'
|
|
538
|
+
if ok.lower() != 'y':
|
|
539
|
+
continue
|
|
540
|
+
|
|
541
|
+
if argv.add:
|
|
542
|
+
tdb.addLocalSystem(
|
|
543
|
+
name,
|
|
544
|
+
x, y, z,
|
|
545
|
+
added='Release 1.00-EDStar',
|
|
546
|
+
modified=created,
|
|
547
|
+
commit=True
|
|
548
|
+
)
|
|
549
|
+
|
|
550
|
+
print("'{}',{},{},{},'Release 1.00-EDStar','{}'".format(
|
|
551
|
+
name, x, y, z, created,
|
|
552
|
+
), file=output)
|
|
553
|
+
|
|
554
|
+
submit_distance(argv, name, distance)
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
if __name__ == "__main__":
|
|
558
|
+
try:
|
|
559
|
+
main()
|
|
560
|
+
except KeyboardInterrupt:
|
|
561
|
+
print("^C")
|
|
562
|
+
except UsageError as e:
|
|
563
|
+
print("ERROR: {}\nSee {} --help for usage help.".format(
|
|
564
|
+
str(e), sys.argv[0]
|
|
565
|
+
))
|