(identifier, module_params, module_name, instantiate=False, kwargs=None)
| 18 | |
| 19 | |
| 20 | def get_from_module(identifier, module_params, module_name, instantiate=False, kwargs=None): |
| 21 | if isinstance(identifier, six.string_types): |
| 22 | res = module_params.get(identifier) |
| 23 | if not res: |
| 24 | res = module_params.get(identifier.lower()) |
| 25 | if not res: |
| 26 | raise Exception('Invalid ' + str(module_name) + ': ' + str(identifier)) |
| 27 | if instantiate and not kwargs: |
| 28 | return res() |
| 29 | elif instantiate and kwargs: |
| 30 | return res(**kwargs) |
| 31 | else: |
| 32 | return res |
| 33 | return identifier |
| 34 | |
| 35 | |
| 36 | # ------------------ |