diff options
author | Christopher Larson <chris_larson@mentor.com> | 2016-04-30 12:40:58 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-05-06 10:20:03 +0100 |
commit | 19e6fd5b7b53f75752dc82d0df0f5e65d10954ac (patch) | |
tree | ffdf6dd0b9982f7629077db45352a24a00d45562 /bitbake/lib/bb/utils.py | |
parent | 7dc12110d400caaed8198ecdaeb86a65f2a3d984 (diff) | |
download | poky-19e6fd5b7b53f75752dc82d0df0f5e65d10954ac.tar.gz |
bitbake: bb.utils: use imp.get_suffixes for load_plugins
Rather than hardcoding .py, use python's knowledge of its file extensions.
(Bitbake rev: 09f838dbaefdaedc01a1f4818ed38280b38db744)
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 92f1b60206..c54ff5b92b 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -28,6 +28,7 @@ import bb.msg | |||
28 | import multiprocessing | 28 | import multiprocessing |
29 | import fcntl | 29 | import fcntl |
30 | import imp | 30 | import imp |
31 | import itertools | ||
31 | import subprocess | 32 | import subprocess |
32 | import glob | 33 | import glob |
33 | import fnmatch | 34 | import fnmatch |
@@ -41,6 +42,8 @@ from ctypes import cdll | |||
41 | 42 | ||
42 | 43 | ||
43 | logger = logging.getLogger("BitBake.Util") | 44 | logger = logging.getLogger("BitBake.Util") |
45 | python_extensions = [e for e, _, _ in imp.get_suffixes()] | ||
46 | |||
44 | 47 | ||
45 | def clean_context(): | 48 | def clean_context(): |
46 | return { | 49 | return { |
@@ -1465,8 +1468,12 @@ def load_plugins(logger, plugins, pluginpath): | |||
1465 | fp.close() | 1468 | fp.close() |
1466 | 1469 | ||
1467 | logger.debug('Loading plugins from %s...' % pluginpath) | 1470 | logger.debug('Loading plugins from %s...' % pluginpath) |
1468 | for fn in glob.glob(os.path.join(pluginpath, '*.py')): | 1471 | |
1469 | name = os.path.splitext(os.path.basename(fn))[0] | 1472 | expanded = (glob.glob(os.path.join(pluginpath, '*' + ext)) |
1473 | for ext in python_extensions) | ||
1474 | files = itertools.chain.from_iterable(expanded) | ||
1475 | names = set(os.path.splitext(os.path.basename(fn))[0] for fn in files) | ||
1476 | for name in names: | ||
1470 | if name != '__init__': | 1477 | if name != '__init__': |
1471 | plugin = load_plugin(name) | 1478 | plugin = load_plugin(name) |
1472 | if hasattr(plugin, 'plugin_init'): | 1479 | if hasattr(plugin, 'plugin_init'): |