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
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
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
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, self.session) 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 ItemNotFoundError, inst: Report.info( "itemdatabase", "Unrecognized item found in mall search: %s" % itemId, inst)
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
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
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
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
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