Example #1
0
def apply_list(o, fl, vl):
    ucmsg.debug_msg("expr", "apply %s and %s to %s from %s" % (fl, vl, o, inspect.stack()[1][2:]))
    for j in fl:
        if is_list(j):
            for k in j:
                n = k.split("=")
                o = apply_expr(o, [n[0]], [n[1]])
    fl = filter(lambda x: not is_list(x), fl)
    if len(fl) != len(vl):
        print "MISMATCHED APPLY", fl, vl, o, inspect.stack()[1][2:]
        return o
    if not has_ev(o):
        evo = []
        for f, v in zip(fl, vl):
            if is_id(f):
                f = "." + f
            evo.append("%s%s=%s" % (o, f, v))
        return evo
    return apply_expr(o, fl, vl)
Example #2
0
def apply_list(o, fl, vl):
    ucmsg.debug_msg("expr", "apply %s and %s to %s from %s" % 
                   (fl, vl, o, inspect.stack()[1][2:]))
    for j in fl:
        if is_list(j):
            for k in j:
                n = k.split('=')
                o = apply_expr(o, [n[0]], [n[1]])
    fl = filter(lambda x: not is_list(x), fl)
    if len(fl) != len(vl):
        print "MISMATCHED APPLY",fl,vl,o,inspect.stack()[1][2:]
        return o
    if not has_ev(o):
        evo = []
        for f, v in zip(fl, vl):
            if is_id(f):
                f = "." + f
            evo.append("%s%s=%s" % (o, f, v))
        return evo
    return apply_expr(o, fl, vl)
Example #3
0
def parse(s, box, quiet=False, user_mode=False, qual=None):
    try:
        if not quiet:
            print "Expression", s
        tl = tokenize(s, box, user_mode)
        ucmsg.debug_msg("tokenize", tl)
        e, tl = expr(tl)
        if len(tl) > 0:
            raise ParseError("unexpected token %s at end" % (tl[0]))
        ucmsg.debug_msg("expr", e)
        eflat = expr_flat(e)
        if qual:
            eflat = apply_user_qual(eflat, qual)
        res = " ".join(eflat)
        res = expand_events(res)
        ucmsg.debug_msg("expanded", tl)
        return res
    except ParseError as p:
        print "PARSE-ERROR", p.msg
        return []
Example #4
0
def parse(s, box, quiet=False, user_mode=False, qual=None):
    try:
        if not quiet:
            print "Expression", s
        tl = tokenize(s, box, user_mode)
        ucmsg.debug_msg("tokenize", tl)
        e, tl = expr(tl)
        if len(tl) > 0:
            raise ParseError("unexpected token %s at end" % (tl[0]))
        ucmsg.debug_msg("expr", e)
        eflat = expr_flat(e)
        if qual:
            eflat = apply_user_qual(eflat, qual)
        res = " ".join(eflat)
        res = expand_events(res)
        ucmsg.debug_msg("expanded", tl)
        return res
    except ParseError as p:
        print "PARSE-ERROR", p.msg
        return []