Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #!/usr/bin/env python
  2. """Retrieve all of the metadata for the contents of an archive.
  3. """
  4. #end_pymotw_header
  5.  
  6. import datetime
  7. import zipfile
  8.  
  9. def print_info(archive_name):
  10. with zipfile.ZipFile(archive_name) as zf:
  11. for info in zf.infolist():
  12. print info.filename
  13. print '\tComment :', info.comment
  14. mod_date = datetime.datetime(*info.date_time)
  15. print '\tModified :', mod_date
  16. if info.create_system == 0:
  17. system = 'Windows'
  18. elif info.create_system == 3:
  19. system = 'Unix'
  20. else:
  21. system = 'UNKNOWN'
  22. print '\tSystem :', system
  23. print '\tZIP version :', info.create_version
  24. print '\tCompressed :', info.compress_size, 'bytes'
  25. print '\tUncompressed:', info.file_size, 'bytes'
  26. print
  27.  
  28. if __name__ == '__main__':
  29. print_info('example.zip')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement