Function bodies 108 total
list_cases method · python · L47-L55 (9 LOC)src/scrawl/web/storage.py
def list_cases(self) -> list[CaseMeta]:
cases = []
if not self.base_dir.exists():
return cases
for case_dir in sorted(self.base_dir.iterdir()):
meta_file = case_dir / "meta.json"
if meta_file.exists():
cases.append(self._read_meta(meta_file))
return casesget_case method · python · L57-L61 (5 LOC)src/scrawl/web/storage.py
def get_case(self, case_id: str) -> CaseMeta | None:
meta_file = self.base_dir / case_id / "meta.json"
if not meta_file.exists():
return None
return self._read_meta(meta_file)update_status method · python · L63-L78 (16 LOC)src/scrawl/web/storage.py
def update_status(
self,
case_id: str,
status: str,
pipeline_stage: int | None = None,
stats: dict | None = None,
):
meta = self.get_case(case_id)
if meta is None:
return
meta.status = status
if pipeline_stage is not None:
meta.pipeline_stage = pipeline_stage
if stats is not None:
meta.stats = stats
self._write_meta(case_id, meta)save_output method · python · L80-L84 (5 LOC)src/scrawl/web/storage.py
def save_output(self, case_id: str, original: str, anonymized: str, mapping: dict):
case_dir = self.base_dir / case_id
(case_dir / "output.md").write_text(original, encoding="utf-8")
(case_dir / "output-anon.md").write_text(anonymized, encoding="utf-8")
(case_dir / "mapping.json").write_text(json.dumps(mapping, indent=2), encoding="utf-8")get_output method · python · L86-L95 (10 LOC)src/scrawl/web/storage.py
def get_output(self, case_id: str) -> tuple[str, str] | None:
case_dir = self.base_dir / case_id
output_file = case_dir / "output.md"
anon_file = case_dir / "output-anon.md"
if not output_file.exists() or not anon_file.exists():
return None
return (
output_file.read_text(encoding="utf-8"),
anon_file.read_text(encoding="utf-8"),
)get_mapping method · python · L97-L101 (5 LOC)src/scrawl/web/storage.py
def get_mapping(self, case_id: str) -> dict:
mapping_file = self.base_dir / case_id / "mapping.json"
if not mapping_file.exists():
return {}
return json.loads(mapping_file.read_text(encoding="utf-8"))_write_meta method · python · L106-L108 (3 LOC)src/scrawl/web/storage.py
def _write_meta(self, case_id: str, meta: CaseMeta):
meta_file = self.base_dir / case_id / "meta.json"
meta_file.write_text(json.dumps(asdict(meta), indent=2), encoding="utf-8")Source: Repobility analyzer · https://repobility.com
_read_meta method · python · L110-L112 (3 LOC)src/scrawl/web/storage.py
def _read_meta(self, meta_file: Path) -> CaseMeta:
data = json.loads(meta_file.read_text(encoding="utf-8"))
return CaseMeta(**data)‹ prevpage 3 / 3