jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[IMPR] Remove private upload parameters

Site.upload() method has private upload parameters for upload recursion.
- remove these parameter from Page.upload() description
- remove them from UploadRobot.upload_file() method
- reorder Site.upload() parameters and description which is possible
because keyword arguments are required for all parameters except
filepage

Change-Id: I14cddb25f02c63eabcec7c4fe7f29fdbd5de3aef
---
M pywikibot/page/__init__.py
M pywikibot/site/_apisite.py
M pywikibot/specialbots/_upload.py
3 files changed, 17 insertions(+), 30 deletions(-)

diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index ee2a538..6a199aa 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -2380,20 +2380,6 @@
will only upload in chunks, if the chunk size is positive but lower
than the file size.
:type chunk_size: int
- :keyword _file_key: Reuses an already uploaded file using the filekey.
- If None (default) it will upload the file.
- :type _file_key: str or None
- :keyword _offset: When file_key is not None this can be an integer to
- continue a previously canceled chunked upload. If False it treats
- that as a finished upload. If True it requests the stash info from
- the server to determine the offset. By default starts at 0.
- :type _offset: int or bool
- :keyword _verify_stash: Requests the SHA1 and file size uploaded and
- compares it to the local file. Also verifies that _offset is
- matching the file size if the _offset is an int. If _offset is
- False if verifies that the file size match with the local file. If
- None it'll verifies the stash when a file key and offset is given.
- :type _verify_stash: bool or None
:keyword report_success: If the upload was successful it'll print a
success message and if ignore_warnings is set to False it'll
raise an UploadError if a warning occurred. If it's
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index f5607c9..dfe5434 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -2449,10 +2449,10 @@
ignore_warnings=False,
chunk_size: int = 0,
asynchronous: bool = False,
+ report_success: Optional[bool] = None,
_file_key: Optional[str] = None,
_offset: Union[bool, int] = 0,
- _verify_stash: Optional[bool] = None,
- report_success: Optional[bool] = None) -> bool:
+ _verify_stash: Optional[bool] = None) -> bool:
"""
Upload a file to the wiki.

@@ -2492,22 +2492,25 @@
but lower than the file size.
:param asynchronous: Make potentially large file operations
asynchronous on the server side when possible.
- :param _file_key: Reuses an already uploaded file using the filekey. If
- None (default) it will upload the file.
- :param _offset: When file_key is not None this can be an integer to
- continue a previously canceled chunked upload. If False it treats
- that as a finished upload. If True it requests the stash info from
- the server to determine the offset. By default starts at 0.
- :param _verify_stash: Requests the SHA1 and file size uploaded and
- compares it to the local file. Also verifies that _offset is
- matching the file size if the _offset is an int. If _offset is
- False if verifies that the file size match with the local file. If
- None it'll verifies the stash when a file key and offset is given.
:param report_success: If the upload was successful it'll print a
success message and if ignore_warnings is set to False it'll
raise an UploadError if a warning occurred. If it's None
(default) it'll be True if ignore_warnings is a bool and False
otherwise. If it's True or None ignore_warnings must be a bool.
+ :param _file_key: Private parameter for upload recurion. Reuses
+ an already uploaded file using the filekey. If None (default)
+ it will upload the file.
+ :param _offset: Private parameter for upload recurion. When
+ file_key is not None this can be an integer to continue a
+ previously canceled chunked upload. If False it treats that
+ as a finished upload. If True it requests the stash info from
+ the server to determine the offset. By default starts at 0.
+ :param _verify_stash: Private parameter for upload recurion.
+ Requests the SHA1 and file size uploaded and compares it to
+ the local file. Also verifies that _offset is matching the
+ file size if the _offset is an int. If _offset is False if
+ verifies that the file size match with the local file. If
+ None it'll verifies the stash when a file key and offset is given.
:return: It returns True if the upload was successful and False
otherwise.
"""
diff --git a/pywikibot/specialbots/_upload.py b/pywikibot/specialbots/_upload.py
index 1aff167..5c08530 100644
--- a/pywikibot/specialbots/_upload.py
+++ b/pywikibot/specialbots/_upload.py
@@ -374,7 +374,7 @@
"""
return self.ignore_warning is True or warn_code in self.ignore_warning

- def upload_file(self, file_url, _file_key=None, _offset=0):
+ def upload_file(self, file_url):
"""
Upload the image at file_url to the target wiki.

@@ -414,8 +414,6 @@
success = imagepage.upload(file_url,
ignore_warnings=ignore_warnings,
chunk_size=self.chunk_size,
- _file_key=_file_key,
- _offset=_offset,
asynchronous=self.asynchronous,
comment=self.summary)
except APIError as error:

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I14cddb25f02c63eabcec7c4fe7f29fdbd5de3aef
Gerrit-Change-Number: 736272
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged