When only .pyc left, the extended API can not be used.

Currently, when only .pyc left, all extented apis, such as
resetting status of snapshot, can not be used.

This is because it only load .py files in api/extention.py.
__init__ and anything that's not .py are all skipped.

This change updates the extention api to load .pyc files
when .py files do not exist.

Change-Id: I80a3c29a50dcb3cb6bf3708dfeb2a3c75194065b
Closes-bug: #1616358
This commit is contained in:
lijunli1 2016-08-25 10:37:17 +08:00
parent ca9038628e
commit f15d9d5eb0

@ -263,12 +263,17 @@ def load_standard_extensions(ext_mgr, logger, path, package, ext_list=None):
else:
relpkg = '.%s' % '.'.join(relpath.split(os.sep))
# Now, consider each file in turn, only considering .py files
# Now, consider each file in turn, only considering .py and .pyc files
for fname in filenames:
root, ext = os.path.splitext(fname)
# Skip __init__ and anything that's not .py
if ext != '.py' or root == '__init__' or fname in FILES_TO_SKIP:
# Skip __init__ and anything that's not .py and .pyc
if ((ext not in ('.py', '.pyc')) or root == '__init__' or
fname in FILES_TO_SKIP):
continue
# If .pyc and .py both exist, skip .pyc
if ext == '.pyc' and ((root + '.py') in filenames):
continue
# Try loading it