本文整理汇总了Python中tutorial.doc_loader.sub_parsers.parseID函数的典型用法代码示例。如果您正苦于以下问题:Python parseID函数的具体用法?Python parseID怎么用?Python parseID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parseID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _readHintSection
def _readHintSection(xmlCtx, section, flags):
hintID = sub_parsers.parseID(xmlCtx, section, 'Specify a hint ID')
if 'item-id' in section.keys():
itemID = sub_parsers.parseID(xmlCtx, section['item-id'], 'Specify a item ID')
else:
_xml.raiseWrongXml(xmlCtx, section.name, 'Specify a item ID')
return
tags = section.keys()
text = translation(_xml.readString(xmlCtx, section, 'text'))
if 'arrow' in tags:
subSec = section['arrow']
direction = _xml.readString(xmlCtx, subSec, 'direction')
if direction not in _AVAILABLE_DIRECTIONS:
_xml.raiseWrongXml(xmlCtx, section, 'Arrow direction {} is invalid.'.format(direction))
arrow = _ArrowProps(direction, _xml.readBool(xmlCtx, subSec, 'loop'))
else:
arrow = None
if 'padding' in tags:
subSec = section['padding']
padding = _Padding(_xml.readFloat(xmlCtx, subSec, 'left'), _xml.readFloat(xmlCtx, subSec, 'top'), _xml.readFloat(xmlCtx, subSec, 'right'), _xml.readFloat(xmlCtx, subSec, 'bottom'))
else:
padding = None
hint = chapter.ChainHint(hintID, itemID, text, section.readBool('has-box', True), arrow, padding)
hint.setActions(sub_parsers.parseActions(xmlCtx, _xml.getSubsection(xmlCtx, section, 'actions'), flags))
return hint
示例2: _readProgressSection
def _readProgressSection(xmlCtx, section, _):
progressID = sub_parsers.parseID(xmlCtx, section, 'Specify a progress ID')
conditions = []
for _, subSec in _xml.getChildren(xmlCtx, section, 'steps'):
conditions.append(chapter.HasIDConditions(sub_parsers.parseID(xmlCtx, subSec, 'Specify a condition ID'), sub_parsers.readConditions(xmlCtx, subSec, [])))
return chapter.ChapterProgress(progressID, conditions)
示例3: _readChapterTaskSection
def _readChapterTaskSection(xmlCtx, section, _):
taskID = sub_parsers.parseID(xmlCtx, section, 'Specify a task ID')
text = translation(_xml.readString(xmlCtx, section, 'text'))
flagID = None
if 'flag' in section.keys():
flagID = _xml.readString(xmlCtx, section, 'flag')
return chapter.ChapterTask(taskID, text, flagID=flagID)
示例4: _parseScenes
def _parseScenes(self, xmlCtx, section, chapter, flags, itemFlags, afterBattle, initial):
for _, sceneSec in _xml.getChildren(xmlCtx, section, 'scenes'):
sceneID = sub_parsers.parseID(xmlCtx, sceneSec, 'Specify a unique name for the scene')
scene = Scene(entityID=sceneID)
self._parseScene(xmlCtx, sceneSec, scene, flags, itemFlags, afterBattle=afterBattle)
self._parseSharedScene(chapter, scene, flags, itemFlags)
chapter.addScene(scene)
示例5: _readGreetingSection
def _readGreetingSection(xmlCtx, section, _):
greetingID = sub_parsers.parseID(xmlCtx, section, 'Specify a greeting ID')
title = translation(_xml.readString(xmlCtx, section, 'title'))
text = translation(_xml.readString(xmlCtx, section, 'text'))
speakID = None
if 'speak' in section.keys():
speakID = _xml.readString(xmlCtx, section, 'speak')
return chapter.Greeting(greetingID, title, text, speakID=speakID)
示例6: _readMarkerSection
def _readMarkerSection(xmlCtx, section, _):
markerID = sub_parsers.parseID(xmlCtx, section, 'Specify a marker ID')
type = _xml.readString(xmlCtx, section, 'type')
marker = None
if type in _MARKER_TYPES:
parser = _MARKER_TYPES[type]
marker = parser(xmlCtx, section, markerID, _xml.readString(xmlCtx, section, 'var-ref'))
else:
LOG_ERROR('Marker is not supported:', type)
return marker
示例7: _readImageSection
def _readImageSection(xmlCtx, section, _):
imageID = sub_parsers.parseID(xmlCtx, section, 'Specify a image ID')
imageType = _xml.readString(xmlCtx, section, 'type')
image = None
if imageType in _IMAGE_TYPES:
parser = _IMAGE_TYPES[imageType]
image = parser(xmlCtx, section, imageID)
else:
LOG_ERROR('Image is not supported:', imageType)
return image
示例8: parse
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')
result[bonusID] = Bonus(subSec.readInt('id', -1), subSec.readString('message'), sub_parsers.readValues(subSec))
return result
示例9: _parseVars
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)
示例10: _parseBonus
def _parseBonus(self, xmlCtx, section, bonuses):
tags = section.keys()
if 'bonus' in tags:
subSection = section['bonus']
return Bonus(subSection.readInt('id', -1), subSection.readString('message'), sub_parsers.readValues(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')
示例11: _readHintSection
def _readHintSection(xmlCtx, section, _):
hintID = sub_parsers.parseID(xmlCtx, section, 'Specify a hint ID')
text = translation(_xml.readString(xmlCtx, section, 'text'))
if 'image' in section.keys():
image = chapter.SimpleImagePath(None, _xml.readString(xmlCtx, section, 'image'))
elif 'image-ref' in section.keys():
image = _xml.readString(xmlCtx, section, 'image-ref')
else:
image = chapter.SimpleImagePath()
speakID = None
if 'speak' in section.keys():
speakID = _xml.readString(xmlCtx, section, 'speak')
return chapter.SimpleHint(hintID, text, image, speakID=speakID)
示例12: readTutorialSettingSection
def readTutorialSettingSection(xmlCtx, section, flags):
settingID = sub_parsers.parseID(xmlCtx, section, 'Specify a setting ID')
settingName = None
if 'setting-name' in section.keys():
settingName = _xml.readString(xmlCtx, section, 'setting-name')
else:
_xml.raiseWrongXml(xmlCtx, section.name, 'Specify a setting name')
settingValue = None
if 'setting-value' in section.keys():
settingValue = _xml.readBool(xmlCtx, section, 'setting-value')
else:
_xml.raiseWrongXml(xmlCtx, section.name, 'Specify a setting value')
return chapter.TutorialSetting(settingID, settingName, settingValue)
示例13: parse
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))
示例14: readSaveAccountSettingSection
def readSaveAccountSettingSection(xmlCtx, section, _, conditions):
settingID = sub_parsers.parseID(xmlCtx, section, 'Specify a setting ID')
return effects.HasTargetEffect(settingID, _EFFECT_TYPE.SAVE_ACCOUNT_SETTING, conditions=conditions)
示例15: _readInternalBrowserSection
def _readInternalBrowserSection(xmlCtx, section, flags, conditions):
flagID = sub_parsers.parseID(xmlCtx, section, 'Specify a flag ID')
if flagID not in flags:
flags.append(flagID)
return effects.HasTargetEffect(flagID, _EFFECT_TYPE.OPEN_INTERNAL_BROWSER, conditions=conditions)