Skip to content

Commit 999d1aa

Browse files
docstrings: Fix parsing errors parsing the docstring
Signed-off-by: Bernhard Kaindl <[email protected]>
1 parent 125c4da commit 999d1aa

File tree

2 files changed

+50
-47
lines changed

2 files changed

+50
-47
lines changed

xcp/accessor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,15 @@ def createAccessor(baseAddress, *args):
440440
For all Accessors, the 1st arg after the address is type bool for ro (readonly flag)
441441
The DeviceAccessor accepts a 3rd argument: a List[] of filesystem names
442442
443-
Examples:
443+
Example usage::
444+
444445
accessor = createAccessor("http://example.com", True)
445446
accessor = createAccessor("dev://example.com", True, ['iso9660', 'ext3'])
446447
if not accessor:
447448
fatal()
448449
else:
449450
accessor.read()
451+
450452
"""
451453
url_parts = urllib.parse.urlsplit(baseAddress, allow_fragments=False)
452454

xcp/cpiofile.py

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -925,13 +925,13 @@ class CpioFile(six.Iterator):
925925

926926
def __init__(self, name=None, mode="r", fileobj=None):
927927
# 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.
935935
"""
936936
if len(mode) > 1 or mode not in "raw":
937937
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):
10031003
an appropriate CpioFile class.
10041004
10051005
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
10261027
"""
10271028

10281029
if not name and not fileobj:
@@ -1182,7 +1183,7 @@ def close(self):
11821183

11831184
def getmember(self, name):
11841185
# 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
11861187
found in the archive, KeyError is raised. If a member occurs more
11871188
than once in the archive, its last occurence is assumed to be the
11881189
most up-to-date version.
@@ -1210,10 +1211,10 @@ def getnames(self):
12101211
return [cpioinfo.name for cpioinfo in self.getmembers()]
12111212

12121213
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
12151216
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
12171218
file in the archive.
12181219
"""
12191220
self._check("aw")
@@ -1274,8 +1275,8 @@ def getcpioinfo(self, name=None, arcname=None, fileobj=None):
12741275
return cpioinfo
12751276

12761277
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
12791280
output is produced.
12801281
"""
12811282
self._check()
@@ -1300,11 +1301,11 @@ def list(self, verbose=True):
13001301
print()
13011302

13021303
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`
13051306
specifies an alternative name for the file in the archive.
13061307
Directories are added recursively by default. This can be avoided by
1307-
setting `recursive' to False.
1308+
setting `recursive` to False.
13081309
"""
13091310
self._check("aw")
13101311

@@ -1351,10 +1352,10 @@ def add(self, name, arcname=None, recursive=True):
13511352
self.addfile(cpioinfo)
13521353

13531354
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
13551356
given, cpioinfo.size bytes are read from it and added to the archive.
13561357
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
13581359
'rb' to avoid irritation about the file size.
13591360
"""
13601361
self._check("aw")
@@ -1389,8 +1390,8 @@ def addfile(self, cpioinfo, fileobj=None):
13891390
def extractall(self, path=".", members=None):
13901391
"""Extract all members from the archive to the current working
13911392
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
13941395
list returned by getmembers().
13951396
"""
13961397
directories = []
@@ -1430,8 +1431,8 @@ def extractall(self, path=".", members=None):
14301431
def extract(self, member, path=""):
14311432
"""Extract a member from the archive to the current working directory,
14321433
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`.
14351436
"""
14361437
self._check("r")
14371438

@@ -1462,10 +1463,10 @@ def extract(self, member, path=""):
14621463

14631464
def extractfile(self, member):
14641465
# 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
14691470
the above, None is returned.
14701471
The file-like object is read-only and provides the following
14711472
methods: read(), readline(), readlines(), seek() and tell()

0 commit comments

Comments
 (0)