diff --git a/confhub/__main__.py b/confhub/__main__.py index e7d0a5a..63c1b3d 100644 --- a/confhub/__main__.py +++ b/confhub/__main__.py @@ -1,3 +1,6 @@ +import sys +from pathlib import Path + from confhub.console import main from confhub.__meta__ import __version__ from confhub.setup_logger import SetupLogger, LoggerReg @@ -10,4 +13,7 @@ ) if __name__ == '__main__': + project_path = Path.cwd() + sys.path.append(str(project_path.resolve())) + main(prog='confhub', version=__version__) diff --git a/confhub/__meta__.py b/confhub/__meta__.py index 59a5c0b..75ca3b7 100644 --- a/confhub/__meta__.py +++ b/confhub/__meta__.py @@ -1 +1 @@ -__version__ = "0.1.0.1a" +__version__ = "0.1.0.2a" diff --git a/confhub/builder.py b/confhub/builder.py index 0b32442..472c587 100644 --- a/confhub/builder.py +++ b/confhub/builder.py @@ -65,7 +65,7 @@ def create_files(self, config_path: Path) -> None: else: existing_file = True - if existing_file: + if existing_file or existing_file is None: with open(file_path, 'w', encoding='utf-8') as file: yaml.dump(data, file, default_flow_style=False) diff --git a/confhub/utils/__models.py b/confhub/utils/__models.py index c23ddb7..cd99ccf 100644 --- a/confhub/utils/__models.py +++ b/confhub/utils/__models.py @@ -2,13 +2,19 @@ from pathlib import Path from typing import List, Dict, Any +import structlog + from confhub import BlockCore +logger: structlog.BoundLogger = structlog.get_logger("confhub") + def get_models_from_path(data: Dict[str, Any]) -> List[BlockCore]: module_path = Path(data.get('models_path')) module_name = '.'.join(module_path.parts[-2:]).replace('.py', '') + logger.debug('Module path', path=module_path, name=module_name) + module = importlib.import_module(module_name) return [ getattr(module, attr)