summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pyssg/__init__.py2
-rw-r--r--src/pyssg/yaml_parser.py7
2 files changed, 6 insertions, 3 deletions
diff --git a/src/pyssg/__init__.py b/src/pyssg/__init__.py
index 5d112f1..46e2323 100644
--- a/src/pyssg/__init__.py
+++ b/src/pyssg/__init__.py
@@ -1,7 +1,9 @@
from .pyssg import main
from .custom_logger import setup_logger
+from .yaml_parser import setup_custom_yaml
setup_logger()
+setup_custom_yaml()
# not meant to be used as a package, so just give main
__all__ = ['main']
diff --git a/src/pyssg/yaml_parser.py b/src/pyssg/yaml_parser.py
index fb19a23..2e1548b 100644
--- a/src/pyssg/yaml_parser.py
+++ b/src/pyssg/yaml_parser.py
@@ -13,6 +13,10 @@ def __join_constructor(loader: SafeLoader, node: SequenceNode) -> str:
return ''.join([str(i) for i in seq])
+def setup_custom_yaml() -> None:
+ SafeLoader.add_constructor('!join', __join_constructor)
+
+
def __read_raw_yaml(path: str) -> list[dict]:
all_docs: list[dict] = []
with open(path, 'r') as f:
@@ -28,6 +32,3 @@ def get_parsed_yaml(resource: str, package: str = '') -> list[dict]:
log.debug('parsing yaml; reading "%s.%s"', package, resource)
with rpath(package, resource) as p:
return __read_raw_yaml(str(p))
-
-
-SafeLoader.add_constructor('!join', __join_constructor)