本文整理汇总了Python中kol.database.ItemDatabase类的典型用法代码示例。如果您正苦于以下问题:Python ItemDatabase类的具体用法?Python ItemDatabase怎么用?Python ItemDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ItemDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parseResponse
def parseResponse(self):
itemsDontMakeCocktailPattern = PatternManager.getOrCompilePattern('itemsDontMakeCocktail')
dontHaveSkillPattern = PatternManager.getOrCompilePattern('dontHaveSkillToMixCocktail')
dontHaveItemsPattern = PatternManager.getOrCompilePattern('dontHaveItemsForThatCocktail')
dontHaveAdventuresPattern = PatternManager.getOrCompilePattern('dontHaveAdventuresToMixCocktail')
# Check for errors.
if itemsDontMakeCocktailPattern.search(self.responseText):
raise Error.Error("Unable to make cocktail. The submitted ingredients do not mix together.", Error.RECIPE_NOT_FOUND)
elif dontHaveSkillPattern.search(self.responseText):
raise Error.Error("Unable to make cocktail. We are not skilled enough.", Error.SKILL_NOT_FOUND)
elif dontHaveItemsPattern.search(self.responseText):
raise Error.Error("Unable to make cocktail. You don't have all of the items you are trying to mix.", Error.ITEM_NOT_FOUND)
elif dontHaveAdventuresPattern.search(self.responseText):
raise Error.Error("Unable to mix drink(s). We don't have enough adventures.", Error.NOT_ENOUGH_ADVENTURES)
# Find the items attached to the message.
singleItemPattern = PatternManager.getOrCompilePattern('acquireSingleItem')
match = singleItemPattern.search(self.responseText)
if match:
descId = int(match.group(1))
item = ItemDatabase.getOrDiscoverItemFromDescId(descId, self.session)
item["quantity"] = 1
else:
multiItemPattern = PatternManager.getOrCompilePattern('acquireMultipleItems')
match = multiItemPattern.search(self.responseText)
if match:
descId = int(match.group(1))
item = ItemDatabase.getOrDiscoverItemFromDescId(descId, self.session)
quantity = int(match.group(2).replace(',', ''))
item["quantity"] = quantity
else:
raise Error.Error("Unknown error.", Error.REQUEST_GENERIC)
self.responseData["booze"] = item
示例2: parseResponse
def parseResponse(self):
noMeatForPastePattern = PatternManager.getOrCompilePattern('noMeatForMeatpasting')
# Check for errors.
if noMeatForPastePattern.search(self.responseText):
raise NotEnoughMeatError("Unable to make the requested item. You don't have enough meat")
# Find the items attached to the message.
singleItemPattern = PatternManager.getOrCompilePattern('acquireSingleItem')
match = singleItemPattern.search(self.responseText)
if match:
descId = int(match.group(1))
item = ItemDatabase.getItemFromDescId(descId, self.session)
item["quantity"] = 1
else:
multiItemPattern = PatternManager.getOrCompilePattern('acquireMultipleItems')
match = multiItemPattern.search(self.responseText)
if match:
descId = int(match.group(1))
item = ItemDatabase.getItemFromDescId(descId, self.session)
quantity = int(match.group(2).replace(',', ''))
item["quantity"] = quantity
else:
raise RequestError("Unknown error.")
self.responseData["items"] = item
示例3: parseResponse
def parseResponse(self):
itemsDontMakeCocktailPattern = PatternManager.getOrCompilePattern('itemsDontMakeCocktail')
dontHaveSkillPattern = PatternManager.getOrCompilePattern('dontHaveSkillToMixCocktail')
dontHaveItemsPattern = PatternManager.getOrCompilePattern('dontHaveItemsForThatCocktail')
dontHaveAdventuresPattern = PatternManager.getOrCompilePattern('dontHaveAdventuresToMixCocktail')
# Check for errors.
if itemsDontMakeCocktailPattern.search(self.responseText):
raise InvalidRecipeError("Unable to make cocktail. The submitted ingredients do not mix together.")
elif dontHaveSkillPattern.search(self.responseText):
raise SkillMissingError("Unable to make cocktail. We are not skilled enough.")
elif dontHaveItemsPattern.search(self.responseText):
raise NotEnoughItemsError("Unable to make cocktail. You don't have all of the items you are trying to mix.")
elif dontHaveAdventuresPattern.search(self.responseText):
raise NotEnoughAdventuresLeftError("Unable to mix drink(s). We don't have enough adventures.")
# Find the items attached to the message.
singleItemPattern = PatternManager.getOrCompilePattern('acquireSingleItem')
match = singleItemPattern.search(self.responseText)
if match:
descId = int(match.group(1))
item = ItemDatabase.getItemFromDescId(descId, self.session)
item["quantity"] = 1
else:
multiItemPattern = PatternManager.getOrCompilePattern('acquireMultipleItems')
match = multiItemPattern.search(self.responseText)
if match:
descId = int(match.group(1))
item = ItemDatabase.getItemFromDescId(descId, self.session)
quantity = int(match.group(2).replace(',', ''))
item["quantity"] = quantity
else:
raise RequestError("Unknown error.")
self.responseData["booze"] = item
示例4: parseResponse
def parseResponse(self):
wrongProfessionPattern = PatternManager.getOrCompilePattern('wrongStillProfession')
invalidItemPattern = PatternManager.getOrCompilePattern('invalidStillItem')
ItemNotFoundPattern = PatternManager.getOrCompilePattern('stillItemNotFound')
maxLimitPattern = PatternManager.getOrCompilePattern('stillMaxLimit')
if wrongProfessionPattern.search(self.responseText):
raise Error.Error("You aren't a Disco Bandit or Accordion Thief.", Error.USER_IS_WRONG_PROFESSION)
if invalidItemPattern.search(self.responseText):
raise Error.Error("You can\'t improve that item.", Error.INVALID_ITEM)
if ItemNotFoundPattern.search(self.responseText):
raise Error.Error("Not enough of that item.", Error.ITEM_NOT_FOUND)
if maxLimitPattern.search(self.responseText):
raise Error.Error("Still can\'t be used anymore today.", Error.LIMIT_REACHED)
# Find the items attached to the message.
singleItemPattern = PatternManager.getOrCompilePattern('acquireSingleItem')
match = singleItemPattern.search(self.responseText)
if match:
descId = int(match.group(1))
item = ItemDatabase.getOrDiscoverItemFromDescId(descId, self.session)
item["quantity"] = 1
else:
multiItemPattern = PatternManager.getOrCompilePattern('acquireMultipleItems')
match = multiItemPattern.search(self.responseText)
if match:
descId = int(match.group(1))
item = ItemDatabase.getOrDiscoverItemFromDescId(descId, self.session)
quantity = int(match.group(2).replace(',', ''))
item["quantity"] = quantity
else:
print self.responseText
raise Error.Error("Unknown error.", Error.REQUEST_GENERIC)
self.responseData["item"] = item
示例5: parseResponse
def parseResponse(self):
cantPulverizePattern = PatternManager.getOrCompilePattern('cantPulverizeItem')
if cantPulverizePattern.search(self.responseText) != None:
item = ItemDatabase.getItemFromId(self.itemId, self.session)
raise UnableToPulverizeItemError("'%s' is not an item that can be pulverized." % item["name"])
notEnoughItemsPattern = PatternManager.getOrCompilePattern('notEnoughItems')
if notEnoughItemsPattern.search(self.responseText) != None:
item = ItemDatabase.getItemFromId(self.itemId, self.session)
if self.quantity == 1:
itemStr = item["name"]
else:
itemStr = item["plural"]
raise NotEnoughItemsError("You do not have %s %s" % (self.quantity % itemStr))
items = []
singleItemPattern = PatternManager.getOrCompilePattern('acquireSingleItem')
for match in singleItemPattern.finditer(self.responseText):
descId = int(match.group(1))
item = ItemDatabase.getItemFromDescId(descId, self.session)
item["quantity"] = 1
items.append(item)
multiItemPattern = PatternManager.getOrCompilePattern('acquireMultipleItems')
for match in multiItemPattern.finditer(self.responseText):
descId = int(match.group(1))
quantity = int(match.group(2).replace(',', ''))
item = ItemDatabase.getItemFromDescId(descId, self.session)
item["quantity"] = quantity
items.append(item)
self.responseData["results"] = items
示例6: preInitializeItemDatabase
def preInitializeItemDatabase(context, **kwargs):
f = None
try:
f = open(_path, "r")
except IOError:
pass
except TypeError:
pass
if f != None:
line = f.readline()
while len(line) > 0:
line = line.strip(" \r\n")
if len(line) > 0 and line[0] != '#':
arr = line.split('\t')
itemId = int(arr[0])
descId = int(arr[1])
name = arr[2]
image = arr[3]
autosell = int(arr[4])
item = {"id":itemId, "descId":descId, "name":name, "autosell":autosell, "image":image}
ItemDatabase.addItem(item)
line = f.readline()
f.close()
return FilterManager.FINISHED
示例7: parseResponse
def parseResponse(self):
dontHaveMeatpastePattern = PatternManager.getOrCompilePattern('noMeatpaste')
itemsDontMeatpastePattern = PatternManager.getOrCompilePattern('itemsDontMeatpaste')
dontHaveItemsPattern = PatternManager.getOrCompilePattern('dontHaveItemsMeatpaste')
# Check for errors.
if dontHaveMeatpastePattern.search(self.responseText):
raise NotEnoughItemsError("Unable to combine items. You don't have any meatpaste.")
elif itemsDontMeatpastePattern.search(self.responseText):
raise InvalidRecipeError("Unable to combine items. The submitted ingredients do not meatpaste together.")
elif dontHaveItemsPattern.search(self.responseText):
raise NotEnoughItemsError("Unable to combine items. You don't have all of the items you are trying to meatpaste.")
# Find the items attached to the message.
singleItemPattern = PatternManager.getOrCompilePattern('acquireSingleItem')
match = singleItemPattern.search(self.responseText)
if match:
descId = int(match.group(1))
item = ItemDatabase.getItemFromDescId(descId, self.session)
item["quantity"] = 1
else:
multiItemPattern = PatternManager.getOrCompilePattern('acquireMultipleItems')
match = multiItemPattern.search(self.responseText)
if match:
descId = int(match.group(1))
item = ItemDatabase.getItemFromDescId(descId, self.session)
quantity = int(match.group(2).replace(',', ''))
item["quantity"] = quantity
else:
raise RequestError("Unknown error.")
self.responseData["items"] = item
示例8: parseResponse
def parseResponse(self):
noWokAccess = PatternManager.getOrCompilePattern('noWokAccess')
itemsDontMakeFoodPattern = PatternManager.getOrCompilePattern('dontHaveItemsForWok')
dontHaveSkillPattern = PatternManager.getOrCompilePattern('dontHaveSkillForWok')
dontHaveAdventuresPattern = PatternManager.getOrCompilePattern('dontHaveAdventuresForWok')
# Check for errors.
if noWokAccess.search(self.responseText):
raise Error.Error("Unable to use the Wok of Ages. I can't get to the Wok!", Error.RECIPE_NOT_FOUND)
elif dontHaveSkillPattern.search(self.responseText):
raise Error.Error("Unable to use the Wok of Ages. I am not skilled enough.", Error.SKILL_NOT_FOUND)
elif itemsDontMakeFoodPattern.search(self.responseText):
raise Error.Error("Unable to use the Wok of Ages. Invalid ingredients.", Error.ITEM_NOT_FOUND)
elif dontHaveAdventuresPattern.search(self.responseText):
raise Error.Error("Unable to use the Wok of Agles. I don't have enough adventures.", Error.NOT_ENOUGH_ADVENTURES)
# Find the items attached to the message.
singleItemPattern = PatternManager.getOrCompilePattern('acquireSingleItem')
match = singleItemPattern.search(self.responseText)
if match:
descId = int(match.group(1))
item = ItemDatabase.getOrDiscoverItemFromDescId(descId, self.session)
item["quantity"] = 1
else:
multiItemPattern = PatternManager.getOrCompilePattern('acquireMultipleItems')
match = multiItemPattern.search(self.responseText)
if match:
descId = int(match.group(1))
item = ItemDatabase.getOrDiscoverItemFromDescId(descId, self.session)
quantity = int(match.group(2).replace(',', ''))
item["quantity"] = quantity
else:
raise Error.Error("Unknown error.", Error.REQUEST_GENERIC)
self.responseData["wok"] = item
示例9: runTest
def runTest(self):
s = TestData.data["session"]
item = ItemDatabase.getItemFromName("olive")
r = ItemDescriptionRequest(s, item["descId"])
itemData = r.doRequest()
self.assertEquals(itemData["isCookingIngredient"], True)
self.assertEquals(itemData["isCocktailcraftingIngredient"], True)
self.assertEquals(itemData["image"], "olive.gif")
self.assertEquals(itemData["autosell"], 35)
self.assertEquals(itemData["type"], "food")
item = ItemDatabase.getItemFromName("furry fur")
r = ItemDescriptionRequest(s, item["descId"])
itemData = r.doRequest()
self.assertEquals(itemData["isMeatsmithingComponent"], True)
self.assertEquals(itemData["image"], "furfur.gif")
self.assertEquals(itemData["autosell"], 129)
item = ItemDatabase.getItemFromName("baconstone")
r = ItemDescriptionRequest(s, item["descId"])
itemData = r.doRequest()
self.assertEquals(itemData["isJewelrymakingComponent"], True)
self.assertEquals(itemData["image"], "baconstone.gif")
self.assertEquals(itemData["autosell"], 500)
# Test a haiku item -- these description pages are formatted differently.
r = ItemDescriptionRequest(s, 435365663)
itemData = r.doRequest()
self.assertEquals(itemData["name"], "little round pebble")
self.assertEquals(itemData["autosell"], 45)
self.assertEquals(itemData["type"], "off-hand item")
示例10: init
def init(params=None):
global _haltEvent
# Create the event which can be used to halt all bots.
_haltEvent = threading.Event()
# Initialize the databases.
ItemDatabase.init()
SkillDatabase.init()
# Force HTTP requests to timeout after 5 minutes.
socket.setdefaulttimeout(300)
示例11: parseResponse
def parseResponse(self):
"""
Searches backoffice.php for item name, quantity, price, limit, and ID.
Returns the items with the usual keys in the item data base along with:
quantity -- The number of the item in your mall store.
price -- The price of the item in your mall store.
limit -- The limit on the item in your mall store.
cheapest -- The cheapest in mall. This includes limited items, use at own risk.
orderId -- Item order in your store. 0 is the first listed and so on.
RegExp match notes: Group 3,6,9, and 11 are garbage HTML data.
"""
storeInventoryPattern = PatternManager.getOrCompilePattern('storeInventory')
items = []
for match in storeInventoryPattern.finditer(self.responseText):
descId = match.group(1)
orderId = match.group(2)
name = match.group(4)
quantity = match.group(5)
itemID = int(match.group(7))
item = ItemDatabase.getOrDiscoverItemFromId(itemID, self.session)
price = match.group(8)
limit = int(match.group(10))
cheapest = int(match.group(12))
item["orderId"] = orderId
item["quantity"] = quantity
item["price"] = price
item["limit"] = limit
item["cheapest"] = cheapest
items.append(item)
self.responseData["items"] = items
示例12: parseResponse
def parseResponse(self):
items = []
itemMatchPattern = PatternManager.getOrCompilePattern('mallItemSearchResult')
itemDetailsPattern = PatternManager.getOrCompilePattern('mallItemSearchDetails')
for itemMatch in itemMatchPattern.finditer(self.responseText):
matchText = itemMatch.group(1)
match = itemDetailsPattern.search(matchText)
itemId = int(match.group('itemId'))
try:
item = ItemDatabase.getItemFromId(itemId)
item["price"] = int(match.group('price').replace(',', ''))
item["storeId"] = int(match.group('storeId'))
item["storeName"] = match.group('storeName').replace('<br>', ' ')
item["quantity"] = int(match.group('quantity').replace(',', ''))
limit = match.group('limit').replace(',', '')
if len(limit) > 0:
limit = int(limit)
item["limit"] = limit
if matchText.find('limited"') >= 0:
item["hitLimit"] = True
items.append(item)
except Error.Error, inst:
if inst.code == Error.ITEM_NOT_FOUND:
Report.info("itemdatabase", "Unrecognized item found in mall search: %s" % itemId, inst)
else:
raise inst
示例13: parseResponse
def parseResponse(self):
response = {}
bountyAvailablePattern = PatternManager.getOrCompilePattern('bountyAvailable')
if bountyAvailablePattern.search(self.responseText):
bountyAvailable = True
else:
bountyAvailable = False
bountyChosenPattern = PatternManager.getOrCompilePattern('bountyChosen')
bountyActivePattern1 = PatternManager.getOrCompilePattern('bountyActive1')
bountyActivePattern2 = PatternManager.getOrCompilePattern('bountyActive2')
if bountyChosenPattern.search(self.responseText) or \
bountyActivePattern1.search(self.responseText) or \
bountyActivePattern2.search(self.responseText):
bountyActive = True
else:
bountyActive = False
dailyBounties = []
if bountyAvailable:
bountyPattern = PatternManager.getOrCompilePattern('dailyBountyItem')
for match in bountyPattern.finditer(self.responseText):
itemId = int(match.group('itemid'))
item = ItemDatabase.getItemFromId(itemId)
dailyBounties.append(item)
response['bountyAvailable'] = bountyAvailable
response['bountyActive'] = bountyActive
response['dailyBounties'] = dailyBounties
self.responseData = response
示例14: parseResponse
def parseResponse(self):
"""
Searches managestore.php for item name, quantity, price, limit, and ID.
Returns the items with the usual keys in the item data base along with:
quantity -- The number of the item in your mall store.
price -- The price of the item in your mall store.
limit -- The limit on the item in your mall store.
"""
storeInventoryPattern = PatternManager.getOrCompilePattern('storeInventory')
items = []
for match in storeInventoryPattern.finditer(self.responseText):
name = match.group(1)
if match.group(2) == None:
quantity = 1
else:
quantity = int(match.group(2))
price = int(match.group(3).replace(',',''))
if match.group(4) == '<font size=1>(unlimited)</font> ':
limit = 0
else:
limit = int(match.group(4))
itemID = int(match.group(5))
item = ItemDatabase.getOrDiscoverItemFromId(itemID, self.session)
item["quantity"] = quantity
item["price"] = price
item["limit"] = limit
items.append(item)
self.responseData["items"] = items
示例15: preInitializeItemDatabase
def preInitializeItemDatabase(context, **kwargs):
db = MySQLDatabaseManager.getDatabase("system")
c = db.cursor()
c.execute("SELECT * FROM item")
row = c.fetchone()
while row != None:
item = {}
item["id"] = row["item_id"]
item["descId"] = row["desc_id"]
item["name"] = row["name"]
item["image"] = row["image"]
item["autosell"] = row["autosell"]
item["type"] = row["type"]
ItemDatabase.addItem(item)
row = c.fetchone()
c.close()
return FilterManager.FINISHED