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
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