def _readRanks(xmlCtx, subsections):
    ranks = tankmen_components.RanksSet()
    for sname, subsection in subsections:
        if ranks.getRankByName(sname) is not None:
            _xml.raiseWrongXml(xmlCtx, sname, 'is not unique')
        sname = intern(sname)
        ctx = (xmlCtx, sname)
        if IS_CLIENT or IS_WEB:
            i18n = shared_components.I18nString(_xml.readNonEmptyString(ctx, subsection, 'userString'))
            icon = _parseIcon((ctx, 'icon'), _xml.getSubsection(ctx, subsection, 'icon'))
            rank = tankmen_components.Rank(sname, i18n=i18n, icon=icon)
        else:
            rank = tankmen_components.Rank(sname)
        ranks.add(rank)

    return ranks
Exemplo n.º 2
0
def _readRanks(xmlCtx, subsections):
    """Reads section containing ranks and stores data to RanksSet.
    :param xmlCtx: tuple(root ctx or None, path to section).
    :param subsections: instance of DataSection.
    :return: instance of RanksSet.
    """
    ranks = tankmen_components.RanksSet()
    for sname, subsection in subsections:
        if ranks.getRankByName(sname) is not None:
            _xml.raiseWrongXml(xmlCtx, sname, 'is not unique')
        ctx = (xmlCtx, sname)
        if IS_CLIENT or IS_WEB:
            i18n = shared_components.I18nString(_xml.readNonEmptyString(ctx, subsection, 'userString'))
            icon = _parseIcon((ctx, 'icon'), _xml.getSubsection(ctx, subsection, 'icon'))
            rank = tankmen_components.Rank(sname, i18n=i18n, icon=icon)
        else:
            rank = tankmen_components.Rank(sname)
        ranks.add(rank)

    return ranks
def _parseName(xmlCtx, section):
    return shared_components.I18nString(_xml.readNonEmptyString(xmlCtx, section, component_constants.EMPTY_STRING)).value