Extract all imports from a python script

def extract_imports(script):
    """Extract all imports from a python script"""
    if not os.path.isfile(script):
        raise ValueError('Not a file: %s' % script)
    parse_tree = parse_python(script)
    result = find_imports(parse_tree)
    result.path = script
    return result