Skip to content

Commit

Permalink
some more typing. still few problems in mapping.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Seher Karakuzu authored and Seher Karakuzu committed Apr 5, 2024
1 parent 3c5e3cb commit e317207
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 83 deletions.
1 change: 1 addition & 0 deletions tiled/adapters/awkward.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from ..adapters.awkward_buffers import DirectoryContainer
from ..server.pydantic_awkward import AwkwardStructure
from ..structures.core import StructureFamily
from .array import ArrayAdapter


class AwkwardAdapter:
Expand Down
7 changes: 4 additions & 3 deletions tiled/adapters/awkward_buffers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@
from ..server.pydantic_awkward import AwkwardStructure
from ..structures.core import StructureFamily
from ..utils import path_from_uri
from .array import ArrayAdapter
from .awkward import AwkwardAdapter


class DirectoryContainer(collections.abc.MutableMapping[str, JSON]):
class DirectoryContainer(collections.abc.MutableMapping[str, bytes]):
def __init__(self, directory: Path, form: Any):
self.directory = directory
self.form = form

def __getitem__(self, form_key: str) -> JSON:
def __getitem__(self, form_key: str) -> bytes:
with open(self.directory / form_key, "rb") as file:
return file.read()

def __setitem__(self, form_key: str, value: Buffer) -> None:
def __setitem__(self, form_key: str, value: bytes) -> None:
with open(self.directory / form_key, "wb") as file:
file.write(value)

Expand Down
Loading

0 comments on commit e317207

Please sign in to comment.