-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
246 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1 @@ | ||
import contextlib | ||
import typing | ||
|
||
from ... import data | ||
|
||
|
||
class Saver: | ||
@classmethod | ||
def bulk_save_metadata(cls, cards: typing.Iterable[data.BaseCard]): | ||
saver = cls() | ||
for t in cards: | ||
t.pass_data_to_saver(saver) | ||
|
||
@classmethod | ||
def forget_all(cls): | ||
raise NotImplementedError() | ||
|
||
@classmethod | ||
@contextlib.contextmanager | ||
def get_saver(cls): | ||
yield cls() | ||
|
||
|
||
class Loader: | ||
@classmethod | ||
def get_all_card_names(cls): | ||
raise NotImplementedError() | ||
|
||
@classmethod | ||
def get_loaded_cards_by_id(cls, card_class=typing.Type[data.BaseCard]): | ||
raise NotImplementedError() | ||
|
||
@classmethod | ||
def denormalize(cls, t: data.BaseCard): | ||
for child in t.children: | ||
child.parent = t | ||
cls.denormalize(child) | ||
|
||
@classmethod | ||
def load_all_cards(cls, card_class=typing.Type[data.BaseCard]): | ||
raise NotImplementedError() | ||
|
||
@classmethod | ||
@contextlib.contextmanager | ||
def get_loader(cls): | ||
yield cls() | ||
from . import ini, memory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import contextlib | ||
import typing | ||
|
||
from ... import data | ||
|
||
|
||
class Saver: | ||
@classmethod | ||
def bulk_save_metadata(cls, cards: typing.Iterable[data.BaseCard]): | ||
saver = cls() | ||
for t in cards: | ||
t.pass_data_to_saver(saver) | ||
|
||
@classmethod | ||
def forget_all(cls): | ||
raise NotImplementedError() | ||
|
||
@classmethod | ||
@contextlib.contextmanager | ||
def get_saver(cls): | ||
yield cls() | ||
|
||
|
||
class Loader: | ||
@classmethod | ||
def get_all_card_names(cls): | ||
raise NotImplementedError() | ||
|
||
@classmethod | ||
def get_loaded_cards_by_id(cls, card_class=typing.Type[data.BaseCard]): | ||
raise NotImplementedError() | ||
|
||
@classmethod | ||
def denormalize(cls, t: data.BaseCard): | ||
for child in t.children: | ||
child.parent = t | ||
cls.denormalize(child) | ||
|
||
@classmethod | ||
def load_all_cards(cls, card_class=typing.Type[data.BaseCard]): | ||
raise NotImplementedError() | ||
|
||
@classmethod | ||
@contextlib.contextmanager | ||
def get_loader(cls): | ||
yield cls() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import ini, memory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
GLOBAL_STORAGE = dict() | ||
GLOBAL_STORAGE[tuple()] = dict() | ||
|
||
|
||
class GlobalMemoryIO: | ||
def save_dict(self, data): | ||
GLOBAL_STORAGE.update(data) | ||
|
||
def set_ns(self, data): | ||
for key, contents in data.items(): | ||
GLOBAL_STORAGE[key] = contents | ||
|
||
def load_keys_to_dict(self, keys): | ||
return {key: GLOBAL_STORAGE[tuple()][key] for key in keys} | ||
|
||
def load_ns_to_dict(self, nsname): | ||
return {nsname: GLOBAL_STORAGE[nsname]} | ||
|
||
|
||
class LocalMemoryIO: | ||
def __init__(self): | ||
self.storage = dict() | ||
self.storage[tuple()] = dict() | ||
|
||
def save_dict(self, data): | ||
self.storage.update(data) | ||
|
||
def set_ns(self, data): | ||
for key, contents in data.items(): | ||
self.storage[key] = contents | ||
|
||
def load_keys_to_dict(self, keys): | ||
return {key: self.storage[tuple()][key] for key in keys} | ||
|
||
def load_ns_to_dict(self, nsname): | ||
return {nsname: self.storage[nsname]} |
Oops, something went wrong.