diff options
author | David Luevano Alvarado <david@luevano.xyz> | 2023-02-19 23:36:04 -0600 |
---|---|---|
committer | David Luevano Alvarado <david@luevano.xyz> | 2023-02-19 23:36:04 -0600 |
commit | f2ab2bac6b26f82730d5f5d7ab1e6d5f2f1060e3 (patch) | |
tree | 88a1ce15061cd7a9cee00941bc9ff3c39e09ab5e /src | |
parent | e28fbb181851ca16bc0ade9c371628f86c25adbc (diff) |
add yaml_parser tests, small refactor
Diffstat (limited to 'src')
-rw-r--r-- | src/pyssg/__init__.py | 2 | ||||
-rw-r--r-- | src/pyssg/yaml_parser.py | 7 |
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) |