Ejemplo n.º 1
0
def _build(name, set):
    # make sure longest equal-prefix items are first
    set = set[:]
    set.sort()
    set.reverse()
    l, u, r = [], [], []
    for item in set:
        l.append(objectgenerator.Literal(value=item.lower()))
        u.append(objectgenerator.Literal(value=item.upper()))
        r.append(objectgenerator.Literal(value=item))
    c[name + '_lc'] = objectgenerator.FirstOfGroup(children=l)
    c[name + '_uc'] = objectgenerator.FirstOfGroup(children=u)
    c[name] = objectgenerator.FirstOfGroup(children=r)
Ejemplo n.º 2
0
def _build(data):
    """Build the name:time map and match rule for each dataset"""
    data = data[:]
    data.sort()  # get shortest and least values first forcefully...
    # then reverse that, to get longest first...
    data.reverse()
    names = []
    mapping = {}
    for key, value in data:
        names.append(objectgenerator.Literal(value=key))
        mapping[key] = value
    rule = objectgenerator.FirstOfGroup(children=names)
    return mapping, rule
Kilo
Lima
Mike
November
Oscar
Papa
Quebec
Romeo
Sierra
Tango
Uniform
Victor
Whiskey
Xray X-ray
Yankee
Zulu""")

set1, set2 = [], []
for item in _letters:
    set1.append(objectgenerator.Literal(value=item))
    set2.append(objectgenerator.Literal(value=string.lower(item)))

military_alphabet_char = objectgenerator.FirstOfGroup(children=set1)
military_alphabet_char_lower = objectgenerator.FirstOfGroup(children=set2)
del set1, set2

c["military_alphabet_char"] = military_alphabet_char
c["military_alphabet_char_lower"] = military_alphabet_char_lower

common.share(c)