@@ -16,7 +16,7 @@ def file_hash(file):
1616 return h .hexdigest ()
1717
1818
19- def make_archive (file , directory ):
19+ def make_archive (file , directory , verbose = False ):
2020 archived_files = []
2121 for dirname , _ , files in os .walk (directory ):
2222 for filename in files :
@@ -34,6 +34,9 @@ def make_archive(file, directory):
3434 with open (path , "rb" ) as fp :
3535 zf .writestr (zip_info , fp .read (), compress_type = zipfile .ZIP_DEFLATED , compresslevel = 9 )
3636
37+ if verbose :
38+ print (f"Added to zip: { archive_path } " )
39+
3740
3841if __name__ == "__main__" :
3942 print (f"starting python standard lib archiving tool..." )
@@ -44,6 +47,7 @@ def make_archive(file, directory):
4447 parser .add_argument ("-M" , "--version-major" , type = int , help = "Major version number (integer)." )
4548 parser .add_argument ("-m" , "--version-minor" , type = int , help = "Minor version number (integer)." )
4649 parser .add_argument ("-x" , "--exclude-patterns" , type = str , default = None , help = "Excluded patterns (semicolon separated list)." )
50+ parser .add_argument ("-v" , "--verbose" , action = "store_true" , help = "Enable verbose output." )
4751
4852 args = parser .parse_args ()
4953
@@ -93,7 +97,7 @@ def make_archive(file, directory):
9397
9498 print (f"making archive { temp_archive } to { final_archive } ..." )
9599 if os .path .exists (final_archive ):
96- make_archive (temp_archive , final_location )
100+ make_archive (temp_archive , final_location , verbose = args . verbose )
97101 if file_hash (temp_archive ) != file_hash (final_archive ):
98102 shutil .copy (temp_archive , final_archive )
99103 else :
0 commit comments