def get_imports(filename):
    """Get all the imports in a file.

    Each import is a tuple of:
      (name, alias, is_from, is_star, source_file)
    """
    with open(filename, "rb") as f:
        src = f.read()
    finder = ImportFinder()
    finder.visit(ast.parse(src, filename=filename))
    imports = []
    for i in finder.imports:
        name, _, is_from, is_star = i
        imports.append(i + (resolve_import(name, is_from, is_star),))
    return imports
Get all the imports in a file.

    Each import is a tuple of:
      (name, alias, is_from, is_star, source_file)