Fix reload to use mod.__cache__ to get name of pyc files
This commit is contained in:
parent
7a154f74fa
commit
0bc186fe7d
@ -46,19 +46,25 @@ def reloadAll(prefix=None, debug=False):
|
|||||||
if modName == '__main__':
|
if modName == '__main__':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
## Ignore if the file name does not start with prefix
|
# Ignore modules without a __file__ that is .py or .pyc
|
||||||
if not hasattr(mod, '__file__') or mod.__file__ is None or os.path.splitext(mod.__file__)[1] not in ['.py', '.pyc']:
|
if not hasattr(mod, '__file__') or mod.__file__ is None or os.path.splitext(mod.__file__)[1] not in ['.py', '.pyc']:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Ignore if the file name does not start with prefix
|
||||||
if prefix is not None and mod.__file__[:len(prefix)] != prefix:
|
if prefix is not None and mod.__file__[:len(prefix)] != prefix:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
## ignore if the .pyc is newer than the .py (or if there is no pyc or py)
|
|
||||||
py = os.path.splitext(mod.__file__)[0] + '.py'
|
py = os.path.splitext(mod.__file__)[0] + '.py'
|
||||||
pyc = py + 'c'
|
if not os.path.isfile(py):
|
||||||
if py not in changed and os.path.isfile(pyc) and os.path.isfile(py) and os.stat(pyc).st_mtime >= os.stat(py).st_mtime:
|
# skip modules that lie about their __file__
|
||||||
#if debug:
|
|
||||||
#print "Ignoring module %s; unchanged" % str(mod)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# if source file is newer than cache file, then it needs to be reloaded.
|
||||||
|
pyc = getattr(mod, '__cached__', py + 'c')
|
||||||
|
if not os.path.isfile(pyc):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if py not in changed and os.stat(pyc).st_mtime < os.stat(py).st_mtime:
|
||||||
changed.append(py) ## keep track of which modules have changed to insure that duplicate-import modules get reloaded.
|
changed.append(py) ## keep track of which modules have changed to insure that duplicate-import modules get reloaded.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user