Skip to content

Commit

Permalink
Fixed work with paths and file creation
Browse files Browse the repository at this point in the history
  • Loading branch information
morington committed Jun 27, 2024
1 parent 4f2fc05 commit 46b845b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions confhub/__main__.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,4 +13,7 @@
)

if __name__ == '__main__':
project_path = Path.cwd()
sys.path.append(str(project_path.resolve()))

main(prog='confhub', version=__version__)
2 changes: 1 addition & 1 deletion confhub/__meta__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.0.1a"
__version__ = "0.1.0.2a"
2 changes: 1 addition & 1 deletion confhub/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 6 additions & 0 deletions confhub/utils/__models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 46b845b

Please sign in to comment.