diff --git a/ptgctl/__init__.py b/ptgctl/__init__.py index bb67a43..4ffb37d 100755 --- a/ptgctl/__init__.py +++ b/ptgctl/__init__.py @@ -1 +1,4 @@ +from . import util +log = util.getLogger("ptgctl", level='info') + from .core import * diff --git a/ptgctl/util/cli.py b/ptgctl/util/cli.py index f255f93..7113911 100644 --- a/ptgctl/util/cli.py +++ b/ptgctl/util/cli.py @@ -1,9 +1,9 @@ import inspect import functools +import warnings from typing import Type, TypeVar - class CachedProperty: def __init__(self, getattr): super().__init__() @@ -63,6 +63,7 @@ def greetings(self): __file__ = None __package__ = None def __init__(self, parent, get_module, lazy=True): + self.__name__ = get_module.__name__ self._self = parent self._get_module = get_module self._loaded = False @@ -76,7 +77,7 @@ def _load_module(self, reload=False): try: self._wrapped = wrapped = self._get_module(self._self) except ImportError as e: - log.warning(f"{e}") + warnings.warn(f'Error Importing {self.__name__}: {e}') self._wrapped = None keys = ( getattr(wrapped, '__bind__', None) or @@ -94,7 +95,7 @@ def _load_module(self, reload=False): self._dir = list(self._public) # mimic - idk for k in self._COPY_OVER: - setattr(self, k, getattr(self._wrapped, k)) + setattr(self, k, getattr(self._wrapped, k, getattr(self, k, None))) self._loaded = self._wrapped is not None def _is_public(self, func):