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 Dec 29, 2014
2 parents 09ffa78 + 19b053a commit 51754df
Show file tree
Hide file tree
Showing 12 changed files with 214 additions and 171 deletions.
15 changes: 14 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@
TradeDangerous, Copyright (C) Oliver "kfsone" Smith, July 2014
==============================================================================

v6.3.1 [wip]
WIP:
. (kfsone) buy, sell, nav and local now have consistent presentation
of each station's distance from the star, labelled "StnLs", while
interstellar distances are labelled "DistLy".

v6.3.1 Dec 28 2014
. (kfsone) Removed '--supply' from "update" completely,
. (kfsone) Improved the "--ls-penalty" from a flat line to a curve,
so really, stupidly, ridiculously distant stations (looking at you,
Alpha centauri) really have to be mind-blowing to show up.
. (kfsone) "run" command output shows score of routes,
. (kfsone) "misc/add-station" now has a "-u" option for updates,
. (kfsone) "misc/add-station" no-longer writes to the csv file
(after adding stations do: trade.py export --table Station)
. (kfsone) Fixed #111 import not rebuilding cache
. (kfsone) "maddavo" plugin is now much smarter
- will try to download a smaller prices file,
Expand Down
14 changes: 4 additions & 10 deletions commands/buy_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
default=None,
type=int,
),
ParseArgument('--ages',
help='Show age of data.',
default=False,
action='store_true',
),
MutuallyExclusiveGroup(
ParseArgument('--price-sort', '-P',
help='(When using --near) Sort by price not distance',
Expand All @@ -64,9 +59,6 @@
def run(results, cmdenv, tdb):
from commands.commandenv import ResultRow

if cmdenv.ages and not cmdenv.quiet:
print("--ages is now enabled by default.")

item = tdb.lookupItem(cmdenv.item)
cmdenv.DEBUG0("Looking up item {} (#{})", item.name(), item.ID)

Expand Down Expand Up @@ -157,7 +149,7 @@ def run(results, cmdenv, tdb):
results.rows.sort(key=lambda result: result.stock, reverse=True)
results.rows.sort(key=lambda result: result.price)
if nearSystem and not cmdenv.sortByPrice:
results.summary.sort = "Dist"
results.summary.sort = "Ly"
results.rows.sort(key=lambda result: result.dist)

limit = cmdenv.limit or 0
Expand All @@ -184,11 +176,13 @@ def render(results, cmdenv, tdb):
key=lambda row: '{:n}'.format(row.stock) if row.stock >= 0 else '?')

if cmdenv.nearSystem:
stnRowFmt.addColumn('Dist', '>', 6, '.2f',
stnRowFmt.addColumn('DistLy', '>', 6, '.2f',
key=lambda row: row.dist)

stnRowFmt.addColumn('Age/days', '>', 7, '.2f',
key=lambda row: row.age)
stnRowFmt.addColumn("StnLs", '>', 10,
key=lambda row: row.station.distFromStar())
stnRowFmt.addColumn("Pad", '>', '3',
key=lambda row: TradeDB.padSizes[row.station.maxPadSize])

Expand Down
9 changes: 2 additions & 7 deletions commands/local_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,8 @@ def run(results, cmdenv, tdb):
age = "{:7.2f}".format(ages[station.ID])
except:
age = "-"
if station.lsFromStar:
ls = '{}ls'.format(station.lsFromStar)
else:
ls = '?'
rr = ResultRow(
station=station,
ls=ls,
age=age,
)
row.stations.append(rr)
Expand Down Expand Up @@ -139,8 +134,8 @@ def render(results, cmdenv, tdb):
ColumnFormat("Station", '<', 32,
key=lambda row: row.station.str())
).append(
ColumnFormat("Dist", '>', '10',
key=lambda row: row.ls)
ColumnFormat("StnLs", '>', '10',
key=lambda row: row.station.distFromStar())
).append(
ColumnFormat("Age/days", '>', 7,
key=lambda row: row.age)
Expand Down
6 changes: 3 additions & 3 deletions commands/olddata_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ def render(results, cmdenv, tdb):
)

if cmdenv.nearSystem:
rowFmt.addColumn('Dist', '>', 6, '.2f',
rowFmt.addColumn('DistLy', '>', 6, '.2f',
key=lambda row: math.sqrt(row.dist2))

rowFmt.append(
ColumnFormat("Age/days", '>', '8', '.2f',
key=lambda row: row.age)
).append(
ColumnFormat("Ls/Star", '>', '10',
key=lambda row: row.ls)
ColumnFormat("StnLs", '>', '10',
key=lambda row: row.station.distFromStar())
).append(
ColumnFormat("Pad", '>', '3',
key=lambda row: \
Expand Down
12 changes: 3 additions & 9 deletions commands/sell_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
default=None,
type=int,
),
ParseArgument('--ages',
help='Show age of data.',
default=False,
action='store_true',
),
ParseArgument('--price-sort', '-P',
help='(When using --near) Sort by price not distance',
action='store_true',
Expand All @@ -51,9 +46,6 @@
def run(results, cmdenv, tdb):
from commands.commandenv import ResultRow

if cmdenv.ages and not cmdenv.quiet:
print("--ages is now enabled by default.")

item = tdb.lookupItem(cmdenv.item)
cmdenv.DEBUG0("Looking up item {} (#{})", item.name(), item.ID)

Expand Down Expand Up @@ -167,11 +159,13 @@ def render(results, cmdenv, tdb):
stnRowFmt.addColumn('Demand', '>', 10,
key=lambda row: '{:n}'.format(row.demand) if row.demand >= 0 else '?')
if cmdenv.nearSystem:
stnRowFmt.addColumn('Dist', '>', 6, '.2f',
stnRowFmt.addColumn('DistLy', '>', 6, '.2f',
key=lambda row: row.dist)

stnRowFmt.addColumn('Age/days', '>', 7, '.2f',
key=lambda row: row.age)
stnRowFmt.addColumn('StnLs', '>', 10,
key=lambda row: row.station.distFromStar())
stnRowFmt.addColumn("Pad", '>', '3',
key=lambda row: TradeDB.padSizes[row.station.maxPadSize])

Expand Down
50 changes: 33 additions & 17 deletions commands/update_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ def editUpdate(tdb, cmdenv, stationID):
absoluteFilename = None
dbFilename = tdb.dbFilename
try:
elementMask = prices.Element.basic
if cmdenv.supply: elementMask |= prices.Element.supply
elementMask = prices.Element.basic | prices.Element.supply
if cmdenv.timestamps: elementMask |= prices.Element.timestamp
if cmdenv.all: elementMask |= prices.Element.blanks
# Open the file and dump data to it.
Expand Down Expand Up @@ -372,6 +371,30 @@ def guidedUpdate(tdb, cmdenv):
saveTemporaryFile(tmpPath)


def uploadUpdated():
try:
import requests
except ImportError:
if platform.system() == "Windows":
prompt = "C:\ThisDir\>"
else:
prompt = "$"
raise SystemExit("""Missing 'requests' module:
You don't appear to have the Python module "requests" installed.
It can be installed with Python's package installer, e.g:
{prompt} pip install requests
For additional help, consult:
Bitbucket Wiki http://kfs.org/td/wiki
Facebook Group http://kfs.org/td/group
ED Forum Thread http://kfs.org/td/thread
""".format(
prompt=prompt
))


######################################################################
# Perform query and populate result set

Expand All @@ -392,24 +415,17 @@ def run(results, cmdenv, tdb):
if not cmdenv.quiet:
print(
"NOTE:\n"
". The Update UI is still somewhat experimental.\n"
". Press CTRL-C here to abort editing, or else "
"just close the window to save.\n"
". Use '-q' to hide this message,\n"
". '-F' to make the update window appear infront "
"of Elite: Dangerous (Windowed),\n"
". '-A' to force all items to show if stuff is "
"missing from a station.",
". Press CTRL-C here to abort edit, otherwise "
"just close the update window to save.\n"
". '-F' makes the window show in-front of the "
"E:D Window.\n"
". '-A' forces all items to be listed.\n",
file=sys.stderr
)
guidedUpdate(tdb, cmdenv)
return None

if not cmdenv.quiet and cmdenv.supply:
print("NOTE: '--supply' (-S) is deprecated.")

# User specified one of the options to use an editor.
editUpdate(tdb, cmdenv, cmdenv.startStation.ID)
else:
# User specified one of the options to use an editor.
editUpdate(tdb, cmdenv, cmdenv.startStation.ID)

return None

Loading

0 comments on commit 51754df

Please sign in to comment.