tradedangerous 10.16.17__py3-none-any.whl → 11.0.0__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.

Files changed (74) hide show
  1. tradedangerous/__init__.py +4 -4
  2. tradedangerous/cache.py +183 -148
  3. tradedangerous/cli.py +2 -7
  4. tradedangerous/commands/TEMPLATE.py +1 -2
  5. tradedangerous/commands/__init__.py +2 -4
  6. tradedangerous/commands/buildcache_cmd.py +6 -11
  7. tradedangerous/commands/buy_cmd.py +11 -12
  8. tradedangerous/commands/commandenv.py +16 -15
  9. tradedangerous/commands/exceptions.py +6 -4
  10. tradedangerous/commands/export_cmd.py +2 -4
  11. tradedangerous/commands/import_cmd.py +3 -5
  12. tradedangerous/commands/local_cmd.py +16 -25
  13. tradedangerous/commands/market_cmd.py +9 -8
  14. tradedangerous/commands/nav_cmd.py +17 -25
  15. tradedangerous/commands/olddata_cmd.py +9 -15
  16. tradedangerous/commands/parsing.py +9 -6
  17. tradedangerous/commands/rares_cmd.py +9 -10
  18. tradedangerous/commands/run_cmd.py +25 -26
  19. tradedangerous/commands/sell_cmd.py +9 -9
  20. tradedangerous/commands/shipvendor_cmd.py +4 -7
  21. tradedangerous/commands/station_cmd.py +8 -14
  22. tradedangerous/commands/trade_cmd.py +5 -10
  23. tradedangerous/commands/update_cmd.py +10 -7
  24. tradedangerous/commands/update_gui.py +1 -3
  25. tradedangerous/corrections.py +1 -3
  26. tradedangerous/csvexport.py +8 -8
  27. tradedangerous/edscupdate.py +4 -6
  28. tradedangerous/edsmupdate.py +4 -4
  29. tradedangerous/formatting.py +53 -40
  30. tradedangerous/fs.py +6 -6
  31. tradedangerous/gui.py +53 -62
  32. tradedangerous/jsonprices.py +8 -16
  33. tradedangerous/mapping.py +4 -3
  34. tradedangerous/mfd/__init__.py +2 -4
  35. tradedangerous/mfd/saitek/__init__.py +0 -1
  36. tradedangerous/mfd/saitek/directoutput.py +8 -11
  37. tradedangerous/mfd/saitek/x52pro.py +5 -7
  38. tradedangerous/misc/checkpricebounds.py +2 -3
  39. tradedangerous/misc/clipboard.py +2 -3
  40. tradedangerous/misc/coord64.py +2 -1
  41. tradedangerous/misc/derp-sentinel.py +1 -1
  42. tradedangerous/misc/diff-system-csvs.py +3 -0
  43. tradedangerous/misc/eddb.py +1 -3
  44. tradedangerous/misc/eddn.py +2 -2
  45. tradedangerous/misc/edsc.py +7 -14
  46. tradedangerous/misc/edsm.py +1 -8
  47. tradedangerous/misc/importeddbstats.py +2 -1
  48. tradedangerous/misc/prices-json-exp.py +7 -5
  49. tradedangerous/misc/progress.py +2 -2
  50. tradedangerous/plugins/__init__.py +2 -2
  51. tradedangerous/plugins/edapi_plug.py +13 -19
  52. tradedangerous/plugins/edcd_plug.py +4 -5
  53. tradedangerous/plugins/eddblink_plug.py +14 -17
  54. tradedangerous/plugins/edmc_batch_plug.py +3 -5
  55. tradedangerous/plugins/journal_plug.py +2 -1
  56. tradedangerous/plugins/netlog_plug.py +5 -5
  57. tradedangerous/plugins/spansh_plug.py +393 -176
  58. tradedangerous/prices.py +19 -20
  59. tradedangerous/submit-distances.py +3 -8
  60. tradedangerous/templates/TradeDangerous.sql +305 -306
  61. tradedangerous/trade.py +12 -5
  62. tradedangerous/tradecalc.py +30 -34
  63. tradedangerous/tradedb.py +140 -206
  64. tradedangerous/tradeenv.py +143 -69
  65. tradedangerous/tradegui.py +4 -2
  66. tradedangerous/transfers.py +23 -20
  67. tradedangerous/version.py +1 -1
  68. {tradedangerous-10.16.17.dist-info → tradedangerous-11.0.0.dist-info}/METADATA +2 -2
  69. tradedangerous-11.0.0.dist-info/RECORD +79 -0
  70. tradedangerous-10.16.17.dist-info/RECORD +0 -79
  71. {tradedangerous-10.16.17.dist-info → tradedangerous-11.0.0.dist-info}/LICENSE +0 -0
  72. {tradedangerous-10.16.17.dist-info → tradedangerous-11.0.0.dist-info}/WHEEL +0 -0
  73. {tradedangerous-10.16.17.dist-info → tradedangerous-11.0.0.dist-info}/entry_points.txt +0 -0
  74. {tradedangerous-10.16.17.dist-info → tradedangerous-11.0.0.dist-info}/top_level.txt +0 -0
@@ -60,8 +60,6 @@ DirectOutput_CloseServer
60
60
 
61
61
  """
62
62
 
63
- from __future__ import absolute_import, with_statement, print_function, division, unicode_literals
64
-
65
63
  from tradedangerous.mfd import MissingDeviceError
66
64
 
67
65
  import ctypes
@@ -69,6 +67,8 @@ import ctypes.wintypes
69
67
  import logging
70
68
  import os
71
69
  import platform
70
+ import sys
71
+ import time
72
72
 
73
73
  S_OK = 0x00000000
74
74
  E_HANDLE = 0x80070006
@@ -84,8 +84,7 @@ SOFTBUTTON_UP = 0x00000002
84
84
  SOFTBUTTON_DOWN = 0x00000004
85
85
 
86
86
 
87
- class DirectOutput(object):
88
-
87
+ class DirectOutput:
89
88
  def __init__(self, dll_path):
90
89
  """
91
90
  Creates python object to interact with DirecOutput.dll
@@ -165,7 +164,7 @@ class DirectOutput(object):
165
164
  S_OK: The call completed successfully.
166
165
  E_HANDLE: The device handle specified is invalid.
167
166
  """
168
-
167
+
169
168
  logging.debug("DirectOutput.RegisterSoftButtonCallback({}, {})".format(device_handle, function))
170
169
  return self.DirectOutputDLL.DirectOutput_RegisterSoftButtonCallback(ctypes.wintypes.HANDLE(device_handle), function, 0)
171
170
 
@@ -276,9 +275,9 @@ class DirectOutput(object):
276
275
  return self.DirectOutputDLL.DirectOutput_SetString(ctypes.wintypes.HANDLE(device_handle), page, line, len(string), ctypes.wintypes.LPWSTR(string))
277
276
 
278
277
 
279
- class DirectOutputDevice(object):
278
+ class DirectOutputDevice:
280
279
 
281
- class Buttons(object):
280
+ class Buttons:
282
281
 
283
282
  select, up, down = False, False, False
284
283
 
@@ -658,8 +657,6 @@ if __name__ == '__main__':
658
657
  # logging.basicConfig(level=logging.INFO, format='%(asctime)s %(name)s [%(filename)s:%(lineno)d] %(message)s')
659
658
  logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)s [%(filename)s:%(lineno)d] %(message)s')
660
659
 
661
- import time, sys
662
-
663
660
  device = DirectOutputDevice(debug_level=1)
664
661
  print("Device initialized")
665
662
 
@@ -675,7 +672,7 @@ if __name__ == '__main__':
675
672
  while True:
676
673
  try:
677
674
  time.sleep(1)
678
- except:
679
- #This is used to catch Ctrl+C, calling finish method is *very* important to de-initalize device.
675
+ except: # noqa: E722
676
+ # This is used to catch Ctrl+C, calling finish method is *very* important to de-initalize device.
680
677
  device.finish()
681
678
  sys.exit()
@@ -13,13 +13,14 @@ TODO:
13
13
  * Error handling and exceptions
14
14
  """
15
15
 
16
- from __future__ import absolute_import, with_statement, print_function, division, unicode_literals
17
-
18
16
  from tradedangerous.mfd.saitek.directoutput import DirectOutputDevice
19
17
 
18
+ import sys
19
+ import time
20
+
20
21
 
21
22
  class X52Pro(DirectOutputDevice):
22
- class Page(object):
23
+ class Page:
23
24
  _lines = [ str(), str(), str() ]
24
25
  _leds = dict()
25
26
 
@@ -45,7 +46,7 @@ class X52Pro(DirectOutputDevice):
45
46
  self.device.SetString(self.page_id, key, value)
46
47
 
47
48
  def activate(self):
48
- if self.active == True:
49
+ if self.active is True:
49
50
  return
50
51
  self.device.AddPage(self.page_id, self.name, 1)
51
52
 
@@ -172,8 +173,6 @@ if __name__ == '__main__':
172
173
 
173
174
  print("Looping")
174
175
 
175
- import time, sys
176
-
177
176
  loopNo = 0
178
177
  while True:
179
178
  try:
@@ -194,4 +193,3 @@ if __name__ == '__main__':
194
193
  print(e)
195
194
  x52.finish()
196
195
  sys.exit()
197
-
@@ -143,7 +143,7 @@ def check_price_bounds(
143
143
  if stations:
144
144
  print()
145
145
  print("Generating", deletePrices)
146
- now = tdb.query("SELECT CURRENT_TIMESTAMP").fetchone()[0];
146
+ now = tdb.query("SELECT CURRENT_TIMESTAMP").fetchone()[0]
147
147
  with open(deletePrices, "w", encoding="utf-8") as fh:
148
148
  print("# Deletions based on {} prices".format(
149
149
  table,
@@ -175,8 +175,6 @@ def check_price_bounds(
175
175
  db.commit()
176
176
 
177
177
  def main():
178
- doDeletions = False
179
-
180
178
  parser = argparse.ArgumentParser(
181
179
  description='Check for prices that are outside reasonable bounds.'
182
180
  )
@@ -284,5 +282,6 @@ def main():
284
282
  errorFilter=errorFilter,
285
283
  )
286
284
 
285
+
287
286
  if __name__ == "__main__":
288
287
  main()
@@ -8,7 +8,7 @@ if 'NOTK' not in os.environ:
8
8
  try:
9
9
  from tkinter import Tk
10
10
 
11
- class SystemNameClip(object):
11
+ class SystemNameClip:
12
12
  """
13
13
  A cross-platform wrapper for copying system names into
14
14
  the clipboard such that they can be pasted into the E:D
@@ -41,10 +41,9 @@ if 'NOTK' not in os.environ:
41
41
  "Set the environment variable 'NOTK' to disable this warning."
42
42
  )
43
43
 
44
- class SystemNameClip(object):
44
+ class SystemNameClip:
45
45
  """
46
46
  Dummy implementation when tkinter is not available.
47
47
  """
48
48
  def copy_text(self, text):
49
49
  pass
50
-
@@ -17,12 +17,13 @@
17
17
  # Original Author: Oliver "kfsone" Smith <oliver@kfs.org>
18
18
  # Released under the "use it with attribution" license.
19
19
 
20
- from __future__ import print_function, division
21
20
  import string
22
21
 
22
+
23
23
  alphabet = string.digits + string.ascii_lowercase + string.ascii_uppercase + '_.'
24
24
  precision = 100.
25
25
 
26
+
26
27
  def coord_to_d64(coord):
27
28
  i = int(abs(coord * precision))
28
29
 
@@ -28,8 +28,8 @@ def mutate(text, pos):
28
28
  yield t2
29
29
  yield from mutate(str(t2), i+len(mutant))
30
30
 
31
+
31
32
  for name in names:
32
33
  for mutant in mutate(name, 0):
33
34
  if mutant in names:
34
35
  print("{} <-> {}".format(name, mutant))
35
-
@@ -29,8 +29,10 @@ class Loc(namedtuple('Loc', [ 'x', 'y', 'z' ])):
29
29
  class Item(namedtuple('Item', [ 'norm', 'name', 'loc' ])):
30
30
  pass
31
31
 
32
+
32
33
  normalizeRe = re.compile('[^A-Za-z0-9\' ]')
33
34
 
35
+
34
36
  def readFile(filename):
35
37
  path = Path(filename)
36
38
  if not path.exists():
@@ -71,6 +73,7 @@ def readFile(filename):
71
73
 
72
74
  return names, locs
73
75
 
76
+
74
77
  oldNames, oldLocs = readFile(sys.argv[1])
75
78
  newNames, newLocs = readFile(sys.argv[2])
76
79
 
@@ -11,8 +11,6 @@ Example:
11
11
  Original author: oliver@kfs.org
12
12
  """
13
13
 
14
- import json
15
- import sys
16
14
  import transfers
17
15
 
18
16
  BASE_URL = "http://eddb.io/archive/v3/"
@@ -22,7 +20,7 @@ STATIONS_EXT_JSON = BASE_URL + "stations.json"
22
20
  STATIONS_LITE_JSON = BASE_URL + "stations_lite.json"
23
21
 
24
22
 
25
- class EDDBQuery(object):
23
+ class EDDBQuery:
26
24
  """
27
25
  Base class for querying an EDDB data set and converting the
28
26
  JSON results into an iterable stream.
@@ -86,12 +86,12 @@ class MarketPrice(namedtuple('MarketPrice', [
86
86
  pass
87
87
 
88
88
 
89
- class Listener(object):
89
+ class Listener:
90
90
  """
91
91
  Provides an object that will listen to the Elite Dangerous Data Network
92
92
  firehose and capture messages for later consumption.
93
93
 
94
- Rather than individual upates, prices are captured across a window of
94
+ Rather than individual updates, prices are captured across a window of
95
95
  between minBatchTime and maxBatchTime. When a new update is received,
96
96
  Rather than returning individual messages, messages are captured across
97
97
  a window of potentially several seconds and returned to the caller in
@@ -1,17 +1,9 @@
1
1
  #! /usr/bin/env python3
2
2
 
3
- from __future__ import absolute_import
4
- from __future__ import with_statement
5
- from __future__ import print_function
6
- from __future__ import division
7
- from __future__ import unicode_literals
8
-
9
- from collections import defaultdict, namedtuple
10
- from urllib.parse import urlencode
3
+ from collections import namedtuple
11
4
  from urllib.request import Request, urlopen
12
5
 
13
6
  import json
14
- import os
15
7
 
16
8
  try:
17
9
  import requests
@@ -45,7 +37,7 @@ def edsc_log(apiCall, params, jsonData=None, error=None):
45
37
  pass
46
38
 
47
39
 
48
- class EDSCQueryBase(object):
40
+ class EDSCQueryBase:
49
41
  """
50
42
  Base class for creating an EDSC Query class, do not use directly.
51
43
 
@@ -116,7 +108,7 @@ class Status(namedtuple('Status', [
116
108
  ])):
117
109
  pass
118
110
 
119
- class StarSubmissionResult(object):
111
+ class StarSubmissionResult:
120
112
  """
121
113
  Translates a response the json we get back from EDSC when
122
114
  we submit a StarSubmission into something less awful to
@@ -228,7 +220,7 @@ class StarSubmissionResult(object):
228
220
  code = int(ent['status']['statusnum'])
229
221
  msg = ent['status']['msg']
230
222
  if code in [301, 302, 303, 304]:
231
- if not lhsName in self.distances:
223
+ if lhsName not in self.distances:
232
224
  self.distances[lhsName] = {}
233
225
  try:
234
226
  rhsDists = self.distances[rhsName]
@@ -238,7 +230,7 @@ class StarSubmissionResult(object):
238
230
  pass
239
231
  dist = float(ent['dist'])
240
232
  self.distances[lhsName][rhsName] = dist
241
- if not lhsName in self.systems:
233
+ if lhsName not in self.systems:
242
234
  self.systems[lhsName] = (code, None)
243
235
  else:
244
236
  if (lhsName,rhsName,code) in errPairs:
@@ -335,7 +327,7 @@ class StarSubmissionResult(object):
335
327
 
336
328
 
337
329
 
338
- class StarSubmission(object):
330
+ class StarSubmission:
339
331
  baseURL = "http://edstarcoordinator.com/api.asmx/"
340
332
  apiCall = "SubmitDistances"
341
333
 
@@ -431,6 +423,7 @@ class StarSubmission(object):
431
423
 
432
424
  return innerData
433
425
 
426
+
434
427
  if __name__ == "__main__":
435
428
  print("Requesting recent, non-test, coords-known, cr >= 2 stars")
436
429
  edsq = StarQuery(test=False, confidence=2, known=1)
@@ -5,14 +5,7 @@ based on edsc.py
5
5
  uses EDSM - https://www.edsm.net/api
6
6
  """
7
7
 
8
- from __future__ import absolute_import
9
- from __future__ import with_statement
10
- from __future__ import print_function
11
- from __future__ import division
12
- from __future__ import unicode_literals
13
-
14
8
  import json
15
- import os
16
9
 
17
10
  try:
18
11
  import requests
@@ -47,7 +40,7 @@ def edsm_log(apiCall, url, params, jsonData=None, error=None):
47
40
  pass
48
41
 
49
42
 
50
- class EDSMQueryBase(object):
43
+ class EDSMQueryBase:
51
44
  """
52
45
  Base class for creating an EDSM Query class, do not use directly.
53
46
 
@@ -24,6 +24,7 @@ def matching_stations():
24
24
  if tdStn:
25
25
  yield tdStn, eddbStn
26
26
 
27
+
27
28
  updateStation = tdb.updateLocalStation
28
29
 
29
30
  bool_trans = { None: '?', 0: 'N', 1: 'Y' }
@@ -50,4 +51,4 @@ for tdStn, eddbStn in matching_stations():
50
51
  if updates:
51
52
  tdb.getDB().commit()
52
53
  csvexport.exportTableToFile(tdb, tdb.tdenv, "Station")
53
- print("Updated Station.csv: {} updates".format(updates))
54
+ print("Updated Station.csv: {} updates".format(updates))
@@ -2,19 +2,21 @@
2
2
 
3
3
  # Experimental module to generate a JSON version of the .prices file.
4
4
 
5
- # Set to True to allow export of systems that don't have any station data
6
- emptySystems = True
7
- # Set to True to allow export of stations that don't have prices
8
- emptyStations = True
9
-
10
5
  import sqlite3
11
6
  import json
12
7
  import time
13
8
  import collections
14
9
  import os
15
10
 
11
+
12
+ # Set to True to allow export of systems that don't have any station data
13
+ emptySystems = True
14
+ # Set to True to allow export of stations that don't have prices
15
+ emptyStations = True
16
+
16
17
  conn = sqlite3.connect("data/TradeDangerous.db")
17
18
 
19
+
18
20
  def collectItemData(db):
19
21
  """
20
22
  Builds a flat, array of item names that serves as a table of items.
@@ -1,6 +1,6 @@
1
1
  import sys
2
2
 
3
- class Progress(object):
3
+ class Progress:
4
4
  """
5
5
  Helper class that describes a simple text-based progress bar.
6
6
  """
@@ -68,4 +68,4 @@ class Progress(object):
68
68
  if self.textLen:
69
69
  fin = "\r{:{width}}\r".format('', width=self.textLen)
70
70
  sys.stdout.write(fin)
71
- sys.stdout.flush()
71
+ sys.stdout.flush()
@@ -10,7 +10,7 @@ class PluginException(Exception):
10
10
  """
11
11
 
12
12
 
13
- class PluginBase(object):
13
+ class PluginBase:
14
14
  """
15
15
  Base class for plugin implementation.
16
16
 
@@ -49,7 +49,7 @@ class PluginBase(object):
49
49
  else:
50
50
  key, value = opt[:equals], opt[equals+1:]
51
51
  keyName = key.lower()
52
- if not keyName in pluginOptions:
52
+ if keyName not in pluginOptions:
53
53
  if keyName == "help":
54
54
  raise SystemExit(self.usage())
55
55
 
@@ -61,8 +61,7 @@ class OAuthCallbackHandler(BaseHTTPRequestHandler):
61
61
  pass
62
62
 
63
63
 
64
- class OAuthCallbackServer(object):
65
-
64
+ class OAuthCallbackServer:
66
65
  def __init__(self, hostname, port, handler):
67
66
  myServer = HTTPServer
68
67
  myServer.callback_code = None
@@ -136,8 +135,11 @@ class EDAPI:
136
135
  # Grab the commander profile
137
136
  self.text = []
138
137
  self.profile = self.query_capi("/profile")
139
- market = self.query_capi("/market")
140
- shipyard = self.query_capi("/shipyard")
138
+
139
+ # kfsone: not sure if there was a reason to query these even tho we didn't
140
+ # use the resulting data.
141
+ # market = self.query_capi("/market")
142
+ # shipyard = self.query_capi("/shipyard")
141
143
 
142
144
  # Grab the market, outfitting and shipyard data if needed
143
145
  portServices = self.profile['lastStarport'].get('services')
@@ -503,7 +505,8 @@ class ImportPlugin(plugins.ImportPluginBase):
503
505
 
504
506
  def warnAPIResponse(checkName, checkYN):
505
507
  # no warning if unknown
506
- if checkYN == "?": return False
508
+ if checkYN == "?":
509
+ return False
507
510
  warnText = (
508
511
  "The station should{s} have a {what}, "
509
512
  "but the API did{d} return one."
@@ -582,7 +585,7 @@ class ImportPlugin(plugins.ImportPluginBase):
582
585
  tdenv.WARN("(Fields will be marked with an leading asterisk '*')")
583
586
  askForData = True
584
587
  if ((defStation.lsFromStar == 0) or ("?" in defStation)):
585
- askForData = True
588
+ askForData = True
586
589
 
587
590
  newStation = {}
588
591
  for key in defStation._fields:
@@ -812,9 +815,7 @@ class ImportPlugin(plugins.ImportPluginBase):
812
815
  shipCost = {}
813
816
  shipList = []
814
817
  eddn_ships = []
815
- if ((station.shipyard == "Y") and
816
- ('ships' in api.profile['lastStarport'])
817
- ):
818
+ if ((station.shipyard == "Y") and ('ships' in api.profile['lastStarport'])):
818
819
  if 'shipyard_list' in api.profile['lastStarport']['ships']:
819
820
  if len(api.profile['lastStarport']['ships']['shipyard_list']):
820
821
  for ship in api.profile['lastStarport']['ships']['shipyard_list'].values():
@@ -914,9 +915,7 @@ class ImportPlugin(plugins.ImportPluginBase):
914
915
  # If a market exists, make the item lists
915
916
  itemList = []
916
917
  eddn_market = []
917
- if ((station.market == "Y") and
918
- ('commodities' in api.profile['lastStarport'])
919
- ):
918
+ if ((station.market == "Y") and ('commodities' in api.profile['lastStarport'])):
920
919
  for commodity in api.profile['lastStarport']['commodities']:
921
920
  if commodity['categoryname'] in cat_ignore:
922
921
  continue
@@ -1046,18 +1045,13 @@ class ImportPlugin(plugins.ImportPluginBase):
1046
1045
  eddn_ships
1047
1046
  )
1048
1047
 
1049
- if ((station.outfitting == "Y") and
1050
- ('modules' in api.profile['lastStarport'] and
1051
- len(api.profile['lastStarport']['modules']))
1052
- ):
1048
+ if station.outfitting == "Y" and 'modules' in api.profile['lastStarport'] and len(api.profile['lastStarport']['modules']):
1053
1049
  eddn_modules = []
1054
1050
  for module in api.profile['lastStarport']['modules'].values():
1055
1051
  # see: https://github.com/EDSM-NET/EDDN/wiki
1056
1052
  addModule = False
1057
1053
  if module['name'].startswith(('Hpt_', 'Int_')) or module['name'].find('_Armour_') > 0:
1058
- if module.get('sku', None) in (
1059
- None, 'ELITE_HORIZONS_V_PLANETARY_LANDINGS'
1060
- ):
1054
+ if module.get('sku', None) in (None, 'ELITE_HORIZONS_V_PLANETARY_LANDINGS'):
1061
1055
  if module['name'] != 'Int_PlanetApproachSuite':
1062
1056
  addModule = True
1063
1057
  if addModule:
@@ -1,8 +1,7 @@
1
1
  import csv
2
2
  import pathlib
3
- import random
4
3
 
5
- from .. import cache, tradeenv, transfers, csvexport
4
+ from .. import cache, transfers, csvexport
6
5
  from ..tradedb import Category, Item
7
6
  from . import PluginException, ImportPluginBase
8
7
 
@@ -194,7 +193,7 @@ class ImportPlugin(ImportPluginBase):
194
193
  """
195
194
  More to do for commodities
196
195
  """
197
- tdb, tdenv = self.tdb, self.tdenv
196
+ tdenv = self.tdenv
198
197
  tdenv.NOTE("Processing {}", tableName)
199
198
 
200
199
  itmCount = 0
@@ -207,7 +206,6 @@ class ImportPlugin(ImportPluginBase):
207
206
  )
208
207
  # first line must be the column names
209
208
  columnDefs = next(csvIn)
210
- columnCount = len(columnDefs)
211
209
 
212
210
  tdenv.DEBUG0("columnDefs: {}", columnDefs)
213
211
 
@@ -235,7 +233,8 @@ class ImportPlugin(ImportPluginBase):
235
233
  tdenv.NOTE("Import stopped.", checkMe, localPath)
236
234
  else:
237
235
  for lineIn in csvIn:
238
- if not lineIn: continue
236
+ if not lineIn:
237
+ continue
239
238
  lineNo = csvIn.line_num
240
239
  tdenv.DEBUG0("LINE {}: {}", lineNo, lineIn)
241
240
 
@@ -3,12 +3,10 @@
3
3
  # a EDDBlink_listener server to update the Database.
4
4
  # ----------------------------------------------------------------
5
5
  import certifi
6
- import codecs
7
6
  import csv
8
7
  import datetime
9
8
  import json
10
9
  import os
11
- import platform
12
10
  import sqlite3
13
11
  import ssl
14
12
  import time
@@ -16,12 +14,10 @@ import time
16
14
  from urllib import request
17
15
  from calendar import timegm
18
16
  from pathlib import Path
19
- from importlib import reload
20
17
 
21
- from .. import plugins, cache, csvexport, tradedb, tradeenv, transfers
18
+ from .. import plugins, cache, transfers
22
19
  from ..misc import progress as pbar
23
20
  from ..plugins import PluginException
24
- from shutil import copyfile
25
21
 
26
22
  # Constants
27
23
  BASE_URL = os.environ.get('TD_SERVER') or "https://elite.tromador.com/files/"
@@ -32,7 +28,7 @@ def request_url(url, headers=None):
32
28
  data = None
33
29
  if headers:
34
30
  data = bytes(json.dumps(headers), encoding="utf-8")
35
-
31
+
36
32
  return request.urlopen(request.Request(url, data=data), context=CONTEXT)
37
33
 
38
34
 
@@ -89,7 +85,8 @@ class ImportPlugin(plugins.ImportPluginBase):
89
85
  'force': "Force regeneration of selected items even if source file not updated since previous run. "
90
86
  "(Useful for updating Vendor tables if they were skipped during a '-O clean' run.)",
91
87
  'purge': "Remove any empty systems that previously had fleet carriers.",
92
- 'solo': "Don't download crowd-sourced market data. (Implies '-O skipvend', supercedes '-O all', '-O clean', '-O listings'.)"
88
+ 'solo': "Don't download crowd-sourced market data. (Implies '-O skipvend', supercedes '-O all', '-O clean', '-O listings'.)",
89
+ "prices": "Backup listings to the TradeDangerous.prices cache file",
93
90
  }
94
91
 
95
92
  def __init__(self, tdb, tdenv):
@@ -193,25 +190,25 @@ class ImportPlugin(plugins.ImportPluginBase):
193
190
  Purges systems from the System table that do not have any stations claiming to be in them.
194
191
  Keeps table from becoming too large because of fleet carriers moving to unpopulated systems.
195
192
  """
196
-
193
+
197
194
  self.tdenv.NOTE("Purging Systems with no stations: Start time = {}", self.now())
198
-
195
+
199
196
  self.execute("PRAGMA foreign_keys = OFF")
200
-
197
+
201
198
  print("Saving systems with stations.... " + str(self.now()) + "\t\t\t\t", end="\r")
202
199
  self.execute("DROP TABLE IF EXISTS System_copy")
203
200
  self.execute("""CREATE TABLE System_copy AS SELECT * FROM System
204
201
  WHERE system_id IN (SELECT system_id FROM Station)
205
202
  """)
206
-
203
+
207
204
  print("Erasing table and reinserting kept systems.... " + str(self.now()) + "\t\t\t\t", end="\r")
208
205
  self.execute("DELETE FROM System")
209
206
  self.execute("INSERT INTO System SELECT * FROM System_copy")
210
-
207
+
211
208
  print("Removing copy.... " + str(self.now()) + "\t\t\t\t", end="\r")
212
209
  self.execute("PRAGMA foreign_keys = ON")
213
210
  self.execute("DROP TABLE IF EXISTS System_copy")
214
-
211
+
215
212
  self.tdenv.NOTE("Finished purging Systems. End time = {}", self.now())
216
213
 
217
214
  def commit(self):
@@ -351,7 +348,7 @@ class ImportPlugin(plugins.ImportPluginBase):
351
348
  default = True
352
349
  for option in self.options:
353
350
  # if not option in ('force', 'fallback', 'skipvend', 'progbar'):
354
- if not option in ('force', 'skipvend'):
351
+ if option not in ('force', 'skipvend', 'prices'):
355
352
  default = False
356
353
  if default:
357
354
  self.options["listings"] = True
@@ -469,11 +466,11 @@ class ImportPlugin(plugins.ImportPluginBase):
469
466
  if self.getOption("rare"):
470
467
  if self.downloadFile(self.rareItemPath) or self.getOption("force"):
471
468
  buildCache = True
472
-
469
+
473
470
  if self.getOption("shipvend"):
474
471
  if self.downloadFile(self.shipVendorPath) or self.getOption("force"):
475
472
  buildCache = True
476
-
473
+
477
474
  if self.getOption("upvend"):
478
475
  if self.downloadFile(self.upgradeVendorPath) or self.getOption("force"):
479
476
  buildCache = True
@@ -508,7 +505,7 @@ class ImportPlugin(plugins.ImportPluginBase):
508
505
  if self.downloadFile(self.liveListingsPath) or self.getOption("force"):
509
506
  self.importListings(self.liveListingsPath)
510
507
 
511
- if self.getOption("listings"):
508
+ if self.getOption("prices"):
512
509
  self.tdenv.NOTE("Regenerating .prices file.")
513
510
  cache.regeneratePricesFile(self.tdb, self.tdenv)
514
511
 
@@ -1,8 +1,6 @@
1
- import os
2
- import re
3
1
  from pathlib import Path
4
2
 
5
- from .. import tradedb, tradeenv, cache, fs
3
+ from .. import fs
6
4
  from ..commands.exceptions import CommandLineError
7
5
  from . import PluginException, ImportPluginBase
8
6
 
@@ -63,7 +61,7 @@ class ImportPlugin(ImportPluginBase):
63
61
  raise PluginException("EDMC Batch unable to process files with multiple stations. Use normal import.")
64
62
 
65
63
  for s in stations:
66
- if(s in stations_seen):
64
+ if s in stations_seen:
67
65
  cur_file = stations_seen[s]
68
66
  # Set the newer file as the one we'll use.
69
67
  stations_seen[s] = self.file_get_newer(cur_file, f)
@@ -81,7 +79,7 @@ class ImportPlugin(ImportPluginBase):
81
79
  fs.ensurefolder(tdenv.tmpDir)
82
80
  batchfile = tdenv.tmpDir / Path(self.BATCH_FILE)
83
81
  if batchfile.exists():
84
- batchfile.unlink()
82
+ batchfile.unlink()
85
83
  # We now have a list of paths. Add all contents to a new file
86
84
  temp_file = open(batchfile, "w")
87
85