diff --git a/Makefile b/Makefile index 317a4b446f9a1cc4c084d69e4a2b7e86a4431eb6..0327d59031c8bb62402c8ea340ac7c01e5f4b5d8 100644 --- a/Makefile +++ b/Makefile @@ -21,3 +21,6 @@ check: test: python -m pytest + +clean: + -rm -r $(CACHE_DIR)/* diff --git a/cache.py b/cache.py index 53be5aabc8ce74aaac2b066e1b98169e87553bef..d46342d64361a027244670e11d8d4242e584894b 100644 --- a/cache.py +++ b/cache.py @@ -28,10 +28,12 @@ def parse_puppet(s: str) -> dict[str, Any]: hash = hashlib.sha256(s.encode('UTF-8')) digest = hash.hexdigest() if record := r.get(digest): - return json.loads(record) + data = json.loads(record) else: almost_data = parse_puppet_for_real(s) hash = hashlib.sha256(almost_data) r.set(digest, almost_data) data = json.loads(almost_data) - return data + if type(data) != dict: + raise Exception("Weird data returned from puppet parse") + return data diff --git a/main.py b/main.py index 1cf91c2fcd13a70888f5e45184f9988ad0895c1c..5e8ca79f7b377b119376c0fb7df384fc2ba589fa 100644 --- a/main.py +++ b/main.py @@ -21,9 +21,10 @@ from typing import ( Tuple, ) -HashEntry: TypeAlias = Union[Tuple[Literal['=>'], str, Any], - Tuple[Literal['+>'], str, Any], - Tuple[Literal['splat-hash'], Any]] + +HashEntry: TypeAlias = Union[Tuple[Literal['=>'], str, Any], + Tuple[Literal['+>'], str, Any], + Tuple[Literal['splat-hash'], Any]] match sys.argv: case [_, d, *_]: @@ -38,6 +39,7 @@ data = info param_doc: dict[str, str] = {} + def print_hash(hash: list[HashEntry], indent: int, context: list[str]) -> None: diff --git a/merge-json.py b/merge-json.py index 65831da2012c87ef9de2cdc78d3e891fd62d58e6..0998d887248dee761d9b3c6e209f0ff59d33b9fd 100755 --- a/merge-json.py +++ b/merge-json.py @@ -38,7 +38,7 @@ def merge_dicts(objects: list[str]) -> dict[Any, list]: return merged -def __main(): +def __main() -> None: import argparse parser = argparse.ArgumentParser() parser.add_argument('--out', action='store')