Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Feb 26, 2015
1 parent 33d77f5 commit 70f6cae
Showing 1 changed file with 53 additions and 40 deletions.
93 changes: 53 additions & 40 deletions commands/buy_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,73 @@
epilog=None
wantsTradeDB=True
arguments = [
ParseArgument('item', help='Name of item to query.', type=str),
ParseArgument(
'name',
help='Items or Ships to look for.',
type=str
),
]
switches = [
ParseArgument('--quantity',
help='Require at least this quantity.',
default=0,
type=int,
ParseArgument(
'--quantity',
help='Require at least this quantity.',
default=0,
type=int,
),
ParseArgument('--near',
help='Find sellers within jump range of this system.',
type=str
ParseArgument(
'--near',
help='Find sellers within jump range of this system.',
type=str
),
ParseArgument('--ly',
help='[Requires --near] Systems within this range of --near.',
default=None,
dest='maxLyPer',
metavar='N.NN',
type=float,
ParseArgument(
'--ly',
help='[Requires --near] Systems within this range of --near.',
default=None,
dest='maxLyPer',
metavar='N.NN',
type=float,
),
ParseArgument('--limit',
help='Maximum number of results to list.',
default=None,
type=int,
ParseArgument(
'--limit',
help='Maximum number of results to list.',
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',
ParseArgument(
'--pad-size', '-p',
help='Limit the padsize to this ship size (S,M,L or ? for unkown).',
metavar='PADSIZES',
dest='padSize',
),
MutuallyExclusiveGroup(
ParseArgument('--price-sort', '-P',
help='(When using --near) Sort by price not distance',
action='store_true',
default=False,
dest='sortByPrice',
ParseArgument(
'--price-sort', '-P',
help='(When using --near) Sort by price not distance',
action='store_true',
default=False,
dest='sortByPrice',
),
ParseArgument('--stock-sort', '-S',
ParseArgument(
'--stock-sort', '-S',
help='Sort by stock followed by price',
action='store_true',
default=False,
dest='sortByStock',
),
),
ParseArgument('--gt',
help='Limit to prices above Ncr',
metavar='N',
dest='gt',
type=int,
ParseArgument(
'--gt',
help='Limit to prices above Ncr',
metavar='N',
dest='gt',
type=int,
),
ParseArgument('--lt',
help='Limit to prices below Ncr',
metavar='N',
dest='lt',
type=int,
ParseArgument(
'--lt',
help='Limit to prices below Ncr',
metavar='N',
dest='lt',
type=int,
),
]

Expand All @@ -81,10 +94,10 @@ def run(results, cmdenv, tdb):
raise CommandLineError("--gt must be lower than --lt")

try:
item = tdb.lookupItem(cmdenv.item)
item = tdb.lookupItem(cmdenv.name)
cmdenv.DEBUG0("Looking up item {} (#{})", item.name(), item.ID)
except LookupError:
item = tdb.lookupShip(cmdenv.item)
item = tdb.lookupShip(cmdenv.name)
cmdenv.DEBUG0("Looking up ship {} (#{})", item.name(), item.ID)
cmdenv.ship = True

Expand Down

0 comments on commit 70f6cae

Please sign in to comment.