File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 11
11
Standard file usage:
12
12
--------------------
13
13
14
+ With context managers:
15
+
16
+ with arpy.Archive('file.ar') as ar:
17
+ print("files: %s" % ar.namelist())
18
+ with ar.open('content.txt') as f:
19
+ print(f.read())
20
+
21
+ Via headers for duplicate names:
22
+
23
+ with arpy.Archive('file.ar') as ar:
24
+ for header in ar.infolist():
25
+ print("file: %s" % header.name)
26
+ with ar.open(header) as f:
27
+ print(f.read())
28
+
29
+ Or directly:
30
+
14
31
ar = arpy.Archive('file.ar'))
15
32
ar.read_all_headers()
16
33
Original file line number Diff line number Diff line change 42
42
ar.archived_files.keys()
43
43
44
44
Files themselves can be opened by getting the value of:
45
- f = ar.archived_files['filename']
45
+ f = ar.archived_files[b 'filename']
46
46
47
47
and read through:
48
48
f.read([length])
49
49
50
- random access through seek and tell functions is supported on the archived files
50
+ random access through seek and tell functions is supported on the archived files.
51
+
52
+ zipfile-like interface is also available:
53
+
54
+ ar.namelist() will return a list of names (with possible duplicates)
55
+ ar.infolist() will return a list of headers
56
+
57
+ Use ar.open(name / header) to get the specific file.
58
+
59
+ You can also use context manager syntax with either the ar file or its contents.
51
60
"""
52
61
53
62
import io
You can’t perform that action at this time.
0 commit comments