| Conditions | 4 |
| Total Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | # -*- coding: utf-8 -*- |
||
| 30 | @add_current_dir_to_syspath |
||
| 31 | def import_callable(full_name): |
||
| 32 | package, *name = full_name.rsplit('.', 1) |
||
| 33 | try: |
||
| 34 | module = importlib.import_module(package) |
||
| 35 | except ValueError as exc: |
||
| 36 | raise ImportError('Error trying to import {!r}'.format(full_name)) from exc |
||
| 37 | |||
| 38 | if name: |
||
| 39 | handler = getattr(module, name[0]) |
||
| 40 | else: |
||
| 41 | handler = module |
||
| 42 | |||
| 43 | if not callable(handler): |
||
| 44 | raise ImportError('{!r} should be callable'.format(full_name)) |
||
| 45 | |||
| 46 | return handler |
||
| 47 |