def enumerate_imports(tokens):
imported_modules = []<EOL>import_line = False<EOL>from_import = False<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.NEWLINE:<EOL><INDENT>import_line = False<EOL>from_import = False<EOL><DEDENT>elif token_string == "<STR_LIT>":<EOL><INDENT>import_line = True<EOL><DEDENT>elif token_string == "<STR_LIT>":<EOL><INDENT>from_import = True<EOL><DEDENT>elif import_line:<EOL><INDENT>if token_type == tokenize.NAME and tokens[index+<NUM_LIT:1>][<NUM_LIT:1>] != '<STR_LIT>':<EOL><INDENT>if not from_import:<EOL><INDENT>if token_string not in reserved_words:<EOL><INDENT>if token_string not in imported_modules:<EOL><INDENT>imported_modules.append(token_string)<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return imported_modules<EOL>
Iterates over *tokens* and returns a list of all imported modules.

.. note:: This ignores imports using the 'as' and 'from' keywords.