code: def extract_imports(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
docs: Extract all imports from a python script