Xqt submitted this change.

View Change


Approvals: Xqt: Verified; Looks good to me, approved
[doc] Adjust documentation length

Change-Id: Ia0e9c33c943f3e96849d2168ea2193ef7fe17b5a
---
M pywikibot/tools/__init__.py
M tests/tools_tests.py
2 files changed, 61 insertions(+), 47 deletions(-)

diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index a2a7802..1661611 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -164,8 +164,8 @@

"""A decorator/context manager that temporarily suppresses warnings.

- Those suppressed warnings that do not match the parameters will be raised
- shown upon exit.
+ Those suppressed warnings that do not match the parameters will be
+ raised shown upon exit.

.. versionadded:: 3.0
"""
@@ -181,13 +181,14 @@
The parameter semantics are similar to those of
`warnings.filterwarnings`.

- :param message: A string containing a regular expression that the start
- of the warning message must match. (case-insensitive)
- :param category: A class (a subclass of Warning) of which the warning
- category must be a subclass in order to match.
+ :param message: A string containing a regular expression that
+ the start of the warning message must match.
+ (case-insensitive)
+ :param category: A class (a subclass of Warning) of which the
+ warning category must be a subclass in order to match.
:type category: type
- :param filename: A string containing a regular expression that the
- start of the path to the warning module must match.
+ :param filename: A string containing a regular expression that
+ the start of the path to the warning module must match.
(case-sensitive)
"""
self.message_match = re.compile(message, re.I).match
@@ -424,16 +425,16 @@
"""
Version object to allow comparing 'wmf' versions with normal ones.

- The version mainly consist of digits separated by periods. After that is a
- suffix which may only be 'wmf<number>', 'alpha', 'beta<number>' or
- '-rc.<number>' (the - and . are optional). They are considered from old to
- new in that order with a version number without suffix is considered the
- newest. This secondary difference is stored in an internal _dev_version
- attribute.
+ The version mainly consist of digits separated by periods. After
+ that is a suffix which may only be 'wmf<number>', 'alpha',
+ 'beta<number>' or '-rc.<number>' (the - and . are optional). They
+ are considered from old to new in that order with a version number
+ without suffix is considered the newest. This secondary difference
+ is stored in an internal _dev_version attribute.

- Two versions are equal if their normal version and dev version are equal. A
- version is greater if the normal version or dev version is greater. For
- example::
+ Two versions are equal if their normal version and dev version are
+ equal. A version is greater if the normal version or dev version is
+ greater. For example::

1.34 < 1.34.1 < 1.35wmf1 < 1.35alpha < 1.35beta1 < 1.35beta2
< 1.35-rc-1 < 1.35-rc.2 < 1.35
@@ -533,8 +534,8 @@
"""
Return self when called.

- When '_own_desc' is defined it'll also issue a deprecation warning using
- issue_deprecation_warning('Calling ' + _own_desc, 'it directly').
+ When '_own_desc' is defined it'll also issue a deprecation warning
+ using issue_deprecation_warning('Calling ' + _own_desc, 'it directly').

.. versionadded:: 3.0
.. deprecated:: 6.2
@@ -570,33 +571,37 @@
"""
Open a file and uncompress it if needed.

- This function supports bzip2, gzip, 7zip, lzma, and xz as compression
- containers. It uses the packages available in the standard library for
- bzip2, gzip, lzma, and xz so they are always available. 7zip is only
- available when a 7za program is available and only supports reading
- from it.
+ This function supports bzip2, gzip, 7zip, lzma, and xz as
+ compression containers. It uses the packages available in the
+ standard library for bzip2, gzip, lzma, and xz so they are always
+ available. 7zip is only available when a 7za program is available
+ and only supports reading from it.

- The compression is either selected via the magic number or file ending.
+ The compression is either selected via the magic number or file
+ ending.

.. versionadded:: 3.0

:param filename: The filename.
- :param use_extension: Use the file extension instead of the magic number
- to determine the type of compression (default True). Must be True when
- writing or appending.
- :param mode: The mode in which the file should be opened. It may either be
- 'r', 'rb', 'a', 'ab', 'w' or 'wb'. All modes open the file in binary
- mode. It defaults to 'rb'.
+ :param use_extension: Use the file extension instead of the magic
+ number to determine the type of compression (default True). Must
+ be True when writing or appending.
+ :param mode: The mode in which the file should be opened. It may
+ either be 'r', 'rb', 'a', 'ab', 'w' or 'wb'. All modes open the
+ file in binary mode. It defaults to 'rb'.
:raises ValueError: When 7za is not available or the opening mode is
unknown or it tries to write a 7z archive.
- :raises FileNotFoundError: When the filename doesn't exist and it tries
- to read from it or it tries to determine the compression algorithm.
- :raises OSError: When it's not a 7z archive but the file extension is 7z.
- It is also raised by bz2 when its content is invalid. gzip does not
- immediately raise that error but only on reading it.
+ :raises FileNotFoundError: When the filename doesn't exist and it
+ tries to read from it or it tries to determine the compression
+ algorithm.
+ :raises OSError: When it's not a 7z archive but the file extension
+ is 7z. It is also raised by bz2 when its content is invalid.
+ gzip does not immediately raise that error but only on reading
+ it.
:raises lzma.LZMAError: When error occurs during compression or
decompression or when initializing the state with lzma or xz.
- :return: A file-like object returning the uncompressed data in binary mode.
+ :return: A file-like object returning the uncompressed data in
+ binary mode.
:rtype: file-like object
"""
# extension_map maps magic_number to extension.
@@ -671,8 +676,9 @@
"""
Return a merged dict and make sure that the original dicts keys are unique.

- The positional arguments are the dictionaries to be merged. It is also
- possible to define an additional dict using the keyword arguments.
+ The positional arguments are the dictionaries to be merged. It is
+ also possible to define an additional dict using the keyword
+ arguments.

.. versionadded:: 3.0
"""
diff --git a/tests/tools_tests.py b/tests/tools_tests.py
index 15471ac..8da9e24 100755
--- a/tests/tools_tests.py
+++ b/tests/tools_tests.py
@@ -37,13 +37,12 @@

class OpenArchiveTestCase(TestCase):

- """
- Unit test class for tools.
+ """Unit test class for tools.

- The tests for open_archive requires that article-pyrus.xml* contain all
- the same content after extraction. The content itself is not important.
- The file article-pyrus.xml_invalid.7z is not a valid 7z file and
- open_archive will fail extracting it using 7za.
+ The tests for open_archive requires that article-pyrus.xml* contain
+ all the same content after extraction. The content itself is not
+ important. The file article-pyrus.xml_invalid.7z is not a valid 7z
+ file and open_archive will fail extracting it using 7za.
"""

net = False
@@ -610,8 +609,8 @@

r"""Test calculator of sha of a file.

- There are two possible hash values for each test. The second one is for
- files with Windows line endings (\r\n).
+ There are two possible hash values for each test. The second one is
+ for files with Windows line endings (\r\n).
"""

net = False

To view, visit change 944929. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ia0e9c33c943f3e96849d2168ea2193ef7fe17b5a
Gerrit-Change-Number: 944929
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-MessageType: merged