diff --git a/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/schema.py b/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/schema.py new file mode 100644 index 0000000000000000000000000000000000000000..df77562f7218d679d01cfc708a87ea0c60b91870 --- /dev/null +++ b/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/schema.py @@ -0,0 +1,39 @@ +from __future__ import annotations + +from pathlib import Path + +""" +Adapted from shared/system to avoid including ssa-workspaces in pex +""" + + +class JSONSerializable: + def __json__(self, request=None) -> dict: + """ + Allows this object to be converted to JSON + + :param request: this parameter is the active Pyramid request, if applicable (None otherwise) + :return: a dictionary which can be converted to JSON using json.dump + """ + pass + + @classmethod + def from_json(cls, json: dict) -> any: + pass + + +class AbstractTextFile(JSONSerializable): + """ + Abstract text file is exactly that, an abstract concept of what a file is, to be + returned from various non-filesystem places. + """ + + def __init__(self, filename: str, content: str): + self.filename, self.content = filename, content + + def write_to(self, directory: Path): + (directory / self.filename).write_text(self.content) + + @classmethod + def from_path(cls, path: Path) -> AbstractTextFile: + return cls(path.name, path.read_text())