INNER CODE UNIT · Python

_try_load

DogsTailFarmer/martin-binance · martin_binance/backup.py:189

    def _try_load(path: Path) -> Optional[object]:
        if not path.exists():
            return None
        raw_bytes = path.read_bytes()
        parsed_dict = orjson.loads(raw_bytes)
        return response.model_validate(parsed_dict)

    try:
        if file_path.exists():
            model_instance = _try_load(file_path)
            if model_instance:
                if probe:
                    msg2log("State backup is available", log_level=logging.INFO)
                else:
                    msg2log(f"🎉 State successfully loaded from: {file_path.name}", log_level=logging.INFO)
                return model_instance
    except orjson.JSONDecodeError as e:
        msg2log(f"⚠️ The main file {file_path.name} failed validation. Error: {e}", log_level=logging.WARNING)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…