MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / getVariationsByItems

Method getVariationsByItems

service/market.py:658–730  ·  view source on GitHub ↗

Get item variations by item, its ID or name

(self, items, alreadyparent=False)

Source from the content-addressed store, hash-verified

656 return parent
657
658 def getVariationsByItems(self, items, alreadyparent=False):
659 """Get item variations by item, its ID or name"""
660 # Set for IDs of parent items
661 parents = set()
662 # Set-container for variables
663 variations = set()
664 variations_limiter = set()
665
666 # if item belongs to these categories, use their group to find "variations"
667 categories = ['Drone', 'Fighter', 'Implant']
668
669 for item in items:
670 if item.category.ID == 20 and item.group.ID != 303: # Implants not Boosters
671 implant_remove_list = set()
672 implant_remove_list.add("Low-Grade ")
673 implant_remove_list.add("Low-grade ")
674 implant_remove_list.add("Mid-Grade ")
675 implant_remove_list.add("Mid-grade ")
676 implant_remove_list.add("High-Grade ")
677 implant_remove_list.add("High-grade ")
678 implant_remove_list.add("Limited ")
679 implant_remove_list.add(" - Advanced")
680 implant_remove_list.add(" - Basic")
681 implant_remove_list.add(" - Elite")
682 implant_remove_list.add(" - Improved")
683 implant_remove_list.add(" - Standard")
684
685 for implant_prefix in ("-6", "-7", "-8", "-9", "-10"):
686 for i in range(50):
687 implant_remove_list.add(implant_prefix + str("%02d" % i))
688
689 for text_to_remove in implant_remove_list:
690 if text_to_remove in item.name:
691 variations_limiter.add(item.name.replace(text_to_remove, ""))
692
693 # Get parent item
694 if alreadyparent is False:
695 parent = self.getParentItemByItem(item)
696 else:
697 parent = item
698 # Combine both in the same set
699 parents.add(parent)
700 # Check for overrides and add them if any
701 if parent.name in self.ITEMS_FORCEDMETAGROUP_R:
702 for _item in self.ITEMS_FORCEDMETAGROUP_R[parent.name]:
703 i = self.getItem(_item)
704 if i:
705 variations.add(i)
706 # Add all parents to variations set
707 variations.update(parents)
708 # Add all variations of parents to the set
709 parentids = tuple(item.ID for item in parents)
710 groupids = tuple(item.group.ID for item in parents if item.category.name in categories)
711 variations_list = eos.db.getVariations(parentids, groupids)
712
713 if variations_limiter:
714 for limit in variations_limiter:
715 trimmed_variations_list = [variation_item for variation_item in variations_list if limit in variation_item.name]

Callers 11

getItemsByMarketGroupMethod · 0.95
getTestSetMethod · 0.80
__init__Method · 0.80
displayMethod · 0.80
__handleModuleMethod · 0.80
__handleDroneMethod · 0.80
__handleFighterMethod · 0.80
__handleCargoMethod · 0.80

Calls 6

getParentItemByItemMethod · 0.95
getItemMethod · 0.95
replaceMethod · 0.80
getAttributeMethod · 0.80
updateMethod · 0.45
__iter__Method · 0.45

Tested by

no test coverage detected