Skip to content

Commit

Permalink
Merged kfsone/tradedangerous into master
Browse files Browse the repository at this point in the history
  • Loading branch information
maddavo committed Mar 4, 2015
2 parents 9bb0f81 + b712e28 commit 635e407
Show file tree
Hide file tree
Showing 12 changed files with 373 additions and 157 deletions.
26 changes: 24 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,33 @@
TradeDangerous, Copyright (C) Oliver "kfsone" Smith, July 2014
==============================================================================

v6.13.0 Mar 03 2015
. (kfsone) Added "modified" column to ShipVendor table,
. (kfsone) "maddavo" import plugin:
- Added "--opt=shipvendors" which imports his ShipVendor.csv,
- Entries with a 'modified' of "DELETED" will be
- Added "--opt=csvonly" to stop after importing any csv files (no prices),
- Added "--opt=csvs" to import all the csvs
(equivalent to typing --opt=systems --opt=stations --opt=shipvendor)
. (kfsone) "market" sub-command:
- Default behavior is equivalent to "--buy --sell",
- You now only need to specify --buy (-B) or --sell (-S) to list ONLY
those columns, so "trade.py market SOL -vv" now shows both sets of data.
. (kfsone) "local" sub-command:
- Added "--stations" option: only list systems with stations,
- Added "--trading" option: only list stations that are flagged as having
a market or have trade data available
- Added "--blackmarket" option: only list stations with a black market,
- Added "--shipyard" option: only list stations with a ship yard,
. (kfsone) "run" sub-command:
- check from stations for whether they have anything that can be bought,
- better feedback on some edge-cases where a route cannot be found,
- fixed some problems with --via,
- better feedback when using --jumps=0 or --ly=0,

v6.12.4 Mar 02 2015
. (kfsone) Added 175 Systems,
. (kfsone) Fixed #193 "run" was ignoring --ls-max,
. (kfsone) Added "--opt=shipvendors" to the maddavo plugin,
. (kfsone) Added "--opt=csvonly" to maddavo plugin (stop after csv imports),
+ DRy411S : ShipVendors

v6.12.3 Mar 01 2015
Expand Down
48 changes: 38 additions & 10 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ RUN sub-command:
How many credits to start with
e.g.
--credits 20000

--ly-per N.NN
--ly N.NN
Maximum distance your ship can jump between systems at full capacity.
Expand Down Expand Up @@ -551,11 +551,12 @@ IMPORT sub-command:
systems: Merge maddavo's System data into local db,
stations: Merge maddavo's Station data into local db,
shipvendors: Merge maddavo's ShipVendor data into local db,
csvs: Merge all of the above
exportcsv: Regenerate System and Station .csv files after
merging System/Station data.
csvonly: Stop after importing CSV files, no prices,
skipdl: Skip doing any downloads.
force: Process prices even if timestamps suggest
force: Process prices even if timestamps suggest
there is no new data.
use3h: Force download of the 3-hours .prices file
use2d: Force download of the 2-days .prices file
Expand Down Expand Up @@ -664,18 +665,18 @@ MARKET sub-command:
Lists items bought / sold at a given station; with --detail (-v) also
includes the average price for those items.

trade.py market <station> [--buy] [--sell] [--detail]
trade.py market <station> [--buy | --sell] [--detail]

station
Name of the station to list, e.g. "paes/ramon" or "ramoncity",

--buy
-B
List items bought by the station (listed as 'SELL' in-game)
List only items bought by the station (listed as 'SELL' in-game)

--sell
-S
List items sold by the station (listed as 'BUY' in-game)
List only items sold by the station (listed as 'BUY' in-game)

--detail
-v
Expand Down Expand Up @@ -778,13 +779,24 @@ LOCAL sub-command:
--pad-size SML?
--pad SML?
-p
Limit results to stations that match one of the pad sizes
specified.
Limit stations to those that match one of the pad sizes specified.
--pad ML? (med, lrg or unknown only)
-o ML? "" "" "" ""
-p ML? "" "" "" ""
--pad ? (unknown only),
--pad L (large only, ignores unknown)

--stations
Limit results to systems which have stations

--trading
Limit stations to those which which have markets or trade data.

--shipyard
Limit stations to those known to have a shipyard.

--blackmarket
Limit stations to those known to have a black market.

-v
Show stations + their distance from star

Expand Down Expand Up @@ -825,13 +837,29 @@ LOCAL sub-command:
Adding detail ('-vv' or '-v -v' or '--detail --detail') would add
a count of the number of items we have prices for at each station.

> trade.py local LAVE --trading --ly 4 -vv
System Dist
/ Station StnLs Age/days Mkt BMk Shp Pad Itms
-----------------------------------------------------------
LAVE 0.00
/ Castellan Station 2.34K 2.57 Yes No No Med 37
/ Lave Station 299 7.79 Yes Yes Yes Lrg 33
/ Warinus 863 7.76 Yes Yes No Med 38
DISO 3.59
/ Shifnalport 284 0.57 Yes Yes Yes Lrg 34
LEESTI 3.91
/ George Lucas 255 0.58 Yes Yes Yes Lrg 52
/ Kolmogorov Hub 2.96K 1.61 Yes Yes No Med 53

> trade.py local SOL --blackmarket --ly 6 -vv


BUY sub-command:

Finds stations that are selling / where you can buy, a named list of
items or ships.
trade.py buy

trade.py buy
[-q | -v] [--quantity Q] [--near N] [--ly-per N]
[-P | -S] [--limit]
[--one-stop | -1]
Expand Down
15 changes: 6 additions & 9 deletions commands/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,13 @@ def __init__(self, errorStr):
self.errorStr = errorStr
def __str__(self):
return "Error: {}\n".format(self.errorStr) + ("""
This could be due to a lack of price or station data. You
may want to consult the "local -vv" sub-command to see if
there are stations in the area with price data.
Possible causes:
- No profitable runs or routes meet your criteria,
- Missing Systems or Stations along the route (see "local -vv"),
- Missing price data (see "market -vv" or "update -h"),
It can also be caused by a lack of any profitable runs
that match the criteria you specified.
See '{} update -h' for help entering/updating prices, or
obtain a crowd-sourced '.prices' file from the web, such
as maddavo's (http://www.davek.com.au/td/)".
If you are not sure where to get data from, consider using a crowd-sourcing
project such as "maddavo's" (http://www.davek.com.au/td/).
For more help, see the TradeDangerous Wiki:
http://kfs.org/td/wiki
Expand Down
7 changes: 6 additions & 1 deletion commands/import_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
"is removed, but other stations are not affected."
)
name='import'
epilog=None
epilog=(
"This sub-command provides a plugin infrastructure, and comes "
"with a module to import data from Maddavo's Market Share "
"(http://www.davek.com.au/td/).\n"
"See \"import --plug=maddavo --opt=help\" for more help."
)
wantsTradeDB=False
arguments = [
]
Expand Down
54 changes: 45 additions & 9 deletions commands/local_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@
metavar='PADSIZES',
dest='padSize',
),
ParseArgument('--stations',
help='Limit to systems which have stations.',
action='store_true',
),
ParseArgument('--trading',
help='Limit stations to ones with price data or flagged as having '
'a market.',
action='store_true',
),
ParseArgument('--blackmarket',
help='Limit stations to those known to have a black market.',
action='store_true',
),
ParseArgument('--shipyard',
help='Limit stations to those known to have a ship yard.',
action='store_true',
),
]

######################################################################
Expand Down Expand Up @@ -74,16 +91,28 @@ def run(results, cmdenv, tdb):
for ID, age in tdb.query(stmt)
}

wantStations = cmdenv.stations
padSize = cmdenv.padSize
wantTrading = cmdenv.trading
wantShipYard = cmdenv.shipyard
wantBlackMarket = cmdenv.wantBlackMarket

def station_filter(system):
for station in system.stations:
if wantTrading and not station.isTrading:
continue
if station.blackMarket != 'Y' and wantBlackMarket:
continue
if station.shipyard != 'Y' and wantShipYard:
continue
if padSize and not station.checkPadSize(padSize):
continue
yield station

for (system, dist) in sorted(distances.items(), key=lambda x: x[1]):
row = ResultRow()
row.system = system
row.dist = dist
row.stations = []
if showStations:
for (station) in system.stations:
if padSize and not station.checkPadSize(padSize):
continue
if showStations or wantStations:
stations = []
for (station) in station_filter(system):
try:
age = "{:7.2f}".format(ages[station.ID])
except:
Expand All @@ -92,7 +121,14 @@ def run(results, cmdenv, tdb):
station=station,
age=age,
)
row.stations.append(rr)
stations.append(rr)
if not stations and wantStations:
continue

row = ResultRow()
row.system = system
row.dist = dist
row.stations = stations if showStations else []
results.rows.append(row)

return results
Expand Down
33 changes: 15 additions & 18 deletions commands/market_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@
),
]
switches = [
ParseArgument(
'--buying', '-B',
help='Show items station is buying',
action='store_true',
MutuallyExclusiveGroup(
ParseArgument(
'--buying', '-B',
help='Show items station is buying',
action='store_true',
),
ParseArgument(
'--selling', '-S',
help='Show items station is selling',
action='store_true',
),
),
ParseArgument(
'--selling', '-S',
help='Show items station is selling',
action='store_true',
)
]

######################################################################
Expand All @@ -54,11 +56,6 @@ def run(results, cmdenv, tdb):
)

buying, selling = cmdenv.buying, cmdenv.selling
if not buying and not selling:
raise CommandLineError(
"Please specify one or both of --buying (-B) "
"or --selling (-S)."
)

results.summary = ResultRow()
results.summary.origin = origin
Expand Down Expand Up @@ -105,7 +102,7 @@ def run(results, cmdenv, tdb):
row.buyLevel = level
row.demand = render_units(units, level)
row.buyAge = float(next(it) or 0)
if buying:
if not selling:
hasBuy = (row.buyCr or units or level)
else:
hasBuy = False
Expand All @@ -116,7 +113,7 @@ def run(results, cmdenv, tdb):
row.sellLevel = level
row.supply = render_units(units, level)
row.sellAge = float(next(it) or 0)
if selling:
if not buying:
hasSell = (row.sellCr or units or level)
else:
hasSell = False
Expand Down Expand Up @@ -154,7 +151,7 @@ def render(results, cmdenv, tdb):

rowFmt.addColumn('Item', '<', longestLen,
key=lambda row: row.item.name())
if cmdenv.buying:
if not cmdenv.selling:
rowFmt.addColumn('Buying', '>', 7, 'n',
key=lambda row: row.buyCr,
pred=buyPred)
Expand All @@ -170,7 +167,7 @@ def render(results, cmdenv, tdb):
rowFmt.addColumn('Age/Days', '>', 7, '.2f',
key=lambda row: row.buyAge,
pred=buyPred)
if cmdenv.selling:
if not cmdenv.buying:
rowFmt.addColumn('Selling', '>', 7, 'n',
key=lambda row: row.sellCr,
pred=sellPred)
Expand Down
Loading

0 comments on commit 635e407

Please sign in to comment.