From ff9b33c0ab8c3651cafa75f895057f6a24ab53fb Mon Sep 17 00:00:00 2001 From: Fred Deschenes Date: Sat, 27 Jun 2015 17:26:19 -0400 Subject: [PATCH] Add search by category in 'buy' command --- README.md | 4 ++-- commands/buy_cmd.py | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1a7903cd..d4c6ac28 100644 --- a/README.md +++ b/README.md @@ -1035,7 +1035,7 @@ Finds stations that are selling / where you can buy, a named list of items or sh [--near N] [--ly-per N] [--avoid PLACES] [--pad-size PSML?] [--black-market | --bm] [--one-stop | -1] - item [item item,item …] + category|item [category|item category|item,category|item,category|item …] ship [ship ship,ship …] ###Options: @@ -1101,7 +1101,7 @@ Finds stations that are selling / where you can buy, a named list of items or sh ###Example: - trade.py buy --near achenar food + trade.py buy --near achenar metals trade.py buy asp trade.py buy --near achenar food,clothing,scrap --one-stop trade.py buy --near achenar type6,type7 -1 diff --git a/commands/buy_cmd.py b/commands/buy_cmd.py index ea5d7cc9..64928b47 100644 --- a/commands/buy_cmd.py +++ b/commands/buy_cmd.py @@ -102,6 +102,15 @@ def get_lookup_list(cmdenv, tdb): for name in names: if mode is not SHIP_MODE: try: + try: + category = tdb.lookupCategory(name) + for item in category.items: + names.append(item.name()) + mode = ITEM_MODE + continue + except LookupError: + pass + item = tdb.lookupItem(name) cmdenv.DEBUG0("Looking up item {} (#{})", item.name(), item.ID) queries[item.ID] = item