def dump_data(cls, *, data_path: PurePath, base_to_dump, user=None, encrypt=True): """Dumb data to pickle. If you whant to encrypt data use: encrypt=True """ base_to_byte = dill.dumps(base_to_dump) if encrypt: base_to_byte = cls.encrypt_data(user.temp_datakey, base_to_byte) data_path.write_bytes(base_to_byte)
def download(self, file: YaDiskFile, local_destination: Path, ov: bool = False) -> None: """ Download file on remote to local_destination. """ p = PurePath(file.id) if local_destination is None: dl_path = PurePath(p.name) else: dl_path = PurePath(local_destination, p.name) if file.type == "dir": dl_path = dl_path.with_suffix(".zip") dl_path = Path(dl_path) print(YadiskDLMessage(dl_path, file.type, file.id, ov).str_value()) download_link = self._storage.get_download_link(file.id) dl_path.write_bytes(self._storage.download(download_link))