MCPcopy Index your code
hub / github.com/WebODM/WebODM / get_current_plugin

Function get_current_plugin

app/plugins/functions.py:282–300  ·  view source on GitHub ↗

When called from a python module inside a plugin's directory, it returns the plugin that this python module belongs to :return: Plugin instance

(only_active=False)

Source from the content-addressed store, hash-verified

280 return res
281
282def get_current_plugin(only_active=False):
283 """
284 When called from a python module inside a plugin's directory,
285 it returns the plugin that this python module belongs to
286 :return: Plugin instance
287 """
288 caller_filename = traceback.extract_stack()[-2][0]
289
290 for p in get_plugins_paths():
291 relp = os.path.relpath(caller_filename, p)
292 if ".." in relp:
293 continue
294
295 parts = relp.split(os.sep)
296 if len(parts) > 0:
297 plugin_name = parts[0]
298 return get_plugin_by_name(plugin_name, only_active=only_active)
299
300 return None
301
302def get_plugins_paths():
303 current_path = os.path.dirname(os.path.realpath(__file__))

Callers 15

saveFunction · 0.90
configFunction · 0.90
get_settingsFunction · 0.90
update_tokenFunction · 0.90
postMethod · 0.90
getMethod · 0.90
ddb_cleanupFunction · 0.90
getMethod · 0.90
postMethod · 0.90
share_to_ddbFunction · 0.90

Calls 2

get_plugins_pathsFunction · 0.85
get_plugin_by_nameFunction · 0.85

Tested by

no test coverage detected