本文整理汇总了Python中messenger.doc_loaders._xml_helpers.readNoEmptyStr函数的典型用法代码示例。如果您正苦于以下问题:Python readNoEmptyStr函数的具体用法?Python readNoEmptyStr怎么用?Python readNoEmptyStr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readNoEmptyStr函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
def load(xmlCtx, section, messengerSettings):
for tagName, subSec in section.items():
if tagName != 'colorScheme':
raise _xml_helpers.XMLError(xmlCtx, 'Tag {0:>s} is invalid'.format(tagName))
ctx = xmlCtx.next(subSec)
name = _xml_helpers.readNoEmptyStr(ctx, subSec, 'name', 'Color scheme name is not defined')
colorScheme = messengerSettings.getColorScheme(name)
if colorScheme is not None:
_readColorScheme(ctx, subSec, colorScheme)
示例2: _readReceiverValue
def _readReceiverValue(xmlCtx, section, settings = None):
name = _xml_helpers.readNoEmptyStr(xmlCtx, section, 'name', 'Receiver name is not defined')
valueSec = section['value']
if not valueSec:
raise _xml_helpers.XMLError(xmlCtx, 'Item value is not defined')
modifiers = []
modifiersSec = valueSec['modifiers']
if modifiersSec:
modifiers = map(lambda section: section.asInt, modifiersSec.values())
label = _xml_helpers.readNoEmptyI18nStr(xmlCtx.next(valueSec), valueSec, 'label', 'Label is not defined')
return (name, _ReceiverInBattle(label, modifiers, valueSec.readInt('order')))
示例3: _readReceiverValue
def _readReceiverValue(xmlCtx, section, settings=None):
name = _xml_helpers.readNoEmptyStr(xmlCtx, section, "name", "Receiver name is not defined")
valueSec = section["value"]
if not valueSec:
raise _xml_helpers.XMLError(xmlCtx, "Item value is not defined")
modifiers = []
modifiersSec = valueSec["modifiers"]
if modifiersSec:
modifiers = map(lambda section: section.asInt, modifiersSec.values())
label = _xml_helpers.readNoEmptyI18nStr(xmlCtx.next(valueSec), valueSec, "label", "Label is not defined")
return (name, _ReceiverInBattle(label, modifiers, valueSec.readInt("order")))
示例4: load
def load(xmlCtx, section, messengerSettings):
for tagName, subSec in section.items():
if tagName != 'settings':
raise _xml_helpers.XMLError(xmlCtx, 'Tag "{0:>s}" is invalid'.format(tagName))
name = _xml_helpers.readNoEmptyStr(xmlCtx, subSec, 'name', 'Setting name is not defined')
if name not in _SETTINGS_LOADERS:
raise _xml_helpers.XMLError(xmlCtx, 'Setting "{0:>s}" is not valid'.format(name))
loader, setReaders, itemReaders = _SETTINGS_LOADERS[name]
if hasattr(messengerSettings, name):
loader(xmlCtx.next(subSec), subSec, getattr(messengerSettings, name), setReaders, itemReaders)
else:
raise _xml_helpers.XMLError(xmlCtx, 'Settings has not attribute {0:>s}'.format(name))
示例5: _readColorScheme
def _readColorScheme(xmlCtx, section, colorScheme):
names = colorScheme.getColorsNames()
defName = colorScheme.getDefColorName()
for tagName, subSec in section.items():
if tagName == 'name':
continue
if tagName != 'item':
raise _xml_helpers.XMLError(xmlCtx, 'Tag "{0:>s}" is invalid'.format(tagName))
ctx = xmlCtx.next(subSec)
name = _xml_helpers.readNoEmptyStr(ctx, subSec, 'name', 'Section "name" is not defined')
colorsSec = subSec['colors']
if not colorsSec:
raise _xml_helpers.XMLError(ctx, 'Section "colors" is not defined')
colorScheme[name] = _readColors(ctx.next(colorsSec), colorsSec, names, defName)
示例6: _readSet
def _readSet(xmlCtx, section, _, readers):
result = []
items = section['items']
if items is None:
raise _xml_helpers.XMLError(xmlCtx, 'Items not found')
for tagName, subSec in items.items():
if tagName != 'item':
raise _xml_helpers.XMLError(xmlCtx, 'Tag "{0:>s}" is invalid'.format(tagName))
ctx = xmlCtx.next(subSec)
name = _xml_helpers.readNoEmptyStr(xmlCtx, subSec, 'name', 'Item name is not defined')
if name not in readers:
raise _xml_helpers.XMLError(xmlCtx, 'Item "{0:>s}" is not valid'.format(name))
result.append(readers[name](ctx, subSec, settings=None))
return result
示例7: _readSettings
def _readSettings(xmlCtx, section, settings, setReaders, itemReaders):
for tagName, subSec in section.items():
if tagName == 'name':
continue
if tagName == 'set':
readers = setReaders
elif tagName == 'item':
readers = itemReaders
else:
raise _xml_helpers.XMLError(xmlCtx, 'Tag "{0:>s}" is invalid'.format(tagName))
ctx = xmlCtx.next(subSec)
name = _xml_helpers.readNoEmptyStr(ctx, subSec, 'name', 'Tag "name" is not defined')
if name not in readers:
raise _xml_helpers.XMLError(ctx, 'Set/item "{0:>s}" is not valid'.format(name))
readers[name](ctx, subSec, settings)
示例8: loadDefault
def loadDefault(xmlCtx, section, messengerSettings):
data = {}
for tagName, subSec in section.items():
if tagName != 'preference':
raise _xml_helpers.XMLError(xmlCtx, 'Tag {0:>s} is invalid'.format(tagName))
ctx = xmlCtx.next(subSec)
name = _xml_helpers.readNoEmptyStr(ctx, subSec, 'name', 'Preference name is not defined')
if name not in _userProps:
raise _xml_helpers.XMLError(ctx, 'Preference {0:>s} is invalid'.format(name))
reader, _, validator, _ = _userProps[name]
value = getattr(subSec, reader)('value')
if validator(value):
data[name] = value
else:
raise _xml_helpers.XMLError(ctx, 'Invalid value of preference {0:>s}'.format(name))
if len(data):
messengerSettings.userPrefs = messengerSettings.userPrefs._replace(**data)
示例9: _readColors
def _readColors(xmlCtx, section, colorsNames, defName):
result = {}
notFound = colorsNames[:]
for tagName, subSec in section.items():
if tagName != 'color':
raise _xml_helpers.XMLError(xmlCtx, 'Tag "{0:>s}" is invalid'.format(tagName))
ctx = xmlCtx.next(subSec)
name = _xml_helpers.readNoEmptyStr(ctx, subSec, 'name', 'Section "name" is not defined')
if name not in colorsNames:
raise _xml_helpers.XMLError(ctx, 'Name of color {0:>s} is invalid'.format(name))
result[name] = _xml_helpers.readRGB(ctx, subSec, 'rgb', 'Color is invalid.')
notFound.remove(name)
if len(notFound):
defColor = 0
if defName in result:
defColor = result[defName]
for name in notFound:
result[name] = defColor
return result