Ejemplo n.º 1
0
def between_wrapper(fstr, token, ai):
    aa = ARGS_REGEX.search(token).group(0)[1:-1].split(',')
    kk = aa[0]
    if '.' in kk:
        kk = kk.split('.')[0].strip()

    for aa in ((DEFLECTION_REGEX, 'obj.get_deflection(attr, current=True)'),
               (BASELINECOR_REGEX, 'aa.get_baseline_corrected_value(attr)'),
               (BASELINE_REGEX, 'aa.get_baseline_value(attr)'),
               (MIN_REGEX, 'aa.get_values(attr, window or -1).min()', kfunc()),
               (MAX_REGEX, 'aa.get_values(attr, window or -1).max()', kfunc()),
               (CP_REGEX, 'aa.get_current_intensity(attr)')):
        if len(aa) == 2:
            r, ff = aa
            kf = lambda x: x
        else:
            r, ff, kf = aa
        # print kk, ai, ff, reg.match(kk)
        if r.match(kk):
            # print 'matrch', ff, kk, ai
            return wrapper(ff, token, kf(kk))
    else:
        # if '.' in ai:
        #     self.unique_warning('invalid modifier teststr="{}"'.format(kk))
        #     return
        # else:
        return wrapper(fstr, token, ai)
Ejemplo n.º 2
0
def extract_attr(key):
    """
    """
    if key.startswith('L2(CDD)'):
        return 'L2(CDD)'

    try:
        aa = ARGS_REGEX.search(key).group(0)[1:-1].split(',')
        key = aa[0]
        if '.' in key:
            key = key.split('.')[0].strip()
    except AttributeError:
        pass

    m = PARENTHESES_REGEX.findall(key)
    if m:
        key = m[0][1:-1]
    else:
        m = KEY_REGEX.findall(key)
        if m:
            k = m[0]
            if k in ('not',):
                k = m[1]
            key = k

    return key
Ejemplo n.º 3
0
def between_teststr(token):
    args = ARGS_REGEX.search(token).group(0)[1:-1].split(',')
    kk = args[0]
    if '.' in kk:
        kk = kk.replace('.', '_')
    else:
        for rargs in ((MIN_REGEX,),
                      (MAX_REGEX,)):
            if len(rargs) == 2:
                r, kf = rargs
            else:
                r = rargs[0]
                kf = kfunc()
            if r.match(kk):
                kk = kf(kk)
                break
    v1, v2 = args[1:]
    return kk, kk, '{}<={}<={}'.format(v1, kk, v2)