import os import boto3 import tarfile from pathlib import Path KENDEX_TARBALL = "Kendex.tar.gz" def main(): repo_dir = Path(__file__).resolve().parent.parent data_dir = os.path.join(repo_dir, "data") kendex_dir = os.path.join(data_dir, "Kendex") if not Path(os.path.join(data_dir, KENDEX_TARBALL)).exists(): s3 = boto3.resource("s3") kendex = s3.Bucket("kendex") kendex.download_file(KENDEX_TARBALL, os.path.join(data_dir, KENDEX_TARBALL)) print(f"downloaded {KENDEX_TARBALL}") if not Path(kendex_dir).exists(): file = tarfile.open(os.path.join(data_dir, KENDEX_TARBALL)) file.extractall(data_dir) file.close() print(f"extracted {KENDEX_TARBALL}") if __name__ == "__main__": main()