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)
| 280 | return res |
| 281 | |
| 282 | def 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 | |
| 302 | def get_plugins_paths(): |
| 303 | current_path = os.path.dirname(os.path.realpath(__file__)) |
no test coverage detected