tradedangerous 11.5.2__py3-none-any.whl → 12.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 (39) hide show
  1. tradedangerous/cache.py +567 -395
  2. tradedangerous/cli.py +2 -2
  3. tradedangerous/commands/TEMPLATE.py +25 -26
  4. tradedangerous/commands/__init__.py +8 -16
  5. tradedangerous/commands/buildcache_cmd.py +40 -10
  6. tradedangerous/commands/buy_cmd.py +57 -46
  7. tradedangerous/commands/commandenv.py +0 -2
  8. tradedangerous/commands/export_cmd.py +78 -50
  9. tradedangerous/commands/import_cmd.py +70 -34
  10. tradedangerous/commands/market_cmd.py +52 -19
  11. tradedangerous/commands/olddata_cmd.py +120 -107
  12. tradedangerous/commands/rares_cmd.py +122 -110
  13. tradedangerous/commands/run_cmd.py +118 -66
  14. tradedangerous/commands/sell_cmd.py +52 -45
  15. tradedangerous/commands/shipvendor_cmd.py +49 -234
  16. tradedangerous/commands/station_cmd.py +55 -485
  17. tradedangerous/commands/update_cmd.py +56 -420
  18. tradedangerous/csvexport.py +173 -162
  19. tradedangerous/gui.py +2 -2
  20. tradedangerous/plugins/eddblink_plug.py +389 -252
  21. tradedangerous/plugins/spansh_plug.py +2488 -821
  22. tradedangerous/prices.py +124 -142
  23. tradedangerous/templates/TradeDangerous.sql +6 -6
  24. tradedangerous/tradecalc.py +1227 -1109
  25. tradedangerous/tradedb.py +533 -384
  26. tradedangerous/tradeenv.py +12 -1
  27. tradedangerous/version.py +1 -1
  28. {tradedangerous-11.5.2.dist-info → tradedangerous-12.0.0.dist-info}/METADATA +17 -4
  29. {tradedangerous-11.5.2.dist-info → tradedangerous-12.0.0.dist-info}/RECORD +33 -39
  30. {tradedangerous-11.5.2.dist-info → tradedangerous-12.0.0.dist-info}/WHEEL +1 -1
  31. tradedangerous/commands/update_gui.py +0 -721
  32. tradedangerous/jsonprices.py +0 -254
  33. tradedangerous/plugins/edapi_plug.py +0 -1071
  34. tradedangerous/plugins/journal_plug.py +0 -537
  35. tradedangerous/plugins/netlog_plug.py +0 -316
  36. tradedangerous/templates/database_changes.json +0 -6
  37. {tradedangerous-11.5.2.dist-info → tradedangerous-12.0.0.dist-info}/entry_points.txt +0 -0
  38. {tradedangerous-11.5.2.dist-info → tradedangerous-12.0.0.dist-info/licenses}/LICENSE +0 -0
  39. {tradedangerous-11.5.2.dist-info → tradedangerous-12.0.0.dist-info}/top_level.txt +0 -0
@@ -1,254 +0,0 @@
1
- # Deprecated
2
- from tradedangerous import tradedb
3
- from tradedangerous.tradeexcept import TradeException
4
-
5
- import json
6
- import sys
7
-
8
-
9
- sys.stderr.write("*** WARNING: jsonprices.py is deprecated; if you rely on it, please post a github issue\n")
10
-
11
-
12
- class UnknownSystemError(TradeException):
13
- def __str__(self):
14
- return "Unknown System: " + ' '.join(self.args)
15
-
16
- class UnknownStationError(TradeException):
17
- def __str__(self):
18
- return "Unknown Station: " + ' '.join(self.args)
19
-
20
-
21
- def lookup_system(tdb, tdenv, name, x, y, z):
22
- try:
23
- system = tdb.systemByName[name.upper()]
24
- except KeyError:
25
- system = None
26
- if not system:
27
- try:
28
- system = tdb.lookupSystem(name)
29
- except LookupError:
30
- pass
31
-
32
- if system:
33
- if system.posX != x or system.posY != y or system.posZ != z:
34
- raise Exception("System {} position mismatch: "
35
- "Got {},{},{} expected {},{},{}".format(
36
- name,
37
- x, y, z,
38
- system.posX, system.posY, system.posZ
39
- ))
40
- return system
41
-
42
- candidates = []
43
- for candidate in tdb.systemByID.values():
44
- if candidate.posX == x and candidate.posY == y and candidate.posZ == z:
45
- candidates.append(candidate)
46
-
47
- if len(candidates) == 1:
48
- candidate = candidates[0]
49
- if candidate.casefold() != name.casefold():
50
- if not tdenv.quiet:
51
- print("System name mismatch: "
52
- "Local: {}, "
53
- "Remote: {}, "
54
- "Coords: {}, {}, {}".format(
55
- name,
56
- candidate.dbname,
57
- candidate.posX,
58
- candidate.posY,
59
- candidate.posZ,
60
- ))
61
- return candidates[0]
62
-
63
- if candidates:
64
- options = ', '.join([s.name for s in candidates])
65
- raise RuntimeError(f"System {system.name} matches co-ordinates for systems: {options}")
66
-
67
- if tdenv.addUnknown:
68
- return tdb.addLocalSystem(name, x, y, z)
69
-
70
- return None
71
-
72
- def lookup_station(
73
- tdb, tdenv,
74
- system, name,
75
- lsFromStar, blackMarket, maxPadSize
76
- ):
77
- station = None
78
- normalizedName = tradedb.TradeDB.normalizedStr(name)
79
- for stn in system.stations:
80
- stnNormalizedName = tradedb.TradeDB.normalizedStr(stn.dbname)
81
- if stnNormalizedName == normalizedName:
82
- station = stn
83
- break
84
-
85
- if not station:
86
- if not tdenv.addUnknown:
87
- return None
88
- station = tdb.addLocalStation(system, name)
89
-
90
- # Now set the parameters
91
- tdb.updateLocalStation(
92
- station, lsFromStar, blackMarket, maxPadSize
93
- )
94
- return station
95
-
96
- def load_prices_json(
97
- tdb,
98
- tdenv,
99
- jsonText
100
- ):
101
- """
102
- Take data from a prices file and load it into the database.
103
- """
104
-
105
- data = json.loads(jsonText)
106
-
107
- sysData = data['sys']
108
- sysName = sysData['name']
109
- pos = sysData['pos']
110
-
111
- stnData = data['stn']
112
- stnName = stnData['name']
113
- lsFromStar = stnData['ls']
114
-
115
- try:
116
- blackMarket = stnData['bm'].upper()
117
- if blackMarket not in [ 'Y', 'N' ]:
118
- blackMarket = '?'
119
- except KeyError:
120
- blackMarket = '?'
121
-
122
- try:
123
- maxPadSize = stnData['mps'].upper()
124
- if maxPadSize not in ['S', 'M', 'L']:
125
- maxPadSize = '?'
126
- except KeyError:
127
- maxPadSize = '?'
128
-
129
- system = lookup_system(
130
- tdb, tdenv,
131
- sysName,
132
- pos[0], pos[1], pos[2],
133
- )
134
- if not system:
135
- if not tdenv.ignoreUnknown:
136
- raise UnknownSystemError(sysName)
137
- if not tdenv.quiet:
138
- print("NOTE: Ignoring unknown system: {} [{},{},{}]".format(
139
- sysName,
140
- pos[0], pos[1], pos[2],
141
- ))
142
- return
143
- if system.dbname != sysName and tdenv.detail:
144
- print("NOTE: Treating '{}' as '{}'".format(
145
- sysName, system.dbname
146
- ))
147
- tdenv.DEBUG1("- System: {}", system.dbname)
148
-
149
- station = lookup_station(
150
- tdb, tdenv,
151
- system,
152
- stnName,
153
- lsFromStar,
154
- blackMarket,
155
- maxPadSize,
156
- )
157
- if not station:
158
- if tdenv.ignoreUnknown:
159
- raise UnknownStationError(stnName)
160
- if not tdenv.quiet:
161
- print("NOTE: Ignoring unknown station: {}/{}".format(
162
- sysName.upper(), stnName
163
- ))
164
- return
165
- tdenv.DEBUG1("- Station: {}", station.dbname)
166
-
167
- def generate_prices_json(
168
- tdb,
169
- tdenv,
170
- station,
171
- ):
172
- """
173
- Generate a JSON dump of the specified station along
174
- with everything we know about the station and the system
175
- it is in.
176
-
177
- tdb:
178
- The TradeDB object to use
179
- tdenv:
180
- Settings
181
- station:
182
- Station to dump
183
- """
184
-
185
- system = station.system
186
-
187
- stationData = {
188
- 'cmdr': tdenv.commander or "unknown",
189
- 'src': 'td/price-json',
190
- 'sys': {
191
- 'name': system.dbname,
192
- 'pos': [ system.posX, system.posY, system.posZ ],
193
- },
194
- 'stn': {
195
- 'name': station.dbname,
196
- 'ls': station.lsFromStar,
197
- },
198
- 'items': {}
199
- }
200
-
201
- conn = tdb.getDB()
202
- cur = conn.cursor()
203
- cur.execute("""
204
- SELECT si.item_id,
205
- si.modified,
206
- sb.price, sb.units, sb.level,
207
- ss.price, ss.units, ss.level
208
- FROM StationItem AS si
209
- LEFT OUTER JOIN StationBuying AS sb
210
- ON (
211
- sb.station_id = si.station_id
212
- AND sb.item_id = si.item_id
213
- )
214
- LEFT OUTER JOIN StationSelling AS ss
215
- ON (
216
- ss.station_id = si.station_id
217
- AND ss.item_id = si.item_id
218
- )
219
- WHERE si.station_id = ?
220
- """, [station.ID])
221
-
222
- items = {}
223
-
224
- lastModified = "0"
225
- for (
226
- itemID, modified,
227
- sbPrice, sbUnits, sbLevel,
228
- ssPrice, ssUnits, ssLevel
229
- ) in cur:
230
- lastModified = max(lastModified, modified)
231
- item = tdb.itemByID[itemID]
232
- itemData = items[item.dbname] = {
233
- 'm': modified,
234
- }
235
- if sbPrice and (sbUnits >= 0 or sbLevel >= 0):
236
- itemData['b'] = [ sbPrice, sbUnits, sbLevel ]
237
- elif sbPrice:
238
- itemData['b'] = sbPrice
239
- if ssPrice and (ssUnits >= 0 or sbLevel >= 0):
240
- itemData['s'] = [
241
- ssPrice, ssUnits, ssLevel
242
- ]
243
- elif ssPrice:
244
- itemData['s'] = ssPrice
245
-
246
- # dedupe timestamps.
247
- for itemData in items.values():
248
- if itemData['m'] == lastModified:
249
- del itemData['m']
250
-
251
- stationData['m'] = lastModified
252
- stationData['items'] = items
253
-
254
- return json.dumps(stationData, separators=(',',':'))