Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
10zinten committed Jul 10, 2024
1 parent 0652a92 commit c17805d
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 156 deletions.
Empty file.
2 changes: 2 additions & 0 deletions src/openpecha/alignment/serializers/pecha_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class PechaDbSerializer:
pass
2 changes: 1 addition & 1 deletion src/openpecha/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def _mkdir(path):
return path


BASE_PATH = _mkdir(Path.home() / ".pechadata")
BASE_PATH = _mkdir(Path.home() / ".openpecha")
PECHAS_PATH = _mkdir(BASE_PATH / "pechas")

PECHA_ANNOTATION_STORE_ID = "PechaAnnotationStore"
Expand Down
64 changes: 0 additions & 64 deletions src/openpecha/pecha/__init__.py
Original file line number Diff line number Diff line change
@@ -1,64 +0,0 @@
import json
from pathlib import Path
from shutil import rmtree
from typing import Dict

from stam import AnnotationStore, Offset, Selector

from openpecha.config import (
PECHA_ANNOTATION_STORE_ID,
PECHA_DATASET_ID,
PECHAS_PATH,
_mkdir,
)
from openpecha.ids import get_uuid
from openpecha.pecha.annotation import Annotation
from openpecha.pecha.layer import Layer, LayerEnum


class Pecha:
def __init__(
self,
pecha_id: str,
bases: Dict[str, str],
layers: Dict[str, Dict[LayerEnum, Layer]],
metadata: Dict[str, str],
) -> None:
self.pecha_id = pecha_id
self.bases = bases
self.layers = layers
self.metadata = metadata

@classmethod
def from_path(cls, path: str):
pass

@classmethod
def from_id(cls, pecha_id: str):
pass

def write(self, export_path: Path = PECHAS_PATH):

pecha_dir = _mkdir(export_path / self.pecha_id)
self.base_path = _mkdir(pecha_dir / f"{self.pecha_id}.opf")
""" write metadata """
self.metadata_fn = self.base_path / "metadata.json"
self.metadata_fn.write_text(
json.dumps(self.metadata, indent=4, ensure_ascii=False), encoding="utf-8"
)

""" write base file"""
base_dir = _mkdir(self.base_path / "base")
for base_fname, base_text in self.bases.items():
base_fn = base_dir / f"{base_fname}.txt"
base_fn.write_text(base_text, encoding="utf-8")

layer_dir = _mkdir(self.base_path / "layers")
""" write annotation layers"""
for layer_fname, layer_data in self.layers.items():
for _, layer in layer_data.items():
_mkdir(layer_dir / layer_fname)
layer.write(
base_file_path=base_dir / layer_fname,
export_path=layer_dir / layer_fname,
)
15 changes: 0 additions & 15 deletions src/openpecha/pecha/annotation.py

This file was deleted.

76 changes: 0 additions & 76 deletions src/openpecha/pecha/layer.py

This file was deleted.

Empty file.
Empty file.

0 comments on commit c17805d

Please sign in to comment.