File size: 729 Bytes
38f4987 748d35c 0ad6e3a 47c26de de1e0b3 0ad6e3a fb37baa 9b7025c 0ad6e3a a1415d7 4d74cf4 38f4987 fb37baa 0ad6e3a fb37baa 0ad6e3a ae6660f 6fc608c e121b13 7067826 0ad6e3a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import uuid
from weakref import WeakValueDictionary
from collections import defaultdict
class StringWrapper:
def __init__(self, s):
self.s = s
class OrderedMultiIndexMapWeakRef:
def __init__(self):
self.data = []
self.ids = []
self.index_list = []
def insert(self, id, text, title: str, sub_title: str):
self.data.append(text)
self.ids.append(int(uuid.UUID(id)))
self.index_list.append(WeakValueDictionary({'title': StringWrapper(title), 'sub_title': StringWrapper(sub_title)}))
def all_ids(self):
return self.ids
def all_metadatas(self):
return [dict(d) for d in self.index_list]
def all_texts(self):
return self.data |