Skip to content

Commit 285c929

Browse files
committed
Update descriptions
1 parent d9bbb36 commit 285c929

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ Usage
1111
Standard file usage:
1212
--------------------
1313

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+
1431
ar = arpy.Archive('file.ar'))
1532
ar.read_all_headers()
1633

arpy.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,21 @@
4242
ar.archived_files.keys()
4343
4444
Files themselves can be opened by getting the value of:
45-
f = ar.archived_files['filename']
45+
f = ar.archived_files[b'filename']
4646
4747
and read through:
4848
f.read([length])
4949
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.
5160
"""
5261

5362
import io

0 commit comments

Comments
 (0)