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)
| 90 | return path |
| 91 | |
| 92 | def 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 | |
| 112 | def filefind(filename, path_dirs=None): |
no outgoing calls
no test coverage detected