Skip to content

Commit

Permalink
Moved list_search
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Aug 11, 2014
1 parent 81539fd commit 7b9ba9a
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions import.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@
categories[cat] = []
categories[cat].append(item)

def list_search(listType, lookup, values):
match = None
needle = lookup.casefold()
for val in values:
if val.casefold().find(needle) > -1:
if match:
raise ValueError("Ambiguity: %s '%s' could match %s or %s" % (
listType, lookup, match, val))
match = val
if not match:
raise ValueError("Error: '%s' doesn't match any %s" % (lookup, listType))
return match

import sys

def addStar(line):
Expand Down Expand Up @@ -65,14 +52,14 @@ def changeStation(name):
return station

def changeCategory(name):
cat = list_search('category', name, categories)
cat = tdb.list_search('category', name, categories)
print("Category Select: ", cat)
return cat

def parseItem(station, cat, line, uiOrder):
fields = line.split()
itemName, sellCr, buyCr = fields[0], int(fields[1]), int(fields[2] if len(fields) > 2 else 0)
item = list_search('item', itemName, categories[cat])
item = tdb.list_search('item', itemName, categories[cat])
print("Item: ", item, sellCr, buyCr)

stationID, itemID = int(station.ID), int(tdb.itemIDs[item])
Expand Down

0 comments on commit 7b9ba9a

Please sign in to comment.