Skip to content
Snippets Groups Projects
Commit fae1c25b authored by Charlotte Hausman's avatar Charlotte Hausman
Browse files

add AbstractTextFile to ingest_envoy

parent fdb7a822
No related branches found
No related tags found
2 merge requests!378Image Ingestion workflow,!376Image Ingestion Workflow Part 1
Pipeline #2317 failed
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())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment