Skip to content
Snippets Groups Projects

Image Ingestion Workflow Part 1

Merged Charlotte Hausman requested to merge WS-531_image_ingestion into main
1 file
+ 39
0
Compare changes
  • Side-by-side
  • Inline
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())
Loading