From 19499ece474d5004eade8b76bd09d3e7272951de Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Sun, 3 May 2015 16:57:28 -0700 Subject: [PATCH] Make use of PadSizeArgument for consistency --- commands/buy_cmd.py | 19 +++++-------------- commands/local_cmd.py | 6 +----- commands/nav_cmd.py | 7 +------ commands/rares_cmd.py | 6 +----- commands/run_cmd.py | 6 +----- commands/sell_cmd.py | 6 +----- 6 files changed, 10 insertions(+), 40 deletions(-) diff --git a/commands/buy_cmd.py b/commands/buy_cmd.py index 15e40eda..0b1b67b4 100644 --- a/commands/buy_cmd.py +++ b/commands/buy_cmd.py @@ -51,12 +51,7 @@ default=None, type=int, ), - ParseArgument( - '--pad-size', '-p', - help='Limit the padsize to this ship size (S,M,L or ? for unkown).', - metavar='PADSIZES', - dest='padSize', - ), + PadSizeArgument(), MutuallyExclusiveGroup( ParseArgument( '--one-stop', '-1', @@ -177,11 +172,7 @@ def sql_query(cmdenv, tdb, queries, mode): bindValues.append(cmdenv.gt) whereClause = ' AND '.join(constraints) - stmt = """ - SELECT DISTINCT {columns} - FROM {tables} - WHERE {where} - """.format( + stmt = """SELECT DISTINCT {columns} FROM {tables} WHERE {where}""".format( columns=','.join(columns), tables=tables, where=whereClause @@ -218,9 +209,9 @@ def run(results, cmdenv, tdb): results.summary.avg = first.cost else: avgPrice = tdb.query(""" - SELECT CAST(AVG(si.supply_price) AS INT) - FROM StationItem AS si - WHERE si.item_id = ? AND si.supply_price > 0 + SELECT CAST(AVG(si.supply_price) AS INT) + FROM StationItem AS si + WHERE si.item_id = ? AND si.supply_price > 0 """, [first.ID]).fetchone()[0] results.summary.avg = avgPrice diff --git a/commands/local_cmd.py b/commands/local_cmd.py index 228c9f84..90dffca1 100644 --- a/commands/local_cmd.py +++ b/commands/local_cmd.py @@ -31,11 +31,7 @@ type=float, default=None, ), - ParseArgument('--pad-size', '-p', - help='Limit the padsize to this ship size (S,M,L or ? for unkown).', - metavar='PADSIZES', - dest='padSize', - ), + PadSizeArgument(), ParseArgument('--stations', help='Limit to systems which have stations.', action='store_true', diff --git a/commands/nav_cmd.py b/commands/nav_cmd.py index c9f5685c..35535515 100644 --- a/commands/nav_cmd.py +++ b/commands/nav_cmd.py @@ -42,12 +42,7 @@ type=int, dest='stationInterval', ), - ParseArgument( - '--pad-size', '-p', - help='Limit the padsize to this ship size (S,M,L or ? for unkown).', - metavar='PADSIZES', - dest='padSize', - ), + PadSizeArgument(), ] ###################################################################### diff --git a/commands/rares_cmd.py b/commands/rares_cmd.py index 94b8128e..8b8b6dc8 100644 --- a/commands/rares_cmd.py +++ b/commands/rares_cmd.py @@ -42,11 +42,7 @@ default=None, type=int, ), - ParseArgument('--pad-size', '-p', - help='Limit the padsize to this ship size (S,M,L or ? for unkown).', - metavar='PADSIZES', - dest='padSize', - ), + PadSizeArgument(), ParseArgument('--price-sort', '-P', help='(When using --near) Sort by price not distance.', action='store_true', diff --git a/commands/run_cmd.py b/commands/run_cmd.py index 47da77c9..d1a2449e 100644 --- a/commands/run_cmd.py +++ b/commands/run_cmd.py @@ -126,16 +126,12 @@ type=float, dest='maxAge', ), - ParseArgument('--pad-size', '-p', - help='Limit the padsize to this ship size (S,M,L or ? for unknown).', - metavar='PADSIZES', - dest='padSize', - ), ParseArgument('--black-market', '-bm', help='Require stations with a black market.', action='store_true', dest='blackMarket', ), + PadSizeArgument(), ParseArgument('--ls-penalty', '--lsp', help="Penalty per 1kls stations are from their stars.", default=0.6, diff --git a/commands/sell_cmd.py b/commands/sell_cmd.py index 86438ae1..65be57a4 100644 --- a/commands/sell_cmd.py +++ b/commands/sell_cmd.py @@ -27,11 +27,7 @@ metavar='N.NN', type=float, ), - ParseArgument('--pad-size', '-p', - help='Limit the padsize to this ship size (S,M,L or ? for unkown).', - metavar='PADSIZES', - dest='padSize', - ), + PadSizeArgument(), ParseArgument('--limit', help='Maximum number of results to list.', default=None,