Add optional direct index to Fimfarchive fetcher

This commit is contained in:
Joakim Soderlund 2019-09-01 15:30:38 +02:00
parent 4a92ced65b
commit d249bd29d0

View file

@ -120,6 +120,18 @@ class Index(Mapping[int, Dict[str, Any]]):
return -1, f"Malformed meta for {key}: {e}".encode() return -1, f"Malformed meta for {key}: {e}".encode()
class DirectIndex(Dict[int, Dict[str, Any]], Index):
"""
In-memory mapping from story key to meta.
"""
def __init__(self, stream: IO[bytes]) -> None:
loader = self.load(stream)
items = ((k, deserialize(v)) for k, v in loader)
super().__init__(items)
class MemoryIndex(Index): class MemoryIndex(Index):
""" """
In-memory mapping from story key to meta. In-memory mapping from story key to meta.