def getMetaGroupByItem(self, item): """Get meta group by item""" # Check if item is in forced metagroup map if item.name in self.ITEMS_FORCEDMETAGROUP: # Create meta group from scratch metaGroup = types_MetaType() # Get meta group info object based on meta group name metaGroupInfo = self.getMetaGroup(self.ITEMS_FORCEDMETAGROUP[item.name][0]) # Get parent item based on its name parent = self.getItem(self.ITEMS_FORCEDMETAGROUP[item.name][1]) # Assign all required for metaGroup variables metaGroup.info = metaGroupInfo metaGroup.items = item metaGroup.parent = parent metaGroup.metaGroupID = metaGroupInfo.ID metaGroup.parentTypeID = parent.ID metaGroup.typeID = item.ID # If no forced meta group is provided, try to use item's # meta group if any else: metaGroup = item.metaGroup return metaGroup