mirror of
https://github.com/JockeTF/fimfarchive.git
synced 2024-11-27 15:38:00 +01:00
Add optional direct index to Fimfarchive fetcher
This commit is contained in:
parent
4a92ced65b
commit
d249bd29d0
1 changed files with 12 additions and 0 deletions
|
@ -120,6 +120,18 @@ class Index(Mapping[int, Dict[str, Any]]):
|
|||
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):
|
||||
"""
|
||||
In-memory mapping from story key to meta.
|
||||
|
|
Loading…
Reference in a new issue