(reader, frame, locals)
return vars
Scan one logical line of Python and look up values of variables used.
Scan one logical line of Python and look up values of variables used.
Scan one logical line of Python and look up values of variables used .
def scanvars(reader, frame, locals):
    """Scan one logical line of Python and look up values of variables used."""
    vars, lasttoken, parent, prefix, value = [], None, None, '', __UNDEF__
    for ttype, token, start, end, line in tokenize.generate_tokens(reader):
        if ttype == tokenize.NEWLINE: break
        if ttype == tokenize.NAME and token not in keyword.kwlist:
            if lasttoken == '.':
                if parent is not __UNDEF__:
                    value = getattr(parent, token, __UNDEF__)
                    vars.append((prefix + token, prefix, value))
            else:
                where, value = lookup(token, frame, locals)
                vars.append((token, where, value))
        elif token == '.':
            prefix += lasttoken + '.'
            parent = value
        else:
            parent, prefix = None, ''
        lasttoken = token
    return vars
def scanvars ( reader , frame , locals ) : vars , lasttoken , parent , prefix , value = [ ] , None , None , '' , __UNDEF__ for ttype , token , start , end , line in tokenize . generate_tokens ( reader ) : if ttype == tokenize . NEWLINE : break if ttype == tokenize . NAME and token not in keyword . kwlist : if lasttoken == '.' : if parent is not __UNDEF__ : value = getattr ( parent , token , __UNDEF__ ) vars . append ( ( prefix + token , prefix , value ) ) else : where , value = lookup ( token , frame , locals ) vars . append ( ( token , where , value ) ) elif token == '.' : prefix += lasttoken + '.' parent = value else : parent , prefix = None , '' lasttoken = token return vars