import pickle
import os


def load_dump(path: str) -> object:
    ''' load object from pickle dump '''
    if os.path.exists(path):
        with open(path, 'rb') as reader:
            return pickle.load(reader)


def save_dump(path: str, obj: object, rewrite: bool=False) -> bool:
    ''' save object to pickle dump '''
    if not os.path.exists(path) or rewrite:
        with open(path, 'wb') as writer:
            pickle.dump(obj, writer)
            return True
    return False


DUMPS_PATH = os.path.join(os.path.dirname(__file__), "dumps")
REQ_DUMP_PATH = os.path.join(DUMPS_PATH, "REQUEST_SCHEMA.dump")
RESP_DUMP_PATH = os.path.join(DUMPS_PATH, "RESPONSE_SCHEMA.dump")
ENDPOINTS_DUMP_PATH = os.path.join(DUMPS_PATH, "RUZ_API_ENDPOINTS.dump")


REQUEST_SCHEMA = load_dump(REQ_DUMP_PATH)
assert REQUEST_SCHEMA

RESPONSE_SCHEMA = load_dump(RESP_DUMP_PATH)
assert RESPONSE_SCHEMA

RUZ_API_ENDPOINTS = load_dump(ENDPOINTS_DUMP_PATH)
assert RUZ_API_ENDPOINTS


__all__ = ("REQUEST_SCHEMA", "RESPONSE_SCHEMA", "RUZ_API_ENDPOINTS")


if __name__ == "__main__":
    from .raw_schema import REQUEST_SCHEMA, RESPONSE_SCHEMA, RUZ_API_ENDPOINTS

    save_dump(REQ_DUMP_PATH, REQUEST_SCHEMA, rewrite=False)
    save_dump(RESP_DUMP_PATH, RESPONSE_SCHEMA, rewrite=False)
    save_dump(ENDPOINTS_DUMP_PATH, RUZ_API_ENDPOINTS, rewrite=False)

@@ -479,16 +479,335 @@
 False%0A%0A%0A
+def recreate_dump(force: bool=False) -%3E None:%0A    from .raw_schema import REQUEST_SCHEMA, RESPONSE_SCHEMA, RUZ_API_ENDPOINTS%0A%0A    save_dump(REQ_DUMP_PATH, REQUEST_SCHEMA, rewrite=force)%0A    save_dump(RESP_DUMP_PATH, RESPONSE_SCHEMA, rewrite=force)%0A    save_dump(ENDPOINTS_DUMP_PATH, RUZ_API_ENDPOINTS, rewrite=force)%0A%0A%0A
 DUMPS_PA
@@ -1382,271 +1382,30 @@
     
-from .raw_schema import REQUEST_SCHEMA, RESPONSE_SCHEMA, RUZ_API_ENDPOINTS%0A%0A    save_dump(REQ_DUMP_PATH, REQUEST_SCHEMA, rewrite=False)%0A    save_dump(RESP_DUMP_PATH, RESPONSE_SCHEMA, rewrite=False)%0A    save_dump(ENDPOINTS_DUMP_PATH, RUZ_API_ENDPOINTS, rewrite=Fals
+recreate_dump(force=Tru
 e)%0A

create function to recreate dump of schemas