import os from nexrad.s3 import S3Bucket class Archive(): path: str bucket: S3Bucket def __init__(self, path: str, bucket: S3Bucket): self.path = path self.bucket = bucket def is_archived(self, key: str): return os.path.exists(self.path + '/' + key) def archive(self, key: str): path = self.path + '/' + key parent = os.path.dirname(path) os.makedirs(parent, exist_ok=True) with open(path, 'wb') as fh: self.bucket.s3.download_fileobj(self.bucket.name, key, fh)