@@ -925,13 +925,13 @@ class CpioFile(six.Iterator):
925
925
926
926
def __init__ (self , name = None , mode = "r" , fileobj = None ):
927
927
# type:(str | None, str, Optional[IO[bytes] | GzipFile | _Stream]) -> None
928
- """Open an (uncompressed) cpio archive `name'. `mode' is either 'r' to
929
- read from an existing archive, 'a' to append data to an existing
930
- file or 'w' to create a new file overwriting an existing one. `mode'
931
- defaults to 'r' .
932
- If `fileobj' is given, it is used for reading or writing data. If it
933
- can be determined, `mode' is overridden by `fileobj's mode.
934
- `fileobj' is not closed, when CpioFile is closed.
928
+ """Open an (uncompressed) cpio archive `name'. `mode` is either `r` to
929
+ read from an existing archive, `a` to append data to an existing
930
+ file or `w` to create a new file overwriting an existing one. `mode`
931
+ defaults to `r` .
932
+ If `fileobj` is given, it is used for reading or writing data. If it
933
+ can be determined, `mode` is overridden by `fileobj` 's mode.
934
+ `fileobj` is not closed, when CpioFile is closed.
935
935
"""
936
936
if len (mode ) > 1 or mode not in "raw" :
937
937
raise ValueError ("mode must be 'r', 'a' or 'w'" )
@@ -1003,26 +1003,27 @@ def open(cls, name=None, mode="r", fileobj=None, bufsize=20*512):
1003
1003
an appropriate CpioFile class.
1004
1004
1005
1005
mode:
1006
- 'r' or 'r:*' open for reading with transparent compression
1007
- 'r:' open for reading exclusively uncompressed
1008
- 'r:gz' open for reading with gzip compression
1009
- 'r:bz2' open for reading with bzip2 compression
1010
- 'r:xz' open for reading with xz compression
1011
- 'a' or 'a:' open for appending
1012
- 'w' or 'w:' open for writing without compression
1013
- 'w:gz' open for writing with gzip compression
1014
- 'w:bz2' open for writing with bzip2 compression
1015
- 'w:xz' open for writing with xz compression
1016
-
1017
- 'r|*' open a stream of cpio blocks with transparent compression
1018
- 'r|' open an uncompressed stream of cpio blocks for reading
1019
- 'r|gz' open a gzip compressed stream of cpio blocks
1020
- 'r|bz2' open a bzip2 compressed stream of cpio blocks
1021
- 'r|xz' open a xz compressed stream of cpio blocks
1022
- 'w|' open an uncompressed stream for writing
1023
- 'w|gz' open a gzip compressed stream for writing
1024
- 'w|bz2' open a bzip2 compressed stream for writing
1025
- 'w|xz' open a xz compressed stream for writing
1006
+
1007
+ - ``r`` or ``r:*`` open for reading with transparent compression
1008
+ - ``r:`` open for reading exclusively uncompressed
1009
+ - ``r:gz`` open for reading with gzip compression
1010
+ - ``r:bz2`` open for reading with bzip2 compression
1011
+ - ``r:xz`` open for reading with xz compression
1012
+ - ``a`` or ``a:`` open for appending
1013
+ - ``w`` or ``w:`` open for writing without compression
1014
+ - ``w:gz`` open for writing with gzip compression
1015
+ - ``w:bz2`` open for writing with bzip2 compression
1016
+ - ``w:xz`` open for writing with xz compression
1017
+
1018
+ - ``r|*`` open a stream of cpio blocks with transparent compression
1019
+ - ``r|`` open an uncompressed stream of cpio blocks for reading
1020
+ - ``r|gz`` open a gzip compressed stream of cpio blocks
1021
+ - ``r|bz2`` open a bzip2 compressed stream of cpio blocks
1022
+ - ``r|xz`` open a xz compressed stream of cpio blocks
1023
+ - ``w|`` open an uncompressed stream for writing
1024
+ - ``w|gz`` open a gzip compressed stream for writing
1025
+ - ``w|bz2`` open a bzip2 compressed stream for writing
1026
+ - ``w|xz`` open a xz compressed stream for writing
1026
1027
"""
1027
1028
1028
1029
if not name and not fileobj :
@@ -1182,7 +1183,7 @@ def close(self):
1182
1183
1183
1184
def getmember (self , name ):
1184
1185
# type:(str | bytes) -> CpioInfo
1185
- """Return a CpioInfo object for member `name' . If `name' can not be
1186
+ """Return a CpioInfo object for member `name` . If `name` can not be
1186
1187
found in the archive, KeyError is raised. If a member occurs more
1187
1188
than once in the archive, its last occurence is assumed to be the
1188
1189
most up-to-date version.
@@ -1210,10 +1211,10 @@ def getnames(self):
1210
1211
return [cpioinfo .name for cpioinfo in self .getmembers ()]
1211
1212
1212
1213
def getcpioinfo (self , name = None , arcname = None , fileobj = None ):
1213
- """Create a CpioInfo object for either the file `name' or the file
1214
- object `fileobj' (using os.fstat on its file descriptor). You can
1214
+ """Create a CpioInfo object for either the file `name` or the file
1215
+ object `fileobj` (using os.fstat on its file descriptor). You can
1215
1216
modify some of the CpioInfo's attributes before you add it using
1216
- addfile(). If given, `arcname' specifies an alternative name for the
1217
+ addfile(). If given, `arcname` specifies an alternative name for the
1217
1218
file in the archive.
1218
1219
"""
1219
1220
self ._check ("aw" )
@@ -1274,8 +1275,8 @@ def getcpioinfo(self, name=None, arcname=None, fileobj=None):
1274
1275
return cpioinfo
1275
1276
1276
1277
def list (self , verbose = True ):
1277
- """Print a table of contents to sys.stdout. If `verbose' is False, only
1278
- the names of the members are printed. If it is True, an `ls -l' -like
1278
+ """Print a table of contents to sys.stdout. If `verbose` is False, only
1279
+ the names of the members are printed. If it is True, an `ls -l` -like
1279
1280
output is produced.
1280
1281
"""
1281
1282
self ._check ()
@@ -1300,11 +1301,11 @@ def list(self, verbose=True):
1300
1301
print ()
1301
1302
1302
1303
def add (self , name , arcname = None , recursive = True ):
1303
- """Add the file `name' to the archive. `name' may be any type of file
1304
- (directory, fifo, symbolic link, etc.). If given, `arcname'
1304
+ """Add the file `name` to the archive. `name` may be any type of file
1305
+ (directory, fifo, symbolic link, etc.). If given, `arcname`
1305
1306
specifies an alternative name for the file in the archive.
1306
1307
Directories are added recursively by default. This can be avoided by
1307
- setting `recursive' to False.
1308
+ setting `recursive` to False.
1308
1309
"""
1309
1310
self ._check ("aw" )
1310
1311
@@ -1351,10 +1352,10 @@ def add(self, name, arcname=None, recursive=True):
1351
1352
self .addfile (cpioinfo )
1352
1353
1353
1354
def addfile (self , cpioinfo , fileobj = None ):
1354
- """Add the CpioInfo object `cpioinfo' to the archive. If `fileobj' is
1355
+ """Add the CpioInfo object `cpioinfo` to the archive. If `fileobj` is
1355
1356
given, cpioinfo.size bytes are read from it and added to the archive.
1356
1357
You can create CpioInfo objects using getcpioinfo().
1357
- On Windows platforms, `fileobj' should always be opened with mode
1358
+ On Windows platforms, `fileobj` should always be opened with mode
1358
1359
'rb' to avoid irritation about the file size.
1359
1360
"""
1360
1361
self ._check ("aw" )
@@ -1389,8 +1390,8 @@ def addfile(self, cpioinfo, fileobj=None):
1389
1390
def extractall (self , path = "." , members = None ):
1390
1391
"""Extract all members from the archive to the current working
1391
1392
directory and set owner, modification time and permissions on
1392
- directories afterwards. `path' specifies a different directory
1393
- to extract to. `members' is optional and must be a subset of the
1393
+ directories afterwards. `path` specifies a different directory
1394
+ to extract to. `members` is optional and must be a subset of the
1394
1395
list returned by getmembers().
1395
1396
"""
1396
1397
directories = []
@@ -1430,8 +1431,8 @@ def extractall(self, path=".", members=None):
1430
1431
def extract (self , member , path = "" ):
1431
1432
"""Extract a member from the archive to the current working directory,
1432
1433
using its full name. Its file information is extracted as accurately
1433
- as possible. `member' may be a filename or a CpioInfo object. You can
1434
- specify a different directory using `path' .
1434
+ as possible. `member` may be a filename or a CpioInfo object. You can
1435
+ specify a different directory using `path` .
1435
1436
"""
1436
1437
self ._check ("r" )
1437
1438
@@ -1462,10 +1463,10 @@ def extract(self, member, path=""):
1462
1463
1463
1464
def extractfile (self , member ):
1464
1465
# type:(CpioInfo | str | bytes) -> ExFileObject | None
1465
- """Extract a member from the archive as a file object. `member' may be
1466
- a filename or a CpioInfo object. If `member' is a regular file, a
1467
- file-like object is returned. If `member' is a link, a file-like
1468
- object is constructed from the link's target. If `member' is none of
1466
+ """Extract a member from the archive as a file object. `member` may be
1467
+ a filename or a CpioInfo object. If `member` is a regular file, a
1468
+ file-like object is returned. If `member` is a link, a file-like
1469
+ object is constructed from the link's target. If `member` is none of
1469
1470
the above, None is returned.
1470
1471
The file-like object is read-only and provides the following
1471
1472
methods: read(), readline(), readlines(), seek() and tell()
0 commit comments