tradedangerous 10.17.0__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.
- tradedangerous/__init__.py +4 -4
- tradedangerous/cache.py +183 -148
- 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.0.dist-info}/METADATA +2 -2
- tradedangerous-11.0.0.dist-info/RECORD +79 -0
- tradedangerous-10.17.0.dist-info/RECORD +0 -79
- {tradedangerous-10.17.0.dist-info → tradedangerous-11.0.0.dist-info}/LICENSE +0 -0
- {tradedangerous-10.17.0.dist-info → tradedangerous-11.0.0.dist-info}/WHEEL +0 -0
- {tradedangerous-10.17.0.dist-info → tradedangerous-11.0.0.dist-info}/entry_points.txt +0 -0
- {tradedangerous-10.17.0.dist-info → tradedangerous-11.0.0.dist-info}/top_level.txt +0 -0
tradedangerous/tradecalc.py
CHANGED
|
@@ -39,13 +39,12 @@ Classes:
|
|
|
39
39
|
|
|
40
40
|
from collections import defaultdict
|
|
41
41
|
from collections import namedtuple
|
|
42
|
-
from .tradedb import System, Station, Trade,
|
|
42
|
+
from .tradedb import System, Station, Trade, describeAge
|
|
43
43
|
from .tradedb import Destination
|
|
44
44
|
from .tradeexcept import TradeException
|
|
45
45
|
|
|
46
46
|
import datetime
|
|
47
47
|
import locale
|
|
48
|
-
import math
|
|
49
48
|
import os
|
|
50
49
|
from .misc import progress as pbar
|
|
51
50
|
import re
|
|
@@ -132,7 +131,7 @@ emptyLoad = TradeLoad((), 0, 0, 0)
|
|
|
132
131
|
# Classes
|
|
133
132
|
|
|
134
133
|
|
|
135
|
-
class Route
|
|
134
|
+
class Route:
|
|
136
135
|
"""
|
|
137
136
|
Describes a series of hops where a TradeLoad is picked up at
|
|
138
137
|
one station, the player travels via 0 or more hyperspace
|
|
@@ -210,7 +209,7 @@ class Route(object):
|
|
|
210
209
|
def __eq__(self, rhs):
|
|
211
210
|
return self.score == rhs.score and len(self.jumps) == len(rhs.jumps)
|
|
212
211
|
|
|
213
|
-
def
|
|
212
|
+
def text(self, colorize) -> str:
|
|
214
213
|
return "%s -> %s" % (colorize("cyan", self.firstStation.name()), colorize("blue", self.lastStation.name()))
|
|
215
214
|
|
|
216
215
|
def detail(self, tdenv):
|
|
@@ -220,9 +219,9 @@ class Route(object):
|
|
|
220
219
|
|
|
221
220
|
detail, goalSystem = tdenv.detail, tdenv.goalSystem
|
|
222
221
|
|
|
223
|
-
colorize = tdenv.colorize if tdenv.color else lambda x, y
|
|
222
|
+
colorize = tdenv.colorize if tdenv.color else lambda x, y: y
|
|
224
223
|
|
|
225
|
-
credits = self.startCr + (tdenv.insurance or 0)
|
|
224
|
+
credits = self.startCr + (tdenv.insurance or 0) # pylint: disable=redefined-builtin
|
|
226
225
|
gainCr = 0
|
|
227
226
|
route = self.route
|
|
228
227
|
|
|
@@ -232,25 +231,23 @@ class Route(object):
|
|
|
232
231
|
# around it this morning.
|
|
233
232
|
def genSubValues():
|
|
234
233
|
for hop in hops:
|
|
235
|
-
for
|
|
234
|
+
for tr, _ in hop[0]:
|
|
236
235
|
yield len(tr.name(detail))
|
|
237
236
|
|
|
238
237
|
longestNameLen = max(genSubValues())
|
|
239
238
|
|
|
240
|
-
text = self.
|
|
239
|
+
text = self.text(colorize)
|
|
241
240
|
if detail >= 1:
|
|
242
241
|
text += " (score: {:f})".format(self.score)
|
|
243
242
|
text += "\n"
|
|
244
|
-
jumpsFmt =
|
|
245
|
-
cruiseFmt =
|
|
243
|
+
jumpsFmt = " Jump {jumps}\n"
|
|
244
|
+
cruiseFmt = " Supercruise to {stn}\n"
|
|
246
245
|
distFmt = None
|
|
247
246
|
if detail > 1:
|
|
248
247
|
if detail > 2:
|
|
249
248
|
text += self.summary() + "\n"
|
|
250
249
|
if tdenv.maxJumpsPer > 1:
|
|
251
|
-
distFmt =
|
|
252
|
-
" Direct: {dist:0.2f}ly, Trip: {trav:0.2f}ly\n"
|
|
253
|
-
)
|
|
250
|
+
distFmt = " Direct: {dist:0.2f}ly, Trip: {trav:0.2f}ly\n"
|
|
254
251
|
hopFmt = (
|
|
255
252
|
" Load from "
|
|
256
253
|
+colorize("cyan", "{station}") +
|
|
@@ -443,7 +440,6 @@ class Route(object):
|
|
|
443
440
|
)
|
|
444
441
|
if dockFmt:
|
|
445
442
|
stn = route[i + 1]
|
|
446
|
-
stnName = stn.name()
|
|
447
443
|
text += dockFmt.format(
|
|
448
444
|
station = decorateStation(stn),
|
|
449
445
|
gain = hopGainCr,
|
|
@@ -471,7 +467,7 @@ class Route(object):
|
|
|
471
467
|
Returns a string giving a short summary of this route.
|
|
472
468
|
"""
|
|
473
469
|
|
|
474
|
-
credits, hops, jumps = self.startCr, self.hops, self.jumps
|
|
470
|
+
credits, hops, jumps = self.startCr, self.hops, self.jumps # pylint: disable=redefined-builtin
|
|
475
471
|
ttlGainCr = sum(hop[1] for hop in hops)
|
|
476
472
|
numJumps = sum(
|
|
477
473
|
len(hopJumps) - 1
|
|
@@ -495,7 +491,7 @@ class Route(object):
|
|
|
495
491
|
)
|
|
496
492
|
|
|
497
493
|
|
|
498
|
-
class TradeCalc
|
|
494
|
+
class TradeCalc:
|
|
499
495
|
"""
|
|
500
496
|
Container for accessing trade calculations with common properties.
|
|
501
497
|
"""
|
|
@@ -546,22 +542,22 @@ class TradeCalc(object):
|
|
|
546
542
|
if tdenv.avoidItems or items:
|
|
547
543
|
avoidItemIDs = set(item.ID for item in tdenv.avoidItems)
|
|
548
544
|
loadItems = items or tdb.itemByID.values()
|
|
549
|
-
|
|
545
|
+
loadItemSet = set()
|
|
550
546
|
for item in loadItems:
|
|
551
547
|
ID = item if isinstance(item, int) else item.ID
|
|
552
548
|
if ID not in avoidItemIDs:
|
|
553
|
-
|
|
554
|
-
if not
|
|
549
|
+
loadItemSet.add(str(ID))
|
|
550
|
+
if not loadItemSet:
|
|
555
551
|
raise TradeException("No items to load.")
|
|
556
|
-
|
|
557
|
-
wheres.append("(item_id IN ({}))"
|
|
552
|
+
load_ids = ",".join(str(ID) for ID in loadItemSet)
|
|
553
|
+
wheres.append(f"(item_id IN ({load_ids}))")
|
|
558
554
|
|
|
559
555
|
demand = self.stationsBuying = defaultdict(list)
|
|
560
556
|
supply = self.stationsSelling = defaultdict(list)
|
|
561
557
|
|
|
562
558
|
whereClause = " AND ".join(wheres) or "1"
|
|
563
559
|
|
|
564
|
-
lastStnID
|
|
560
|
+
lastStnID = 0
|
|
565
561
|
dmdCount, supCount = 0, 0
|
|
566
562
|
stmt = """
|
|
567
563
|
SELECT station_id, item_id,
|
|
@@ -589,7 +585,7 @@ class TradeCalc(object):
|
|
|
589
585
|
raise BadTimestampError(
|
|
590
586
|
self.tdb,
|
|
591
587
|
stnID, itmID, timestamp
|
|
592
|
-
)
|
|
588
|
+
) from None
|
|
593
589
|
if dmdCr > 0:
|
|
594
590
|
if not minDemand or dmdUnits >= minDemand:
|
|
595
591
|
dmdAppend((itmID, dmdCr, dmdUnits, dmdLevel, ageS))
|
|
@@ -601,7 +597,7 @@ class TradeCalc(object):
|
|
|
601
597
|
|
|
602
598
|
tdenv.DEBUG0("Loaded {} buys, {} sells".format(dmdCount, supCount))
|
|
603
599
|
|
|
604
|
-
def bruteForceFit(self, items, credits, capacity, maxUnits):
|
|
600
|
+
def bruteForceFit(self, items, credits, capacity, maxUnits): # pylint: disable=redefined-builtin
|
|
605
601
|
"""
|
|
606
602
|
Brute-force generation of all possible combinations of items.
|
|
607
603
|
This is provided to make it easy to validate the results of future
|
|
@@ -656,7 +652,7 @@ class TradeCalc(object):
|
|
|
656
652
|
|
|
657
653
|
return _fitCombos(0, credits, capacity)
|
|
658
654
|
|
|
659
|
-
def fastFit(self, items, credits, capacity, maxUnits):
|
|
655
|
+
def fastFit(self, items, credits, capacity, maxUnits): # pylint: disable=redefined-builtin
|
|
660
656
|
"""
|
|
661
657
|
Best load calculator using a recursive knapsack-like
|
|
662
658
|
algorithm to find multiple loads and return the best.
|
|
@@ -755,7 +751,7 @@ class TradeCalc(object):
|
|
|
755
751
|
|
|
756
752
|
# Mark's test run, to spare searching back through the forum posts for it.
|
|
757
753
|
# python trade.py run --fr="Orang/Bessel Gateway" --cap=720 --cr=11b --ly=24.73 --empty=37.61 --pad=L --hops=2 --jum=3 --loop --summary -vv --progress
|
|
758
|
-
def simpleFit(self, items, credits, capacity, maxUnits):
|
|
754
|
+
def simpleFit(self, items, credits, capacity, maxUnits): # pylint: disable=redefined-builtin
|
|
759
755
|
"""
|
|
760
756
|
Simplistic load calculator:
|
|
761
757
|
(The item list is sorted with highest profit margin items in front.)
|
|
@@ -825,7 +821,7 @@ class TradeCalc(object):
|
|
|
825
821
|
buy = getBuy(sell[0], None)
|
|
826
822
|
if buy:
|
|
827
823
|
gainCr = buy[1] - sell[1]
|
|
828
|
-
if
|
|
824
|
+
if minGainCr <= gainCr <= maxGainCr:
|
|
829
825
|
addTrade(Trade(
|
|
830
826
|
itemIdx[sell[0]],
|
|
831
827
|
sell[1], gainCr,
|
|
@@ -867,7 +863,7 @@ class TradeCalc(object):
|
|
|
867
863
|
maxLsFromStar = tdenv.maxLs or float('inf')
|
|
868
864
|
reqBlackMarket = getattr(tdenv, 'blackMarket', False) or False
|
|
869
865
|
maxAge = getattr(tdenv, 'maxAge') or 0
|
|
870
|
-
credits = tdenv.credits - (getattr(tdenv, 'insurance', 0) or 0)
|
|
866
|
+
credits = tdenv.credits - (getattr(tdenv, 'insurance', 0) or 0) # pylint: disable=redefined-builtin
|
|
871
867
|
fitFunction = self.defaultFit
|
|
872
868
|
capacity = tdenv.capacity
|
|
873
869
|
maxUnits = getattr(tdenv, 'limit') or capacity
|
|
@@ -902,7 +898,7 @@ class TradeCalc(object):
|
|
|
902
898
|
if avoidPlaces:
|
|
903
899
|
restrictStations = set(
|
|
904
900
|
stn for stn in restrictStations
|
|
905
|
-
if stn not in avoidPlaces and
|
|
901
|
+
if stn not in avoidPlaces and
|
|
906
902
|
stn.system not in avoidPlaces
|
|
907
903
|
)
|
|
908
904
|
|
|
@@ -940,11 +936,10 @@ class TradeCalc(object):
|
|
|
940
936
|
for route in routes:
|
|
941
937
|
if tdenv.progress:
|
|
942
938
|
prog.increment(1)
|
|
943
|
-
tdenv.DEBUG1("Route = {}", route.
|
|
939
|
+
tdenv.DEBUG1("Route = {}", route.text(lambda x, y: y))
|
|
944
940
|
|
|
945
941
|
srcStation = route.lastStation
|
|
946
942
|
startCr = credits + int(route.gainCr * safetyMargin)
|
|
947
|
-
routeJumps = len(route.jumps)
|
|
948
943
|
|
|
949
944
|
srcSelling = getSelling(srcStation.ID, None)
|
|
950
945
|
srcSelling = tuple(
|
|
@@ -968,7 +963,8 @@ class TradeCalc(object):
|
|
|
968
963
|
if unique:
|
|
969
964
|
uniquePath = route.route
|
|
970
965
|
elif loopInt:
|
|
971
|
-
|
|
966
|
+
pos_from_end = 0 - loopInt
|
|
967
|
+
uniquePath = route.route[pos_from_end:-1]
|
|
972
968
|
|
|
973
969
|
stations = (d for d in station_iterator(srcStation)
|
|
974
970
|
if (d.station != srcStation) and
|
|
@@ -986,7 +982,7 @@ class TradeCalc(object):
|
|
|
986
982
|
"destSys {}, destStn {}, jumps {}, distLy {}",
|
|
987
983
|
dest.system.dbname,
|
|
988
984
|
dest.station.dbname,
|
|
989
|
-
"->".join(jump.
|
|
985
|
+
"->".join(jump.text() for jump in dest.via),
|
|
990
986
|
dest.distLy
|
|
991
987
|
)
|
|
992
988
|
return True
|
|
@@ -1110,7 +1106,7 @@ class TradeCalc(object):
|
|
|
1110
1106
|
)
|
|
1111
1107
|
|
|
1112
1108
|
result = []
|
|
1113
|
-
for (dst, route, trade, jumps,
|
|
1109
|
+
for (dst, route, trade, jumps, _, score) in bestToDest.values():
|
|
1114
1110
|
result.append(route.plus(dst, trade, jumps, score))
|
|
1115
1111
|
|
|
1116
1112
|
return result
|