File tree Expand file tree Collapse file tree 3 files changed +172
-1
lines changed Expand file tree Collapse file tree 3 files changed +172
-1
lines changed Original file line number Diff line number Diff line change 11import ziplinter
22
33def main ():
4- print ("{}" , ziplinter .parse_file ("../testdata/unix.zip" ))
4+ info = ziplinter .parse_file ("../testdata/unix.zip" )
5+ assert info ["comment" ] == ""
6+
7+ # created using `cat utf8-infozip.zip time-infozip.zip >> concatenated.zip`
8+ with open ("../testdata/concatenated.zip" , "rb" ) as f :
9+ data = f .read ()
10+
11+ info1 = ziplinter .parse_bytes (data )
12+
13+ start = 0
14+ for r in info1 ["parsed_ranges" ]:
15+ if r ["contains" ] == "local file header" :
16+ start = int (r ["start" ])
17+ break
18+
19+ assert start == 162
20+
21+ info2 = ziplinter .parse_bytes (data [:start ])
22+
23+ assert info1 != info2
524
625if __name__ == '__main__' :
726 main ()
Original file line number Diff line number Diff line change 1+ -- -
2+ source : ziplinter / src / lib .rs
3+ expression : result
4+ -- -
5+ {
6+ " comment" : " " ,
7+ " contents" : [
8+ {
9+ " central" : {
10+ " comment" : " " ,
11+ " compressed_size" : 0 ,
12+ " crc32" : 0 ,
13+ " creator_version" : {
14+ " host_system" : " Unix" ,
15+ " version" : 30
16+ },
17+ " disk_nbr_start" : 0 ,
18+ " external_attrs" : 2175008768 ,
19+ " extra" : [
20+ 85 ,
21+ 84 ,
22+ 5 ,
23+ 0 ,
24+ 3 ,
25+ 141 ,
26+ 73 ,
27+ 249 ,
28+ 89 ,
29+ 117 ,
30+ 120 ,
31+ 11 ,
32+ 0 ,
33+ 1 ,
34+ 4 ,
35+ 232 ,
36+ 3 ,
37+ 0 ,
38+ 0 ,
39+ 4 ,
40+ 232 ,
41+ 3 ,
42+ 0 ,
43+ 0
44+ ],
45+ " flags" : 0 ,
46+ " header_offset" : 0 ,
47+ " internal_attrs" : 0 ,
48+ " method" : " Store" ,
49+ " mode" : 420 ,
50+ " modified" : " 2017-11-01T04:11:57Z" ,
51+ " name" : " test.txt" ,
52+ " reader_version" : {
53+ " host_system" : " MsDos" ,
54+ " version" : 10
55+ },
56+ " uncompressed_size" : 0
57+ },
58+ " local" : {
59+ " accessed" : null ,
60+ " compressed_size" : 0 ,
61+ " crc32" : 0 ,
62+ " created" : null ,
63+ " extra" : [
64+ 85 ,
65+ 84 ,
66+ 9 ,
67+ 0 ,
68+ 3 ,
69+ 141 ,
70+ 73 ,
71+ 249 ,
72+ 89 ,
73+ 141 ,
74+ 73 ,
75+ 249 ,
76+ 89 ,
77+ 117 ,
78+ 120 ,
79+ 11 ,
80+ 0 ,
81+ 1 ,
82+ 4 ,
83+ 232 ,
84+ 3 ,
85+ 0 ,
86+ 0 ,
87+ 4 ,
88+ 232 ,
89+ 3 ,
90+ 0 ,
91+ 0
92+ ],
93+ " flags" : 0 ,
94+ " gid" : 1000 ,
95+ " header_offset" : 0 ,
96+ " method" : " Store" ,
97+ " method_specific" : " None" ,
98+ " mode" : 0 ,
99+ " modified" : " 2017-11-01T04:11:57Z" ,
100+ " name" : " test.txt" ,
101+ " reader_version" : {
102+ " host_system" : " MsDos" ,
103+ " version" : 10
104+ },
105+ " uid" : 1000 ,
106+ " uncompressed_size" : 0
107+ }
108+ }
109+ ],
110+ " encoding" : " Utf8" ,
111+ " eocd" : {
112+ " dir" : {
113+ " inner" : {
114+ " dir_disk_nbr" : 0 ,
115+ " dir_records_this_disk" : 1 ,
116+ " directory_offset" : 228 ,
117+ " directory_records" : 1 ,
118+ " directory_size" : 78 ,
119+ " disk_nbr" : 0
120+ },
121+ " offset" : 306
122+ },
123+ " dir64" : null ,
124+ " global_offset" : 162
125+ },
126+ " parsed_ranges" : [
127+ {
128+ " contains" : " end of central directory record" ,
129+ " end" : 328 ,
130+ " start" : 306
131+ },
132+ {
133+ " contains" : " central directory header" ,
134+ " end" : 306 ,
135+ " filename" : " test.txt" ,
136+ " start" : 228
137+ },
138+ {
139+ " contains" : " local file header" ,
140+ " end" : 228 ,
141+ " filename" : " test.txt" ,
142+ " start" : 162
143+ },
144+ {
145+ " contains" : " file data" ,
146+ " end" : 228 ,
147+ " filename" : " test.txt" ,
148+ " start" : 228
149+ }
150+ ],
151+ " size" : 328
152+ }
You can’t perform that action at this time.
0 commit comments