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.
Files changed (87) hide show
  1. py.typed +1 -0
  2. trade.py +49 -0
  3. tradedangerous/__init__.py +43 -0
  4. tradedangerous/cache.py +1381 -0
  5. tradedangerous/cli.py +136 -0
  6. tradedangerous/commands/TEMPLATE.py +74 -0
  7. tradedangerous/commands/__init__.py +244 -0
  8. tradedangerous/commands/buildcache_cmd.py +102 -0
  9. tradedangerous/commands/buy_cmd.py +427 -0
  10. tradedangerous/commands/commandenv.py +372 -0
  11. tradedangerous/commands/exceptions.py +94 -0
  12. tradedangerous/commands/export_cmd.py +150 -0
  13. tradedangerous/commands/import_cmd.py +222 -0
  14. tradedangerous/commands/local_cmd.py +243 -0
  15. tradedangerous/commands/market_cmd.py +207 -0
  16. tradedangerous/commands/nav_cmd.py +252 -0
  17. tradedangerous/commands/olddata_cmd.py +270 -0
  18. tradedangerous/commands/parsing.py +221 -0
  19. tradedangerous/commands/rares_cmd.py +298 -0
  20. tradedangerous/commands/run_cmd.py +1521 -0
  21. tradedangerous/commands/sell_cmd.py +262 -0
  22. tradedangerous/commands/shipvendor_cmd.py +60 -0
  23. tradedangerous/commands/station_cmd.py +68 -0
  24. tradedangerous/commands/trade_cmd.py +181 -0
  25. tradedangerous/commands/update_cmd.py +67 -0
  26. tradedangerous/corrections.py +55 -0
  27. tradedangerous/csvexport.py +234 -0
  28. tradedangerous/db/__init__.py +27 -0
  29. tradedangerous/db/adapter.py +192 -0
  30. tradedangerous/db/config.py +107 -0
  31. tradedangerous/db/engine.py +259 -0
  32. tradedangerous/db/lifecycle.py +332 -0
  33. tradedangerous/db/locks.py +208 -0
  34. tradedangerous/db/orm_models.py +500 -0
  35. tradedangerous/db/paths.py +113 -0
  36. tradedangerous/db/utils.py +661 -0
  37. tradedangerous/edscupdate.py +565 -0
  38. tradedangerous/edsmupdate.py +474 -0
  39. tradedangerous/formatting.py +210 -0
  40. tradedangerous/fs.py +156 -0
  41. tradedangerous/gui.py +1146 -0
  42. tradedangerous/mapping.py +133 -0
  43. tradedangerous/mfd/__init__.py +103 -0
  44. tradedangerous/mfd/saitek/__init__.py +3 -0
  45. tradedangerous/mfd/saitek/directoutput.py +678 -0
  46. tradedangerous/mfd/saitek/x52pro.py +195 -0
  47. tradedangerous/misc/checkpricebounds.py +287 -0
  48. tradedangerous/misc/clipboard.py +49 -0
  49. tradedangerous/misc/coord64.py +83 -0
  50. tradedangerous/misc/csvdialect.py +57 -0
  51. tradedangerous/misc/derp-sentinel.py +35 -0
  52. tradedangerous/misc/diff-system-csvs.py +159 -0
  53. tradedangerous/misc/eddb.py +81 -0
  54. tradedangerous/misc/eddn.py +349 -0
  55. tradedangerous/misc/edsc.py +437 -0
  56. tradedangerous/misc/edsm.py +121 -0
  57. tradedangerous/misc/importeddbstats.py +54 -0
  58. tradedangerous/misc/prices-json-exp.py +179 -0
  59. tradedangerous/misc/progress.py +194 -0
  60. tradedangerous/plugins/__init__.py +249 -0
  61. tradedangerous/plugins/edcd_plug.py +371 -0
  62. tradedangerous/plugins/eddblink_plug.py +861 -0
  63. tradedangerous/plugins/edmc_batch_plug.py +133 -0
  64. tradedangerous/plugins/spansh_plug.py +2647 -0
  65. tradedangerous/prices.py +211 -0
  66. tradedangerous/submit-distances.py +422 -0
  67. tradedangerous/templates/Added.csv +37 -0
  68. tradedangerous/templates/Category.csv +17 -0
  69. tradedangerous/templates/RareItem.csv +143 -0
  70. tradedangerous/templates/TradeDangerous.sql +338 -0
  71. tradedangerous/tools.py +40 -0
  72. tradedangerous/tradecalc.py +1302 -0
  73. tradedangerous/tradedb.py +2320 -0
  74. tradedangerous/tradeenv.py +313 -0
  75. tradedangerous/tradeenv.pyi +109 -0
  76. tradedangerous/tradeexcept.py +131 -0
  77. tradedangerous/tradeorm.py +183 -0
  78. tradedangerous/transfers.py +192 -0
  79. tradedangerous/utils.py +243 -0
  80. tradedangerous/version.py +16 -0
  81. tradedangerous-12.7.6.dist-info/METADATA +106 -0
  82. tradedangerous-12.7.6.dist-info/RECORD +87 -0
  83. tradedangerous-12.7.6.dist-info/WHEEL +5 -0
  84. tradedangerous-12.7.6.dist-info/entry_points.txt +3 -0
  85. tradedangerous-12.7.6.dist-info/licenses/LICENSE +373 -0
  86. tradedangerous-12.7.6.dist-info/top_level.txt +2 -0
  87. tradegui.py +24 -0
@@ -0,0 +1,133 @@
1
+ #
2
+ # Mapping class for FDEV-IDs to TD names
3
+ #
4
+ # Deprecated
5
+ # FDEVMappingItems and FDEVMappingShips used by edapi plugin
6
+ class FDEVMappingBase:
7
+ """
8
+ Base class to map FDEV-IDs to TD names, do not use directly.
9
+
10
+ Derived class must declare "tableName" and "colNames" which are used
11
+ to select the ID->Name mapping from the database.
12
+
13
+ "colNames" is a list() of columns. The first one must be the idColumn.
14
+
15
+ If there are unknown IDs but name mappings override the mapUnknown()
16
+ method and use addUnknown().
17
+ """
18
+
19
+ def __init__(self, tdb, tdenv):
20
+ """
21
+ Parameters:
22
+ tdb Instance of TradeDB
23
+ tdenv Instance of TradeEnv
24
+ """
25
+ self.tdb = tdb
26
+ self.tdenv = tdenv
27
+ self._colCount = len(self.colNames) - 1
28
+ self.mapLoad()
29
+ anz = len(self.entries)
30
+ self.mapUnknown()
31
+ self._mapCount = len(self.entries)
32
+ anz = self._mapCount - anz
33
+ if anz > 0:
34
+ self.tdenv.DEBUG1("Added {:n} unkown {}-Mappings".format(anz, self.tableName))
35
+
36
+ @property
37
+ def colCount(self):
38
+ return self._colCount
39
+
40
+ @property
41
+ def mapCount(self):
42
+ return self._mapCount
43
+
44
+ def mapLoad(self):
45
+ """
46
+ Loads the mapping
47
+ """
48
+ stmt = """
49
+ SELECT {columns}
50
+ FROM {table}
51
+ WHERE LENGTH({idCol}) > 0
52
+ """.format(columns=",".join(self.colNames),
53
+ table=self.tableName,
54
+ idCol=self.colNames[0]
55
+ )
56
+
57
+ self.tdenv.DEBUG1("Loading mapping for {}".format(self.tableName))
58
+
59
+ conn = self.tdb.getDB()
60
+ curs = conn.cursor()
61
+
62
+ entries = {}
63
+ curs.execute(stmt)
64
+ for line in curs:
65
+ ID = line[0]
66
+ if self._colCount == 1:
67
+ entries[ID] = line[1]
68
+ else:
69
+ entries[ID] = {}
70
+ for i, val in enumerate(line[1:], start=1):
71
+ if val:
72
+ entries[ID][self.colNames[i]] = val
73
+ self.tdenv.DEBUG2("{}: {}".format(ID, str(entries[ID]).replace("{", "{{").replace("}", "}}")))
74
+ self.entries = entries
75
+ self.tdenv.DEBUG1("Loaded {:n} {}-Mappings".format(len(entries), self.tableName))
76
+
77
+ def addUnknown(self, wrong, right):
78
+ # add Entries by name with unknown IDs
79
+ if isinstance(wrong, (str,int,tuple)):
80
+ self.tdenv.DEBUG2("{}: {}".format(wrong, right))
81
+ self.entries[wrong] = right
82
+ else:
83
+ self.tdenv.WARN("{}: {}".format(wrong, right))
84
+ return
85
+
86
+ def mapUnknown(self):
87
+ # override this and add unknown IDs in the derived class
88
+ return
89
+
90
+ def mapID(self, ID, oldValue=None):
91
+ res = self.entries.get(int(ID), None)
92
+ if not res:
93
+ if isinstance(oldValue, (str,int)):
94
+ res = self.entries.get(oldValue, oldValue)
95
+ elif isinstance(oldValue, tuple):
96
+ res = self.entries.get(oldValue, None)
97
+ return res
98
+
99
+ class FDEVMappingItems(FDEVMappingBase):
100
+ """
101
+ Maps ID to TD and EDDN items
102
+ """
103
+ tableName = "Item"
104
+ colNames = [ 'item_id', 'name' ]
105
+
106
+ def mapUnknown(self):
107
+ # no ID known yet for:
108
+ self.addUnknown('Comercial Samples', 'Commercial Samples')
109
+ self.addUnknown('Encripted Data Storage', 'Encrypted Data Storage')
110
+ self.addUnknown('Wreckage Components', 'Salvageable Wreckage')
111
+
112
+ class FDEVMappingShips(FDEVMappingBase):
113
+ """
114
+ Maps ID to TD ships
115
+ """
116
+ tableName = "Ship"
117
+ colNames = [ 'ship_id', 'name' ]
118
+
119
+ class FDEVMappingShipyard(FDEVMappingBase):
120
+ """
121
+ Maps ID to EDDN shipyard
122
+ """
123
+ tableName = "FDevShipyard"
124
+ colNames = [ 'id', 'name' ]
125
+
126
+ class FDEVMappingOutfitting(FDEVMappingBase):
127
+ """
128
+ Maps ID to EDDN outfitting
129
+ """
130
+ tableName = "FDevOutfitting"
131
+ colNames = [ 'id', 'category', 'name', 'mount',
132
+ 'guidance', 'ship', 'class', 'rating'
133
+ ]
@@ -0,0 +1,103 @@
1
+ # Copyright (C) Oliver 'kfsone' Smith 2014 <oliver@kfs.org>:
2
+ # You are free to use, redistribute, or even print and eat a copy of
3
+ # this software so long as you include this copyright notice.
4
+ # I guarantee there is at least one bug neither of us knew about.
5
+ # ---------------------------------------------------------------------
6
+ # TradeDangerous :: Modules :: Multi-function display wrapper
7
+ #
8
+ # Multi-Function Display wrappers
9
+
10
+ ######################################################################
11
+ # imports
12
+
13
+ import sys
14
+ import time
15
+
16
+
17
+ ######################################################################
18
+ # exceptions
19
+
20
+ class MissingDeviceError(Exception):
21
+ """
22
+ Throw when no instance of a device cannot be found.
23
+ """
24
+ pass
25
+
26
+ ######################################################################
27
+ # classes
28
+
29
+ class DummyMFD:
30
+ """
31
+ Base class for the MFD drivers, implemented as no-ops so that
32
+ you can always use all MFD functions without conditionals.
33
+ """
34
+
35
+ def __init__(self):
36
+ pass
37
+
38
+
39
+ def finish(self):
40
+ """
41
+ Close down the driver.
42
+ """
43
+ pass
44
+
45
+
46
+ def display(self, line1, line2="", line3="", delay=None):
47
+ """
48
+ Display data to the MFD.
49
+ Arguments: 1-3 lines of text plus optional pause in seconds.
50
+ """
51
+ pass
52
+
53
+
54
+ def attention(self, duration):
55
+ """
56
+ Draw the user's attention.
57
+ """
58
+ print("\a")
59
+
60
+
61
+ # for now, I'm going to put the wrapper classes just here. till I
62
+ # have a few more to play with and can figure out how I want to
63
+ # organize them.
64
+
65
+ class X52ProMFD(DummyMFD):
66
+ """
67
+ Wrapper for the Saitek X52 Pro MFD.
68
+ """
69
+
70
+ def __init__(self):
71
+ from sys import exit
72
+ from . saitek import directoutput, x52pro
73
+ try:
74
+ self.doObj = x52pro.X52Pro()
75
+ except MissingDeviceError:
76
+ print("{}: error: Could not find any X52 Pro devices attached to the system - please ensure your device is connected and drivers are installed.".format(__name__))
77
+ exit(1)
78
+ except directoutput.DLLError as e:
79
+ print("{}: error#{}: Unable to initialize the Saitek X52 Pro module: {}".format(__name__, e.error_code, e.msg), file=sys.stderr)
80
+ exit(1)
81
+
82
+ self.page = self.doObj.add_page('TD')
83
+ self.display('TradeDangerous', 'INITIALIZING')
84
+
85
+
86
+ def finish(self):
87
+ self.doObj.finish()
88
+
89
+
90
+ def display(self, line1, line2="", line3="", delay=None):
91
+ self.page[0], self.page[1], self.page[2] = line1, line2, line3
92
+ if delay:
93
+ time.sleep(delay)
94
+
95
+ def attention(self, duration):
96
+ page = self.page
97
+ iterNo = 0
98
+ cutoff = time.time() + duration
99
+ while time.time() <= cutoff:
100
+ for ledNo in range(0, 20):
101
+ page.set_led(ledNo, (iterNo + ledNo) % 4)
102
+ iterNo += 1
103
+ time.sleep(0.02)
@@ -0,0 +1,3 @@
1
+ # Saitek MFD wrappers
2
+
3
+ __all__ = [ "DirectOutput", "X52Pro" ]