From 95b3dbd4faa148e90420068d32bda9b3652ef86e Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Sun, 3 May 2015 17:54:09 -0700 Subject: [PATCH] Normalized --avoid for places --- commands/buy_cmd.py | 9 +-------- commands/nav_cmd.py | 9 ++------- commands/parsing.py | 13 +++++++++++++ commands/sell_cmd.py | 9 +-------- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/commands/buy_cmd.py b/commands/buy_cmd.py index f93f809e..e3277a4d 100644 --- a/commands/buy_cmd.py +++ b/commands/buy_cmd.py @@ -51,14 +51,7 @@ default=None, type=int, ), - ParseArgument( - '--avoid', - help=( - "Don't list results for specified systems/stations.\n" - "Names can be one-per --avoid or comma separated." - ), - action='append', - ), + AvoidPlacesArgument(), PadSizeArgument(), BlackMarketSwitch(), MutuallyExclusiveGroup( diff --git a/commands/nav_cmd.py b/commands/nav_cmd.py index bd76e8da..68d9730e 100644 --- a/commands/nav_cmd.py +++ b/commands/nav_cmd.py @@ -22,12 +22,7 @@ metavar='N.NN', type=float, ), - ParseArgument('--avoid', - help='Exclude a system from the route. If you specify a station, ' - 'the system that station is in will be avoided instead.', - action='append', - default=[], - ), + AvoidPlacesArgument(), ParseArgument('--via', help='Require specified systems/stations to be en-route (in order).', action='append', @@ -232,4 +227,4 @@ def render(results, cmdenv, tdb): for stnRow in row.stations: print(stnRowFmt.format(stnRow)) - return results \ No newline at end of file + return results diff --git a/commands/parsing.py b/commands/parsing.py index 43eae9a3..5ffebbc9 100644 --- a/commands/parsing.py +++ b/commands/parsing.py @@ -61,6 +61,19 @@ def __init__(self): } +class AvoidPlacesArgument(ParseArgument): + def __init__(self): + self.args = ['--avoid'] + self.kwargs = { + 'action': 'append', + 'help': ( + "Don't list results for the specified systems or stations.\n" + "Names can be one-per '--avoid' or comma separated, e.g. " + "'--avoid a,b,c' or '--avoid a,b --avoid c'" + ), + } + + class SwitchArgument(ParseArgument): def __init__(self, help=None): if isinstance(self.switches, (tuple, list)): diff --git a/commands/sell_cmd.py b/commands/sell_cmd.py index 5bec6781..d5069d0b 100644 --- a/commands/sell_cmd.py +++ b/commands/sell_cmd.py @@ -27,14 +27,7 @@ metavar='N.NN', type=float, ), - ParseArgument( - '--avoid', - help=( - "Don't list results for specified systems/stations.\n" - "Names can be one-per --avoid or comma separated." - ), - action='append', - ), + AvoidPlacesArgument(), PadSizeArgument(), BlackMarketSwitch(), ParseArgument('--limit',