def _readPriceGroups(cache, xmlCtx, section, sectionName): if IS_EDITOR and section is None: return else: for tag, iSection in section.items(): if tag != sectionName: continue priceGroup = cc.PriceGroup() priceGroup.id = ix.readInt(xmlCtx, iSection, 'id', 1) iCtx = (xmlCtx, 'id %s' % priceGroup.id) if priceGroup.id in cache.priceGroups: ix.raiseWrongXml(iCtx, 'id', 'duplicate price group id') priceGroup.name = intern(ix.readString(iCtx, iSection, 'name')) if priceGroup.name in cache.priceGroupNames: ix.raiseWrongXml( iCtx, 'id', 'duplicate price group name "%s"' % priceGroup.name) priceGroup.notInShop = iSection.readBool('notInShop', False) iv._readPriceForItem(iCtx, iSection, priceGroup.compactDescr) if iSection.has_key('tags'): tags = iSection.readString('tags').split() priceGroup.tags = frozenset(map(intern, tags)) for tag in priceGroup.tags: cache.priceGroupTags.setdefault(tag, []).append(priceGroup) cache.priceGroupNames[priceGroup.name] = priceGroup.id cache.priceGroups[priceGroup.id] = priceGroup return
def createPriceGroup(cache): if 20000 in cache.priceGroups: if cache.priceGroups[20000].name != 'custom': ix.raiseWrongXml((None, ''), 'priceGroup', 'CamoSelector price group ID needs to be changed!') return priceGroup = cc.PriceGroup() priceGroup.id = 20000 priceGroup.name = intern('custom') priceGroup.notInShop = True priceGroup.tags = frozenset(map(intern, ('custom', 'notInShop', 'legacy', 'paints', 'camouflages', 'common') + nations.NAMES)) for tag in priceGroup.tags: cache.priceGroupTags.setdefault(tag, []).append(priceGroup) cache.priceGroupNames[priceGroup.name] = priceGroup.id cache.priceGroups[priceGroup.id] = priceGroup