21 lines
591 B
Python
21 lines
591 B
Python
"""
|
|
Lazy import mechanism for PVC CLI to reduce startup time
|
|
"""
|
|
|
|
class LazyModule:
|
|
"""
|
|
A proxy for a module that is loaded only when actually used
|
|
"""
|
|
def __init__(self, name):
|
|
self.name = name
|
|
self._module = None
|
|
|
|
def __getattr__(self, attr):
|
|
if self._module is None:
|
|
import importlib
|
|
self._module = importlib.import_module(self.name)
|
|
return getattr(self._module, attr)
|
|
|
|
# Create lazy module proxies
|
|
yaml = LazyModule('yaml')
|
|
click_advanced = LazyModule('click') # For advanced click features not used at startup |