def enumerate_method_calls(tokens, modules):
out = []<EOL>for index, tok in enumerate(tokens):<EOL><INDENT>token_type = tok[<NUM_LIT:0>]<EOL>token_string = tok[<NUM_LIT:1>]<EOL>if token_type == tokenize.NAME:<EOL><INDENT>next_tok_string = tokens[index+<NUM_LIT:1>][<NUM_LIT:1>]<EOL>if next_tok_string == '<STR_LIT:(>': <EOL><INDENT>prev_tok_string = tokens[index-<NUM_LIT:1>][<NUM_LIT:1>]<EOL>if prev_tok_string == '<STR_LIT:.>': <EOL><INDENT>prev_prev_tok_string = tokens[index-<NUM_LIT:2>][<NUM_LIT:1>]<EOL>if prev_prev_tok_string not in ['<STR_LIT>',"<STR_LIT>", '<STR_LIT:]>', '<STR_LIT:)>', '<STR_LIT:}>']:<EOL><INDENT>if prev_prev_tok_string not in modules:<EOL><INDENT>to_replace = "<STR_LIT>" % (<EOL>prev_prev_tok_string, token_string)<EOL>if to_replace not in out:<EOL><INDENT>out.append(to_replace)<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return out<EOL>
Returns a list of all object (not module) method calls in the given tokens.

*modules* is expected to be a list of all global modules imported into the
source code we're working on.

For example:
    >>> enumerate_method_calls(tokens)
    ['re.compile', 'sys.argv', 'f.write']