You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

canon-zip 550B

12345678910111213141516171819202122
  1. #!/usr/bin/python
  2. from zipfile import ZipFile
  3. import sys
  4. """Canonicalize a zip/jar file. Sets all the filestamps to a specific date.
  5. canon-zip YYYY-MM-DD INPUT OUTPUT
  6. """
  7. (year, month, day) = sys.argv[1].split('-')
  8. year = int(year)
  9. month = int(month)
  10. day = int(day)
  11. with ZipFile(sys.argv[3], 'w') as outzip:
  12. with ZipFile(sys.argv[2], 'r') as inzip:
  13. for info in inzip.infolist():
  14. info.date_time = (year, month, day, 0, 0, 0)
  15. content = inzip.read(info.filename)
  16. outzip.writestr(info, content)