2121import zipfile
2222from pathlib import Path
2323
24+ import click
2425import paramiko
2526from requests import Response
2627from tqdm import tqdm
2728
29+ LIGHT_GRAY = (128 , 128 , 128 )
30+
2831
2932def download_progress_bar (response : Response , output_path : Path ) -> None :
3033 """
@@ -83,14 +86,14 @@ def zip_directory(input: Path, output: Path) -> None:
8386 if not input .exists ():
8487 raise RuntimeError (f"{ input } does not exist..." )
8588
86- print ("Zipping..." )
89+ click . echo ("Zipping..." )
8790 with zipfile .ZipFile (output , "w" , zipfile .ZIP_DEFLATED ) as zipf :
8891 for root , _ , files in os .walk (input ):
8992 for file in tqdm (files , desc = "Zipping" ):
9093 file_path = Path (root ) / file
9194 zipf .write (file_path , file_path .relative_to (input ))
9295
93- print ("Done" )
96+ click . echo ("Done" )
9497
9598
9699def unzip_directory (input : Path , output : Path ) -> None :
@@ -128,7 +131,7 @@ def unzip_directory(input: Path, output: Path) -> None:
128131 if perm :
129132 extracted_path .chmod (perm )
130133
131- print ("Done" )
134+ click . echo ("Done" )
132135
133136
134137def tar_directory (input : Path , output : Path ) -> None :
@@ -145,14 +148,14 @@ def tar_directory(input: Path, output: Path) -> None:
145148 if not input .exists ():
146149 raise RuntimeError (f"{ input } does not exist..." )
147150
148- print ("Compressing" )
151+ click . echo ("Compressing" )
149152 with tarfile .open (output , "w:gz" ) as tar :
150153 for root , _ , files in os .walk (input ):
151154 for file in tqdm (files , desc = "Archiving" ):
152155 file_path = Path (root ) / file
153156 tar .add (file_path , arcname = file_path .relative_to (input ))
154157
155- print ("Done" )
158+ click . echo ("Done" )
156159
157160
158161def untar_directory (input : Path , output : Path ) -> None :
@@ -169,7 +172,7 @@ def untar_directory(input: Path, output: Path) -> None:
169172 if not input .exists ():
170173 raise RuntimeError (f"{ input } does not exist..." )
171174
172- print ("Extracting" )
175+ click . echo ("Extracting" )
173176 with tarfile .open (input , "r:gz" ) as tar :
174177 for member in tqdm (tar .getmembers (), desc = "Extracting" ):
175178 tar .extract (member , path = output )
@@ -179,4 +182,4 @@ def untar_directory(input: Path, output: Path) -> None:
179182 if member .mode and not member .islnk () and not member .issym ():
180183 extracted_path .chmod (member .mode )
181184
182- print ("Done" )
185+ click . echo ("Done" )
0 commit comments