def _getCommonChapterValues(self, bonuses, subSection, xmlCtx): chapterID = _xml.readString(xmlCtx, subSection, 'chapter-id') title = translation(_xml.readString(xmlCtx, subSection, 'title')) descSec = _xml.getSubsection(xmlCtx, subSection, 'description') defDesc = translation(descSec.asString) abDesc = translation(descSec.readString('after-battle', defDesc)) descriptions = (defDesc, abDesc) bonus = self._parseBonus(xmlCtx, subSection, bonuses) forcedLoading = subSection.readInt('forced-loading', -1) pathSec = _xml.getSubsection(xmlCtx, subSection, 'file-path') defFilePath = pathSec.asString afterBattleFilePath = pathSec.readString('after-battle', defFilePath) filePaths = (defFilePath, afterBattleFilePath) sharedScene = subSection.readString('shared-scene') predefinedVars = [] varsSection = subSection['vars'] or {} for name, varSection in varsSection.items(): if name == 'var-set': predefinedVars.append(sub_parsers.parseVarSet(xmlCtx, varSection, ())) else: _xml.raiseWrongXml(xmlCtx, name, 'Unknown tag') return (chapterID, title, descriptions, bonus, forcedLoading, filePaths, sharedScene, predefinedVars)
def _getCommonChapterValues(self, bonuses, subSection, xmlCtx): chapterID = _xml.readString(xmlCtx, subSection, 'chapter-id') title = translation(_xml.readString(xmlCtx, subSection, 'title')) descSec = _xml.getSubsection(xmlCtx, subSection, 'description') defDesc = translation(descSec.asString) abDesc = translation(descSec.readString('after-battle', defDesc)) descriptions = (defDesc, abDesc) bonus = self._parseBonus(xmlCtx, subSection, bonuses) forcedLoading = subSection.readInt('forced-loading', -1) pathSec = _xml.getSubsection(xmlCtx, subSection, 'file-path') defFilePath = pathSec.asString afterBattleFilePath = pathSec.readString('after-battle', defFilePath) filePaths = (defFilePath, afterBattleFilePath) sharedScene = subSection.readString('shared-scene') predefinedVars = [] varsSection = subSection['vars'] or {} for name, varSection in varsSection.items(): if name == 'var-set': predefinedVars.append( sub_parsers.parseVarSet(xmlCtx, varSection, ())) else: _xml.raiseWrongXml(xmlCtx, name, 'Unknown tag') return (chapterID, title, descriptions, bonus, forcedLoading, filePaths, sharedScene, predefinedVars)
def _parseVars(self, xmlCtx, section, flags, chapter): gVarIDs = [] for name, subSec in _xml.getChildren(xmlCtx, section, 'vars'): if name == 'var-set': chapter.addVarSet(sub_parsers.parseVarSet(xmlCtx, subSec, flags)) if name == 'var-set-ref': gVarIDs.append(sub_parsers.parseID(xmlCtx, subSec, 'Specify a var ID')) _xml.raiseWrongXml(xmlCtx, name, 'Unknown tag') if gVarIDs: GlobalRefParser().parse(chapter, varIDs=gVarIDs, flags=flags)
def _parseVars(self, xmlCtx, section, flags, chapter): gVarIDs = [] for name, subSec in _xml.getChildren(xmlCtx, section, 'vars'): if name == 'var-set': chapter.addVarSet(sub_parsers.parseVarSet(xmlCtx, subSec, flags)) elif name == 'var-set-ref': gVarIDs.append(sub_parsers.parseID(xmlCtx, subSec, 'Specify a var ID')) else: _xml.raiseWrongXml(xmlCtx, name, 'Unknown tag') if gVarIDs: GlobalRefParser().parse(chapter, varIDs=gVarIDs, flags=flags)
def parse(self, chapter, varIDs = None, flags = None): if varIDs is None: varIDs = [] if flags is None: flags = [] section = ResMgr.openSection(GLOBAL_REFS_FILE_PATH) if section is None: _xml.raiseWrongXml(None, GLOBAL_REFS_FILE_PATH, 'can not open or read') xmlCtx = (None, GLOBAL_REFS_FILE_PATH) if len(varIDs): for _, subSec in _xml.getChildren(xmlCtx, section, 'vars'): varID = sub_parsers.parseID(xmlCtx, subSec, 'Specify a var ID') if varID in varIDs: chapter.addVarSet(sub_parsers.parseVarSet(xmlCtx, subSec, flags))
def parse(self, chapter, varIDs=None, flags=None): if varIDs is None: varIDs = [] if flags is None: flags = [] section = ResMgr.openSection(GLOBAL_REFS_FILE_PATH) if section is None: _xml.raiseWrongXml(None, GLOBAL_REFS_FILE_PATH, 'can not open or read') xmlCtx = (None, GLOBAL_REFS_FILE_PATH) if len(varIDs): for _, subSec in _xml.getChildren(xmlCtx, section, 'vars'): varID = sub_parsers.parseID(xmlCtx, subSec, 'Specify a var ID') if varID in varIDs: chapter.addVarSet( sub_parsers.parseVarSet(xmlCtx, subSec, flags))