MCPcopy Create free account
hub / github.com/ipython/ipython / get_py_filename

Function get_py_filename

IPython/utils/path.py:92–109  ·  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, force_win32=None)

Source from the content-addressed store, hash-verified

90 return path
91
92def get_py_filename(name, force_win32=None):
93 """Return a valid python filename in the current directory.
94
95 If the given name is not a file, it adds '.py' and searches again.
96 Raises IOError with an informative message if the file isn't found.
97 """
98
99 name = os.path.expanduser(name)
100 if force_win32 is not None:
101 warn("The 'force_win32' argument to 'get_py_filename' is deprecated "
102 "since IPython 5.0 and should not be used anymore",
103 DeprecationWarning, stacklevel=2)
104 if not os.path.isfile(name) and not name.endswith('.py'):
105 name += '.py'
106 if os.path.isfile(name):
107 return name
108 else:
109 raise IOError('File `%r` not found.' % name)
110
111
112def filefind(filename, path_dirs=None):

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