from nullptr.models import * from os.path import isfile, dirname, isdir import os from os.path import basename import json from .util import * from time import time import pickle from struct import unpack, pack from functools import partial from io import BytesIO class StorePickler(pickle.Pickler): def persistent_id(self, obj): return "STORE" if type(obj) == Store else None class StoreUnpickler(pickle.Unpickler): def __init__(self, stream, store): self.store = store super().__init__(stream) def persistent_load(self, pers_id): if pers_id == "STORE": return self.store raise pickle.UnpicklingError("I don know the persid!") class ChunkHeader: def __init__(self): self.offset = 0 self.in_use = True self.size = 0 self.used = 0 @classmethod def parse(cls, fil): offset = fil.tell() d = fil.read(16) if len(d) < 16: return None o = cls() o.offset = offset d, o.used = unpack('