MCPcopy Index your code
hub / github.com/USArmyResearchLab/Dshell / get_plugins

Function get_plugins

dshell/dshelllist.py:17–47  ·  view source on GitHub ↗

Generate a list of all available plugin modules, either in the dshell.plugins directory or external packages

()

Source from the content-addressed store, hash-verified

15
16
17def get_plugins():
18 """
19 Generate a list of all available plugin modules, either in the
20 dshell.plugins directory or external packages
21 """
22 plugins = {}
23 # List of directories above the plugins directory that we don't care about
24 import_base = get_plugin_path().split(os.path.sep)[:-1]
25
26 # Walk through the plugin path and find any Python modules that aren't
27 # __init__.py. These are assumed to be plugin modules and will be
28 # treated as such.
29 for root, dirs, files in os.walk(get_plugin_path()):
30 if '__init__.py' in files:
31 import_path = root.split(os.path.sep)[len(import_base):]
32 for f in iglob("{}/*.py".format(root)):
33 name = os.path.splitext(os.path.basename(f))[0]
34 if name != '__init__':
35 if name in plugins and logger:
36 logger.warning("Duplicate plugin name found: {}".format(name))
37 module = '.'.join(["dshell"] + import_path + [name])
38 plugins[name] = module
39
40 # Next, try to discover additional plugins installed externally.
41 # Uses entry points in setup.py files.
42 for ep_plugin in pkg_resources.iter_entry_points("dshell_plugins"):
43 if ep_plugin.name in plugins:
44 logger.warning("Duplicate plugin name found: {}".format(ep_plugin.name))
45 plugins[ep_plugin.name] = ep_plugin.module_name
46
47 return plugins
48
49
50def get_output_modules(output_module_path):

Callers 3

mainFunction · 0.90
main_command_lineFunction · 0.90
get_plugin_informationFunction · 0.85

Calls 1

get_plugin_pathFunction · 0.90

Tested by

no test coverage detected