def enumerate_dynamic_imports(tokens):
    imported_modules = []
    import_line = False
    for index, tok in enumerate(tokens):
        token_type = tok[0]
        token_string = tok[1]
        if token_type == tokenize.NEWLINE:
            import_line = False
        elif token_string == "import":
            try:
                if tokens[index-1][0] == tokenize.NEWLINE:
                    import_line = True
            except IndexError:
                import_line = True # Just means this is the first line
        elif import_line:
            if token_type == tokenize.NAME and tokens[index+1][1] != 'as':
                if token_string not in reserved_words:
                    if token_string not in imported_modules:
                        imported_modules.append(token_string)
    return imported_modules
Called by the proxy when the toolkit item is closed.
dataset/ETHPy150Open b3mb4m/shellsploit-framework/shell/Session/encoders/pyminifier/analyze.py/enumerate_dynamic_imports--crossover with--dataset/ETHPy150Open ContinuumIO/ashiba/enaml/enaml/widgets/dock_item.py/DockItem._item_closed