-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathzipfile_infolist.py
31 lines (26 loc) · 956 Bytes
/
zipfile_infolist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
"""Retrieve all of the metadata for the contents of an archive.
"""
#end_pymotw_header
import datetime
import zipfile
def print_info(archive_name):
with zipfile.ZipFile(archive_name) as zf:
for info in zf.infolist():
print(info.filename)
print(' Comment :', info.comment)
mod_date = datetime.datetime(*info.date_time)
print(' Modified :', mod_date)
if info.create_system == 0:
system = 'Windows'
elif info.create_system == 3:
system = 'Unix'
else:
system = 'UNKNOWN'
print(' System :', system)
print(' ZIP version :', info.create_version)
print(' Compressed :', info.compress_size, 'bytes')
print(' Uncompressed:', info.file_size, 'bytes')
print()
if __name__ == '__main__':
print_info('example.zip')