neurocarto.util.utils
- neurocarto.util.utils.import_name(desp, module_path, root=None, *, reload=False)
load a symbol (could be a function, a class or module itself) from a module.
Module Path:
[ROOT:]MODULE:NAME, where- ROOT:
a filepath prepend into
sys.path.- MODULE:
module path
- NAME:
variable name. Use ‘*’ to return a module.
- Parameters:
desp (str) – description of the module_path. used in error message.
module_path (str)
root (str | None) – PYTHONPATH
reload – reload the module.
- Returns:
- Raises:
ImportError –
ValueError – incorrect module path
- neurocarto.util.utils.get_import_file(module_path, root=None)
Try to find python module file according to the module_path.
- Parameters:
module_path (str)
root (str | None)
- Returns:
found filepath.
- Return type:
Path | None
- neurocarto.util.utils.doc_link(**kwargs)
A decorator to replace the text with pattern
{CLASS}into sphinx cross-reference link (if environment variableSPHINX_BUILDis set) in the function document.Match rules:
{class}::class:~{class#attr}:class :attr:~{class#meth()}:class :meth:~{module#class}::class:~{module#func()}::func:~{#attr}::attr:~{#meth()}::meth:~{func()}::func:~{VAR}: if VAR is a str, use its str content.{...}: (other) do not replace
Limitation:
not support ForwardReference
not support attribute documents.
- Parameters:
kwargs (str) – extra
- Returns:
decorator.