Load module from .py/.pyc file. Parameters ---------- name : str Name of the module. path : str Path to .py/.pyc file. Returns ------- mod : module Imported module.
(name, path)
| 25 | |
| 26 | |
| 27 | def load_module(name, path): |
| 28 | """Load module from .py/.pyc file. |
| 29 | |
| 30 | Parameters |
| 31 | ---------- |
| 32 | name : str |
| 33 | Name of the module. |
| 34 | path : str |
| 35 | Path to .py/.pyc file. |
| 36 | |
| 37 | Returns |
| 38 | ------- |
| 39 | mod : module |
| 40 | Imported module. |
| 41 | |
| 42 | """ |
| 43 | from importlib.util import module_from_spec, spec_from_file_location |
| 44 | |
| 45 | spec = spec_from_file_location(name, path) |
| 46 | mod = module_from_spec(spec) |
| 47 | spec.loader.exec_module(mod) |
| 48 | return mod |
| 49 | |
| 50 | |
| 51 | def get_optparser(cmdpath, usage=None, prog_prefix="mne", version=None): |