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

Method filename_and_mtime

IPython/extensions/autoreload.py:183–207  ·  view source on GitHub ↗
(self, module)

Source from the content-addressed store, hash-verified

181 return top_module, top_name
182
183 def filename_and_mtime(self, module):
184 if not hasattr(module, '__file__') or module.__file__ is None:
185 return None, None
186
187 if getattr(module, '__name__', None) in [None, '__mp_main__', '__main__']:
188 # we cannot reload(__main__) or reload(__mp_main__)
189 return None, None
190
191 filename = module.__file__
192 path, ext = os.path.splitext(filename)
193
194 if ext.lower() == '.py':
195 py_filename = filename
196 else:
197 try:
198 py_filename = source_from_cache(filename)
199 except ValueError:
200 return None, None
201
202 try:
203 pymtime = os.stat(py_filename).st_mtime
204 except OSError:
205 return None, None
206
207 return py_filename, pymtime
208
209 def check(self, check_all=False, do_reload=True):
210 """Check whether some modules need to be reloaded."""

Callers 2

checkMethod · 0.95
post_execute_hookMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected