Skip to content

Commit

Permalink
Moved yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
AshishA26 committed Aug 16, 2024
1 parent dea012d commit f75eb30
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions logger/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# pylint: disable-next=unused-import
import types

from utilities import yaml
from .. import yaml


CONFIG_FILE_PATH = pathlib.Path("config.yaml")
CONFIG_FILE_PATH = pathlib.Path("config_logger.yaml")


class Logger:
Expand Down
25 changes: 25 additions & 0 deletions yaml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
For YAML files.
"""

import pathlib
import yaml


def open_config(file_path: pathlib.Path) -> "tuple[bool, dict | None]":
"""
Open and decode YAML file.
"""
try:
with file_path.open("r", encoding="utf8") as file:
try:
config = yaml.safe_load(file)
return True, config
except yaml.YAMLError as exception:
print(f"ERROR: Could not parse YAML file: {exception}")
except FileNotFoundError as exception:
print(f"ERROR: YAML file not found: {exception}")
except IOError as exception:
print(f"ERROR: Could not open file: {exception}")

return False, None

0 comments on commit f75eb30

Please sign in to comment.