示例#1
0
 def _parseBonus(self, xmlCtx, section, bonuses):
     tags = section.keys()
     if 'bonus' in tags:
         subSection = section['bonus']
         return sub_parsers.parseBonus(xmlCtx, subSection)
     if 'bonus-ref' in tags:
         bonusID = sub_parsers.parseID(xmlCtx, section['bonus-ref'], 'Specify a bonus ID')
         if bonusID in bonuses:
             return bonuses[bonusID]
         _xml.raiseWrongXml(xmlCtx, section.name, 'Bonus reference {0} is not found'.format(bonusID))
     else:
         _xml.raiseWrongXml(xmlCtx, section.name, 'Bonuses is not found')
示例#2
0
    def parse(self):
        section = ResMgr.openSection(BONUSES_REFS_FILE_PATH)
        if section is None:
            _xml.raiseWrongXml(None, BONUSES_REFS_FILE_PATH, 'can not open or read')
        xmlCtx = (None, BONUSES_REFS_FILE_PATH)
        result = {}
        for _, subSec in _xml.getChildren(xmlCtx, section, 'bonuses'):
            bonusID = sub_parsers.parseID(xmlCtx, subSec, 'Specify a bonus ID')
            bonus = sub_parsers.parseBonus(xmlCtx, subSec)
            result[bonusID] = bonus

        return result