File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 22
33import os
44import struct
5+ import sys
56import typing
67import zipfile
78
@@ -310,3 +311,21 @@ def validate_zipfile(zip_filepath: str) -> tuple[bool, str | None]:
310311 return False , "Trailing data"
311312
312313 return True , None
314+
315+
316+ def main (argv ) -> int : # pragma: no cover
317+ if len (argv ) != 1 :
318+ print ("Usage: python -m warehouse.utils.zipfiles <ZIP path>" )
319+ return 1
320+ zip_filepath = argv [0 ]
321+ zip_filename = os .path .basename (zip_filepath )
322+ ok , error = validate_zipfile (zip_filepath )
323+ if ok :
324+ print (f"{ zip_filename } : OK" )
325+ else :
326+ print (f"{ zip_filename } : { error } " )
327+ return 0 if ok else 1
328+
329+
330+ if __name__ == "__main__" : # pragma: no cover
331+ sys .exit (main (sys .argv [1 :]))
You can’t perform that action at this time.
0 commit comments