def _parse(section): ver = section.readString('ver', '') if not ver: raise ParseError('Attribute "ver" is not valid.') if ver not in _PARSER_BY_VER: raise ParseError('That version {0} is not supported.'.format(ver)) clazz, (actionsClazz, guiClazz, proxyDataClazz) = _PARSER_BY_VER[ver] return clazz(actionsClazz(), guiClazz(), proxyDataClazz()).parse(section)
def parse(self, section): name = self._readString('name', section) url = self._readString('href', section) target = section.readString('target', 'internal') if target == 'internal': size = parseSize(section.readString('size')) showRefresh = section.readBool('show_refresh') webClientHandler = section.readString('web_client_handler') isSolidBorder = section.readBool('is_solid_border') action = actions.OpenInternalBrowser(name, url, size, showRefresh, webClientHandler, isSolidBorder) elif target == 'external': action = actions.OpenExternalBrowser(name, url) elif target == 'promo': action = actions.OpenPromoBrowser(name, url) elif target == 'stronghold': action = actions.OpenStrongholdBrowser(name, url) elif target == 'ranked': action = actions.OpenRankedBrowser(name, url) else: raise ParseError( 'The target of action "{0}" is not valid: {1}.'.format( self.getTagName(), target)) return action
def parse(self, section): text = section.asString if not text: raise ParseError( 'The content of action "{0}" is not defined.'.format( self.getTagName())) return actions.ReplaceButtons(self._readString('name', section), section.asString)
def parse(self, section): name = self._readString('name', section) url = self._readString('href', section) target = section.readString('target', 'internal') if target == 'internal': action = actions.OpenInternalBrowser(name, url) elif target == 'external': action = actions.OpenExternalBrowser(name, url) else: raise ParseError('The target of action "{0}" is not valid: {1}.'.format(self.getTagName(), target)) return action
def parse(self, section): if section.name != self.getTagName(): raise ParseError('Root tag "{0}" is invalid'.format(section.name)) notifyID = section.readInt64('notification_id', 0L) if not notifyID: raise ParseError('Attribute "notification_id" is not valid.') ttl = section.readFloat('valid_till', 0.0) sub = section[self._actionsParser.getTagName()] if sub: actionsHolder = self._actionsParser.parse(sub) else: actionsHolder = None sub = section[self._guiParser.getTagName()] if sub: itemsHolder = self._guiParser.parse(sub) else: raise ParseError('The tag "gui" is empty.') return (notifyID, ttl, actionsHolder, itemsHolder)
def fromSection(section): if not section: raise ParseError('Section is empty') return _parse(section)
def fromString(xml): section = ResMgr.DataSection().createSectionFromString(xml) if not section: raise ParseError('Can not read notification') return _parse(section)
def _readString(self, name, section): value = section.readString(name, '') if not value: raise ParseError('The {0} of section "{1}" is not defined.'.format( name, self.getTagName())) return value