Iterate through plugins (`connect_plugin` attribute of entry point) which name starts with `point` or equals to `name`. If `fallback` kwarg specified, plugin with that name yield last.
(group, point='', name=None, fallback=None)
| 4 | |
| 5 | |
| 6 | def get_plugins(group, point='', name=None, fallback=None): |
| 7 | """ |
| 8 | Iterate through plugins (`connect_plugin` attribute of entry point) |
| 9 | which name starts with `point` or equals to `name`. |
| 10 | If `fallback` kwarg specified, plugin with that name yield last. |
| 11 | """ |
| 12 | for ep in pkg_resources.iter_entry_points('bitmessage.' + group): |
| 13 | if name and ep.name == name or ep.name.startswith(point): |
| 14 | try: |
| 15 | plugin = ep.load().connect_plugin |
| 16 | if ep.name == fallback: |
| 17 | _fallback = plugin |
| 18 | else: |
| 19 | yield plugin |
| 20 | except (AttributeError, |
| 21 | ImportError, |
| 22 | ValueError, |
| 23 | pkg_resources.DistributionNotFound, |
| 24 | pkg_resources.UnknownExtra): |
| 25 | continue |
| 26 | try: |
| 27 | yield _fallback |
| 28 | except NameError: |
| 29 | pass |
| 30 | |
| 31 | |
| 32 | def get_plugin(*args, **kwargs): |
no outgoing calls
no test coverage detected