コード例 #1
0
 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")
コード例 #2
0
ファイル: ItemDataConverter.py プロジェクト: NardoLoopa/pykol
def mergeItems():
	ItemDatabase.init()
	for i in range(len(_items)):
		item = _items[i]
		try:
			savedItem = ItemDatabase.getItemFromId(item["id"])
			
			for k,v in item.iteritems():
				if k != "enchantments" and k != "type":
					savedItem[k] = v
			if "enchantments" in item and len(item["enchantments"]) > 0:
				if "enchantments" not in savedItem:
					savedItem["enchantments"] = {}
				for k,v in item["enchantments"].iteritems():
					savedItem["enchantments"][k] = v
			_items[i] = savedItem
		except ItemNotFoundError:
			r = ItemDescriptionRequest(_session, item["descId"])
			itemInfo = r.doRequest()
			for k,v in itemInfo.iteritems():
				item[k] = v
コード例 #3
0
def mergeItems():
    ItemDatabase.init()
    for i in range(len(_items)):
        item = _items[i]
        try:
            savedItem = ItemDatabase.getItemFromId(item["id"])

            for k,v in item.iteritems():
                if k != "enchantments" and k != "type":
                    savedItem[k] = v
            if "enchantments" in item and len(item["enchantments"]) > 0:
                if "enchantments" not in savedItem:
                    savedItem["enchantments"] = {}
                for k,v in item["enchantments"].iteritems():
                    savedItem["enchantments"][k] = v
            _items[i] = savedItem
        except ItemNotFoundError:
            r = ItemDescriptionRequest(_session, item["descId"])
            itemInfo = r.doRequest()
            for k,v in itemInfo.iteritems():
                item[k] = v
コード例 #4
0
ファイル: ItemDataConverter.py プロジェクト: MicN/HogBotGit
def mergeItems():
    ItemDatabase.init()
    for i in range(len(_items)):
        item = _items[i]
        try:
            savedItem = ItemDatabase.getItemFromId(item["id"])

            for k,v in item.iteritems():
                if k != "enchantments" and k != "type":
                    savedItem[k] = v
            if "enchantments" in item and len(item["enchantments"]) > 0:
                if "enchantments" not in savedItem:
                    savedItem["enchantments"] = {}
                for k,v in item["enchantments"].iteritems():
                    savedItem["enchantments"][k] = v
            _items[i] = savedItem
        except Error.Error, inst:
            if inst.code == Error.ITEM_NOT_FOUND:
                r = ItemDescriptionRequest(_session, item["descId"])
                itemInfo = r.doRequest()
                for k,v in itemInfo.iteritems():
                    item[k] = v
            else:
                raise inst
コード例 #5
0
def couldNotFindItem(context, **kwargs):
	if "session" not in kwargs:
		return
		
	session = kwargs["session"]
	item = None
	
	r = ClosetContentsRequest(session)
	r.skipParseResponse = True
	r.doRequest()
	
	if "descId" in kwargs:
		descId = kwargs["descId"]
		pattern = re.compile("<option value='([0-9]+)' descid='%s'>([^<>]*) \([0-9]+\)<\/option>" % descId)
		match = pattern.search(r.responseText)
		if match:
			item = {"id":int(match.group(1)), "descId":descId, "name":match.group(2)}
		else:
			raise ItemNotFoundError("Could not find item associated with description ID '%s'." % descId)
			
	elif "itemId" in kwargs:
		itemId = kwargs["itemId"]
		pattern = re.compile("<option value='%s' descid='([0-9]+)'>([^<>]*) \([0-9]+\)<\/option>" % itemId)
		match = pattern.search(r.responseText)
		if match:
			item = {"id":itemId, "descId":int(match.group(1)), "name":match.group(2)}
		else:
			raise ItemNotFoundError("Could not find item associated with ID '%s'." % itemId)
			
	elif "itemName" in kwargs:
		itemName = kwargs["itemName"]
		pattern = re.compile("<option value='([0-9]+)' descid='([0-9]+)'>%s \([0-9]+\)<\/option>" % itemName)
		match = pattern.search(r.responseText)
		if match:
			item = {"id":int(match.group(1)), "descId":int(match.group(2)), "name":itemName}
		else:
			raise ItemNotFoundError("Could not find item with name '%s'." % itemName)
	
	if item != None:
		r = ItemDescriptionRequest(session, item["descId"])
		itemInfo = r.doRequest()
		for k,v in itemInfo.iteritems():
			item[k] = v
		
		Report.trace("itemdatabase", "Discovered new item: %s" % item)
		
		context["item"] = item
		FilterManager.executeFiltersForEvent("discoveredNewItem", session=session, item=item)