MCPcopy Index your code
hub / github.com/ipython/ipython / get_py_filename

Function get_py_filename

IPython/utils/path.py:76–90  ·  view source on GitHub ↗

Return a valid python filename in the current directory. If the given name is not a file, it adds '.py' and searches again. Raises IOError with an informative message if the file isn't found.

(name)

Source from the content-addressed store, hash-verified

74 return path
75
76def get_py_filename(name):
77 """Return a valid python filename in the current directory.
78
79 If the given name is not a file, it adds '.py' and searches again.
80 Raises IOError with an informative message if the file isn't found.
81 """
82
83 name = os.path.expanduser(name)
84 if os.path.isfile(name):
85 return name
86 if not name.endswith(".py"):
87 py_name = name + ".py"
88 if os.path.isfile(py_name):
89 return py_name
90 raise IOError("File `%r` not found." % name)
91
92
93def filefind(filename: str, path_dirs=None) -> str:

Callers 4

find_user_codeMethod · 0.90
runMethod · 0.90
make_filenameMethod · 0.90
pfileMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…