jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/459270 )
Change subject: Fix type hints for *args and **kwargs
......................................................................
Fix type hints for *args and **kwargs
First of all, *args is not a list, it's a tuple. In addition to that,
and according to PEP 484[1], the type hint for *args should be the type
of its elements, otherwise it's obvious that the type of *args is
a tuple. Similarly, for **kwargs the type hint should mention the
dict's value types.
Use `typing.Sequence[T]` or `typing.Iterable[T]` for args (without *).
[1]:
https://www.python.org/dev/peps/pep-0484/#arbitrary-argument-lists-and-defa…
Change-Id: I7f0db256b52714c5e46db0a9f609831bee74ac53
---
M generate_user_files.py
M pywikibot/bot.py
M pywikibot/comms/eventstreams.py
M pywikibot/site.py
M pywikibot/tools/__init__.py
M pywikibot/tools/djvu.py
M pywikibot/tools/formatter.py
M scripts/add_text.py
M scripts/archive/featured.py
M scripts/archivebot.py
M scripts/basic.py
M scripts/blockpageschecker.py
M scripts/capitalize_redirects.py
M scripts/catall.py
M scripts/category.py
M scripts/category_redirect.py
M scripts/cfd.py
M scripts/checkimages.py
M scripts/claimit.py
M scripts/clean_sandbox.py
M scripts/commons_link.py
M scripts/commonscat.py
M scripts/coordinate_import.py
M scripts/cosmetic_changes.py
M scripts/create_categories.py
M scripts/data_ingestion.py
M scripts/delete.py
M scripts/disambredir.py
M scripts/djvutext.py
M scripts/editarticle.py
M scripts/fixing_redirects.py
M scripts/flickrripper.py
M scripts/followlive.py
M scripts/freebasemappingupload.py
M scripts/harvest_template.py
M scripts/illustrate_wikidata.py
M scripts/image.py
M scripts/imagerecat.py
M scripts/imagetransfer.py
M scripts/imageuncat.py
M scripts/interwiki.py
M scripts/interwikidata.py
M scripts/isbn.py
M scripts/listpages.py
M scripts/login.py
M scripts/lonelypages.py
M scripts/maintenance/download_dump.py
M scripts/makecat.py
M scripts/misspelling.py
M scripts/movepages.py
M scripts/ndashredir.py
M scripts/newitem.py
M scripts/noreferences.py
M scripts/nowcommons.py
M scripts/pagefromfile.py
M scripts/protect.py
M scripts/redirect.py
M scripts/reflinks.py
M scripts/replace.py
M scripts/replicate_wiki.py
M scripts/revertbot.py
M scripts/script_wui.py
M scripts/selflink.py
M scripts/solve_disambiguation.py
M scripts/spamremove.py
M scripts/states_redirect.py
M scripts/surnames_redirects.py
M scripts/table2wiki.py
M scripts/template.py
M scripts/templatecount.py
M scripts/touch.py
M scripts/transferbot.py
M scripts/unlink.py
M scripts/unusedfiles.py
M scripts/upload.py
M scripts/watchlist.py
M scripts/weblinkchecker.py
M scripts/welcome.py
M scripts/wikisourcetext.py
M tests/utils.py
80 files changed, 80 insertions(+), 93 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/generate_user_files.py b/generate_user_files.py
index 3033a18..aa502b7 100755
--- a/generate_user_files.py
+++ b/generate_user_files.py
@@ -427,7 +427,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
# set the config family and mylang values to an invalid state so that
# the script can detect that the command line arguments -family & -lang
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index e6fc79c..faaad1c 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -899,7 +899,7 @@
args may be passed as an argument, thereby overriding sys.argv
@param args: Command line arguments
- @type args: list of unicode
+ @type args: typing.Iterable
@param do_help: Handle parameter '-help' to show help and invoke sys.exit
@type do_help: bool
@return: list of arguments not recognised globally
@@ -1136,7 +1136,6 @@
Only accept options defined in availableOptions.
@param kwargs: bot options
- @type kwargs: dict
"""
self.setOptions(**kwargs)
@@ -1145,7 +1144,6 @@
Set the instance options.
@param kwargs: options
- @type kwargs: dict
"""
valid_options = set(self.availableOptions)
received_options = set(kwargs)
@@ -1203,7 +1201,6 @@
Only accept options defined in availableOptions.
@param kwargs: bot options
- @type kwargs: dict
"""
if 'generator' in kwargs:
self.generator = kwargs.pop('generator')
@@ -1760,7 +1757,6 @@
print a message. If None uses this instances default.
@type ignore_server_errors: bool or None
@param kwargs: Additional parameters directly given to L{Bot.userPut}.
- @type kwargs: dict
@return: whether the page was saved successfully
@rtype: bool
"""
diff --git a/pywikibot/comms/eventstreams.py b/pywikibot/comms/eventstreams.py
index 7731d5b..a4695b3 100644
--- a/pywikibot/comms/eventstreams.py
+++ b/pywikibot/comms/eventstreams.py
@@ -89,7 +89,6 @@
default url using _site.family settings and streamtype
@type url: str
@param kwargs: keyword arguments passed to SSEClient and requests lib
- @type kwargs: dict
@raises ImportError: sseclient is not installed
"""
if isinstance(EventSource, Exception):
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 6d7ef3e..8a15511 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -2470,7 +2470,7 @@
joined using MediaWiki message 'comma-separator'.
@param args: text to be expanded
- @type args: iterable of unicode
+ @type args: typing.Iterable[unicode]
@rtype: unicode
"""
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 05017ae..9d24df3 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -1493,9 +1493,7 @@
if the decorated decorator was called without arguments.
@param outer_args: args
- @type outer_args: list
@param outer_kwargs: kwargs
- @type outer_kwargs: dict
"""
def inner_wrapper(*args, **kwargs):
"""Replacement function.
@@ -1611,9 +1609,7 @@
"""Replacement function.
@param args: args passed to the decorated function.
- @type args: list
@param kwargs: kwargs passed to the decorated function.
- @type kwargs: dict
@return: the value returned by the decorated function
@rtype: any
"""
@@ -1705,9 +1701,7 @@
"""Replacement function.
@param __args: args passed to the decorated function
- @type __args: list
- @param __kwargs: kwargs passed to the decorated function
- @type __kwargs: dict
+ @param __kw: kwargs passed to the decorated function
@return: the value returned by the decorated function
@rtype: any
"""
@@ -1798,9 +1792,7 @@
"""Replacement function.
@param __args: args passed to the decorated function
- @type __args: list
- @param __kwargs: kwargs passed to the decorated function
- @type __kwargs: dict
+ @param __kw: kwargs passed to the decorated function
@return: the value returned by the decorated function
@rtype: any
"""
diff --git a/pywikibot/tools/djvu.py b/pywikibot/tools/djvu.py
index fe9ba04..a33659d 100644
--- a/pywikibot/tools/djvu.py
+++ b/pywikibot/tools/djvu.py
@@ -27,7 +27,7 @@
Tiny wrapper around subprocess.Popen().
@param args: same as Popen()
- @type args: sequence or string
+ @type args: typing.Sequence[string]
@param library: library to be logged in logging messages
@type library: string
diff --git a/pywikibot/tools/formatter.py b/pywikibot/tools/formatter.py
index 918bb89..ebeacf9 100644
--- a/pywikibot/tools/formatter.py
+++ b/pywikibot/tools/formatter.py
@@ -144,7 +144,7 @@
@param format_string: The format template string
@type format_string: unicode
@param args: The positional field values
- @type args: sequence
+ @type args: typing.Sequence
@param kwargs: The named field values
@type kwargs: dict
@return: The formatted string
diff --git a/scripts/add_text.py b/scripts/add_text.py
index 044a361..8c220c1 100755
--- a/scripts/add_text.py
+++ b/scripts/add_text.py
@@ -241,7 +241,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
# If none, the var is setted only for check purpose.
summary = None
diff --git a/scripts/archive/featured.py b/scripts/archive/featured.py
index c5a9d71..9fe974f 100755
--- a/scripts/archive/featured.py
+++ b/scripts/archive/featured.py
@@ -615,7 +615,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
local_args = pywikibot.handle_args(args)
diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index 8839a79..188db6d 100755
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -720,7 +720,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
filename = None
pagename = None
diff --git a/scripts/basic.py b/scripts/basic.py
index 1ef778a..bc9b550 100755
--- a/scripts/basic.py
+++ b/scripts/basic.py
@@ -158,7 +158,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
# Process global arguments to determine desired site
diff --git a/scripts/blockpageschecker.py b/scripts/blockpageschecker.py
index bf22e22..085e487 100755
--- a/scripts/blockpageschecker.py
+++ b/scripts/blockpageschecker.py
@@ -222,7 +222,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
# Loading the comments
global categoryToCheck, project_inserted
diff --git a/scripts/capitalize_redirects.py b/scripts/capitalize_redirects.py
index dcc8442..063b8ab 100755
--- a/scripts/capitalize_redirects.py
+++ b/scripts/capitalize_redirects.py
@@ -93,7 +93,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
diff --git a/scripts/catall.py b/scripts/catall.py
index 3a934ce..1e6ad4f 100755
--- a/scripts/catall.py
+++ b/scripts/catall.py
@@ -88,7 +88,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
docorrections = True
start = 'A'
diff --git a/scripts/category.py b/scripts/category.py
index 7d82892..757348d 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -1325,7 +1325,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
from_given = False
to_given = False
diff --git a/scripts/category_redirect.py b/scripts/category_redirect.py
index dcc706f..1850d05 100755
--- a/scripts/category_redirect.py
+++ b/scripts/category_redirect.py
@@ -504,7 +504,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
for arg in pywikibot.handle_args(args):
diff --git a/scripts/cfd.py b/scripts/cfd.py
index f19a279..4d15c8a 100755
--- a/scripts/cfd.py
+++ b/scripts/cfd.py
@@ -75,7 +75,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
cfd_page = DEFAULT_CFD_PAGE
local_args = pywikibot.handle_args(args)
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index ccb3010..7d6ae91 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -1570,7 +1570,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
# Command line configurable parameters
repeat = True # Restart after having check all the images?
diff --git a/scripts/claimit.py b/scripts/claimit.py
index 3c523f8..c134ff4 100755
--- a/scripts/claimit.py
+++ b/scripts/claimit.py
@@ -106,7 +106,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
@rtype: bool
"""
exists_arg = ''
diff --git a/scripts/clean_sandbox.py b/scripts/clean_sandbox.py
index b946d74..8e11b95 100755
--- a/scripts/clean_sandbox.py
+++ b/scripts/clean_sandbox.py
@@ -246,7 +246,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
opts = {}
local_args = pywikibot.handle_args(args)
diff --git a/scripts/commons_link.py b/scripts/commons_link.py
index 0cfd3fd..c5525e3 100755
--- a/scripts/commons_link.py
+++ b/scripts/commons_link.py
@@ -123,7 +123,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
diff --git a/scripts/commonscat.py b/scripts/commonscat.py
index f17b345..9ec63d4 100755
--- a/scripts/commonscat.py
+++ b/scripts/commonscat.py
@@ -512,7 +512,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
checkcurrent = False
diff --git a/scripts/coordinate_import.py b/scripts/coordinate_import.py
index fce00a5..e8c4f4c 100755
--- a/scripts/coordinate_import.py
+++ b/scripts/coordinate_import.py
@@ -117,7 +117,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
# Process global args and prepare generator args parser
local_args = pywikibot.handle_args(args)
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index 8f53756..0c62f19 100644
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -84,7 +84,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
diff --git a/scripts/create_categories.py b/scripts/create_categories.py
index 3ed977d..9e43ccd 100755
--- a/scripts/create_categories.py
+++ b/scripts/create_categories.py
@@ -82,7 +82,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
parent = None
basename = None
diff --git a/scripts/data_ingestion.py b/scripts/data_ingestion.py
index 6e39a59..709dc5d 100755
--- a/scripts/data_ingestion.py
+++ b/scripts/data_ingestion.py
@@ -248,7 +248,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
# Process global args and prepare generator args parser
local_args = pywikibot.handle_args(args)
diff --git a/scripts/delete.py b/scripts/delete.py
index 8612e1d..6c995c1 100755
--- a/scripts/delete.py
+++ b/scripts/delete.py
@@ -226,7 +226,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
page_name = ''
summary = None
diff --git a/scripts/disambredir.py b/scripts/disambredir.py
index cbb1920..5b1e736 100755
--- a/scripts/disambredir.py
+++ b/scripts/disambredir.py
@@ -66,7 +66,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
local_args = pywikibot.handle_args(args)
diff --git a/scripts/djvutext.py b/scripts/djvutext.py
index bbe9ed6..79dbf16 100644
--- a/scripts/djvutext.py
+++ b/scripts/djvutext.py
@@ -130,7 +130,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
index = None
djvu_path = '.' # default djvu file directory
diff --git a/scripts/editarticle.py b/scripts/editarticle.py
index 4918e8d..b1dc3da 100755
--- a/scripts/editarticle.py
+++ b/scripts/editarticle.py
@@ -117,7 +117,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
app = ArticleEditor(*args)
app.run()
diff --git a/scripts/fixing_redirects.py b/scripts/fixing_redirects.py
index 8c3ee81..592806b 100755
--- a/scripts/fixing_redirects.py
+++ b/scripts/fixing_redirects.py
@@ -175,7 +175,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
featured = False
gen = None
diff --git a/scripts/flickrripper.py b/scripts/flickrripper.py
index b75ec67..9efd9df 100755
--- a/scripts/flickrripper.py
+++ b/scripts/flickrripper.py
@@ -415,7 +415,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
local_args = pywikibot.handle_args(args)
diff --git a/scripts/followlive.py b/scripts/followlive.py
index 354ad32..4dbb70b 100644
--- a/scripts/followlive.py
+++ b/scripts/followlive.py
@@ -551,7 +551,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
# Generate the question text
pywikibot.handle_args(*args)
diff --git a/scripts/freebasemappingupload.py b/scripts/freebasemappingupload.py
index 07a40ed..7f397bd 100755
--- a/scripts/freebasemappingupload.py
+++ b/scripts/freebasemappingupload.py
@@ -110,7 +110,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
filename = 'fb2w.nt.gz' # Default filename
for arg in pywikibot.handle_args(args):
diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py
index b0ff2fd..228a3e9 100755
--- a/scripts/harvest_template.py
+++ b/scripts/harvest_template.py
@@ -317,7 +317,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
template_title = None
diff --git a/scripts/illustrate_wikidata.py b/scripts/illustrate_wikidata.py
index 94e79e4..7c050b3 100755
--- a/scripts/illustrate_wikidata.py
+++ b/scripts/illustrate_wikidata.py
@@ -90,7 +90,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
# Process global args and prepare generator args parser
local_args = pywikibot.handle_args(args)
diff --git a/scripts/image.py b/scripts/image.py
index dcae5af..78368bb 100755
--- a/scripts/image.py
+++ b/scripts/image.py
@@ -130,7 +130,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
old_image = None
new_image = None
diff --git a/scripts/imagerecat.py b/scripts/imagerecat.py
index feebfe1..be97bb6 100755
--- a/scripts/imagerecat.py
+++ b/scripts/imagerecat.py
@@ -450,7 +450,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
generator = None
onlyFilter = False
diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py
index bc7db3e..6f606df 100755
--- a/scripts/imagetransfer.py
+++ b/scripts/imagetransfer.py
@@ -282,7 +282,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
gen = None
diff --git a/scripts/imageuncat.py b/scripts/imageuncat.py
index 870dbc3..46b8035 100755
--- a/scripts/imageuncat.py
+++ b/scripts/imageuncat.py
@@ -1316,7 +1316,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
generator = None
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index 6d0304c..246d640 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -2387,7 +2387,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
singlePageTitle = ''
opthintsonly = False
diff --git a/scripts/interwikidata.py b/scripts/interwikidata.py
index 9e06001..8e5a71c 100644
--- a/scripts/interwikidata.py
+++ b/scripts/interwikidata.py
@@ -218,7 +218,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
local_args = pywikibot.handle_args(args)
gen_factory = pagegenerators.GeneratorFactory()
diff --git a/scripts/isbn.py b/scripts/isbn.py
index f0bec35..4c8ab93 100755
--- a/scripts/isbn.py
+++ b/scripts/isbn.py
@@ -1637,7 +1637,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
diff --git a/scripts/listpages.py b/scripts/listpages.py
index b5d3ddb..bd95806 100755
--- a/scripts/listpages.py
+++ b/scripts/listpages.py
@@ -175,7 +175,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
gen = None
notitle = False
diff --git a/scripts/login.py b/scripts/login.py
index ece07018..8e949b1 100755
--- a/scripts/login.py
+++ b/scripts/login.py
@@ -116,7 +116,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
password = None
sysop = False
diff --git a/scripts/lonelypages.py b/scripts/lonelypages.py
index 0f8c4b4..317f4e0 100755
--- a/scripts/lonelypages.py
+++ b/scripts/lonelypages.py
@@ -230,7 +230,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
diff --git a/scripts/maintenance/download_dump.py b/scripts/maintenance/download_dump.py
index 9844889..b2291b9 100644
--- a/scripts/maintenance/download_dump.py
+++ b/scripts/maintenance/download_dump.py
@@ -204,7 +204,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
opts = {}
unknown_args = []
diff --git a/scripts/makecat.py b/scripts/makecat.py
index c81504e..2ed0f0e 100755
--- a/scripts/makecat.py
+++ b/scripts/makecat.py
@@ -225,7 +225,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
global workingcat, parentcats
global checked, tocheck
diff --git a/scripts/misspelling.py b/scripts/misspelling.py
index 7aca9f6..b825999 100755
--- a/scripts/misspelling.py
+++ b/scripts/misspelling.py
@@ -166,7 +166,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
# the option that's always selected when the bot wonders what to do with
# a link. If it's None, the user is prompted (default behaviour).
diff --git a/scripts/movepages.py b/scripts/movepages.py
index 9ce5d48..6630f3d 100755
--- a/scripts/movepages.py
+++ b/scripts/movepages.py
@@ -180,7 +180,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
oldName = None
options = {}
diff --git a/scripts/ndashredir.py b/scripts/ndashredir.py
index 1928356..29eb67a 100644
--- a/scripts/ndashredir.py
+++ b/scripts/ndashredir.py
@@ -128,7 +128,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
# Process global arguments to determine desired site
diff --git a/scripts/newitem.py b/scripts/newitem.py
index 82df37c..937910a 100755
--- a/scripts/newitem.py
+++ b/scripts/newitem.py
@@ -127,7 +127,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
# Process global args and prepare generator args parser
local_args = pywikibot.handle_args(args)
diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index 39d67f0..b2964c1 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -731,7 +731,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
diff --git a/scripts/nowcommons.py b/scripts/nowcommons.py
index b29d7df..6a3f431 100755
--- a/scripts/nowcommons.py
+++ b/scripts/nowcommons.py
@@ -374,7 +374,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py
index add9054..21d41ae 100755
--- a/scripts/pagefromfile.py
+++ b/scripts/pagefromfile.py
@@ -291,7 +291,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
filename = "dict.txt"
options = {}
diff --git a/scripts/protect.py b/scripts/protect.py
index bd1f24c..1aa5d5a 100755
--- a/scripts/protect.py
+++ b/scripts/protect.py
@@ -152,7 +152,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
message_properties = {}
diff --git a/scripts/redirect.py b/scripts/redirect.py
index b4cd567..dff042e 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -688,7 +688,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
gen_options = {}
diff --git a/scripts/reflinks.py b/scripts/reflinks.py
index 0821d1c..ef86f97 100755
--- a/scripts/reflinks.py
+++ b/scripts/reflinks.py
@@ -767,7 +767,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
xml_filename = None
xml_start = None
diff --git a/scripts/replace.py b/scripts/replace.py
index a0c04fa..00fb7bb 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -871,7 +871,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
add_cat = None
gen = None
diff --git a/scripts/replicate_wiki.py b/scripts/replicate_wiki.py
index 99394cf..fe486f0 100755
--- a/scripts/replicate_wiki.py
+++ b/scripts/replicate_wiki.py
@@ -244,7 +244,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
my_args = pywikibot.handle_args(args)
diff --git a/scripts/revertbot.py b/scripts/revertbot.py
index 0278d54..ddcea48 100755
--- a/scripts/revertbot.py
+++ b/scripts/revertbot.py
@@ -145,7 +145,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
user = None
rollback = False
diff --git a/scripts/script_wui.py b/scripts/script_wui.py
index 50c9bf4..40c4d10 100755
--- a/scripts/script_wui.py
+++ b/scripts/script_wui.py
@@ -330,7 +330,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
global __simulate, __sys_argv
diff --git a/scripts/selflink.py b/scripts/selflink.py
index 38ee6df..4c08e6a 100755
--- a/scripts/selflink.py
+++ b/scripts/selflink.py
@@ -80,7 +80,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
# Process global args and prepare generator args parser
local_args = pywikibot.handle_args(args)
diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py
index 50d4ce8..d08a7e0 100755
--- a/scripts/solve_disambiguation.py
+++ b/scripts/solve_disambiguation.py
@@ -1174,7 +1174,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
# the option that's always selected when the bot wonders what to do with
# a link. If it's None, the user is prompted (default behaviour).
diff --git a/scripts/spamremove.py b/scripts/spamremove.py
index 6e94a66..db76bd3 100755
--- a/scripts/spamremove.py
+++ b/scripts/spamremove.py
@@ -125,7 +125,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
spam_external_url = None
protocol = 'http'
diff --git a/scripts/states_redirect.py b/scripts/states_redirect.py
index bdac42b..2cc6012 100755
--- a/scripts/states_redirect.py
+++ b/scripts/states_redirect.py
@@ -115,7 +115,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
local_args = pywikibot.handle_args(args)
start = None
diff --git a/scripts/surnames_redirects.py b/scripts/surnames_redirects.py
index 5071c2d..635815f 100755
--- a/scripts/surnames_redirects.py
+++ b/scripts/surnames_redirects.py
@@ -106,7 +106,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
diff --git a/scripts/table2wiki.py b/scripts/table2wiki.py
index 4235578..cb66d7d 100644
--- a/scripts/table2wiki.py
+++ b/scripts/table2wiki.py
@@ -522,7 +522,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
gen = None
diff --git a/scripts/template.py b/scripts/template.py
index 0a729b9..b9f546c 100755
--- a/scripts/template.py
+++ b/scripts/template.py
@@ -269,7 +269,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
template_names = []
templates = {}
diff --git a/scripts/templatecount.py b/scripts/templatecount.py
index ff383a0..adc0896 100755
--- a/scripts/templatecount.py
+++ b/scripts/templatecount.py
@@ -154,7 +154,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
operation = None
args_list = []
diff --git a/scripts/touch.py b/scripts/touch.py
index b5ee1bd..732f56b 100755
--- a/scripts/touch.py
+++ b/scripts/touch.py
@@ -74,7 +74,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
gen = None
options = {}
diff --git a/scripts/transferbot.py b/scripts/transferbot.py
index 48d2846..c0b0d8e 100755
--- a/scripts/transferbot.py
+++ b/scripts/transferbot.py
@@ -87,7 +87,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
local_args = pywikibot.handle_args(args)
diff --git a/scripts/unlink.py b/scripts/unlink.py
index dd9abe5..89097a4 100755
--- a/scripts/unlink.py
+++ b/scripts/unlink.py
@@ -62,7 +62,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
# This temporary string is used to read the title
# of the page that should be unlinked.
diff --git a/scripts/unusedfiles.py b/scripts/unusedfiles.py
index 3b7a428..cad7df0 100755
--- a/scripts/unusedfiles.py
+++ b/scripts/unusedfiles.py
@@ -108,7 +108,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
options = {}
total = None
diff --git a/scripts/upload.py b/scripts/upload.py
index 8e81522..5faf354 100755
--- a/scripts/upload.py
+++ b/scripts/upload.py
@@ -100,7 +100,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
url = u''
description = []
diff --git a/scripts/watchlist.py b/scripts/watchlist.py
index 716f424..206d21b 100755
--- a/scripts/watchlist.py
+++ b/scripts/watchlist.py
@@ -91,7 +91,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
all = False
new = False
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py
index f29edf6..0a232c6 100755
--- a/scripts/weblinkchecker.py
+++ b/scripts/weblinkchecker.py
@@ -953,7 +953,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
gen = None
xmlFilename = None
diff --git a/scripts/welcome.py b/scripts/welcome.py
index 42f2781..17419b4 100755
--- a/scripts/welcome.py
+++ b/scripts/welcome.py
@@ -902,7 +902,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
for arg in pywikibot.handle_args(args):
arg, sep, val = arg.partition(':')
diff --git a/scripts/wikisourcetext.py b/scripts/wikisourcetext.py
index df3f5c4..8286604 100644
--- a/scripts/wikisourcetext.py
+++ b/scripts/wikisourcetext.py
@@ -131,7 +131,7 @@
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: list of unicode
+ @type args: unicode
"""
index = None
pages = '1-'
diff --git a/tests/utils.py b/tests/utils.py
index fe8a9ed..c6ce1c6 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -727,7 +727,7 @@
Execute the pwb.py script and capture outputs.
@param args: list of arguments for pwb.py
- @type args: list of unicode
+ @type args: typing.Sequence[unicode]
@param overrides: mapping of pywikibot symbols to test replacements
@type overrides: dict
"""
--
To view, visit https://gerrit.wikimedia.org/r/459270
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I7f0db256b52714c5e46db0a9f609831bee74ac53
Gerrit-Change-Number: 459270
Gerrit-PatchSet: 3
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/458749 )
Change subject: [IMPR] Use bot instance instead of bot class
......................................................................
[IMPR] Use bot instance instead of bot class
- improve option handling
- remove some globals no longer needed
- just return from main() instead of sys.exit()
4th step detached from Id7ca3461d for easier reviewing
Change-Id: I7e6b18b046052e83d0b4848d537d2b62957d61d6
---
M scripts/makecat.py
1 file changed, 59 insertions(+), 55 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/makecat.py b/scripts/makecat.py
index 3d5e589..c81504e 100755
--- a/scripts/makecat.py
+++ b/scripts/makecat.py
@@ -49,7 +49,6 @@
from __future__ import absolute_import, unicode_literals
import codecs
-import sys
import pywikibot
@@ -63,27 +62,42 @@
"""Bot tries to find new articles for a given category."""
- @staticmethod
- def needcheck(page):
+ def __init__(self, **kwargs):
+ """Initializer."""
+ self.availableOptions.update({
+ 'all': False,
+ 'exist': False,
+ 'forward': False,
+ 'keepparent': False,
+ 'nodate': False,
+ })
+ super(MakeCatBot, self).__init__(**kwargs)
+ self.skipdates = self.getOption('nodate')
+ self.checkforward = True
+ self.checkbackward = not self.getOption('forward')
+ self.checkbroken = not (self.getOption('forward')
+ and self.getOption('exist'))
+ self.removeparent = not self.getOption('keepparent')
+ self.main = not self.getOption('all')
+
+ def needcheck(self, page):
"""Verify whether the current page may be processed."""
- global main_ns, checked, skipdates
- return not (main_ns and page.namespace() != 0
+ global checked
+ return not (self.main and page.namespace() != 0
or page in checked
- or skipdates and page.autoFormat()[0] is not None)
+ or self.skipdates and page.autoFormat()[0] is not None)
def change_category(self, page, catlist):
"""Change the category of page."""
pass
- @classmethod
- def include(cls, pl, checklinks=True, realinclude=True, linkterm=None,
+ def include(self, pl, checklinks=True, realinclude=True, linkterm=None,
summary=''):
"""Include the current page to the working category."""
- global mysite
- global workingcat, parentcats, removeparent
- global checkforward, checkbackward
+ global workingcat, parentcats
global checked, tocheck
cl = checklinks
+ mysite = self.site
if linkterm:
actualworkingcat = pywikibot.Category(mysite, workingcat.title(),
sort_key=linkterm)
@@ -102,7 +116,7 @@
cats = [x for x in pl.categories()]
for c in cats:
if c in parentcats:
- if removeparent:
+ if self.removeparent:
pl.change_category(actualworkingcat,
summary=summary)
break
@@ -111,14 +125,14 @@
text, cats + [actualworkingcat], site=pl.site),
summary=summary)
if cl:
- if checkforward:
+ if self.checkforward:
for page2 in pl.linkedPages():
- if cls.needcheck(page2):
+ if self.needcheck(page2):
tocheck.append(page2)
checked[page2] = page2
- if checkbackward:
+ if self.checkbackward:
for ref_page in pl.getReferences():
- if cls.needcheck(ref_page):
+ if self.needcheck(ref_page):
tocheck.append(ref_page)
checked[ref_page] = ref_page
@@ -126,17 +140,16 @@
"""Check whether the page is to be skipped."""
pass
- @classmethod
- def asktoadd(cls, pl, summary):
+ def asktoadd(self, pl, summary):
"""Work on current page and ask to add article to category."""
- global mysite
global checked, tocheck
global excludefile
+ mysite = self.site
if pl.site != mysite:
return
if pl.isRedirectPage():
pl2 = pl.getRedirectTarget()
- if cls.needcheck(pl2):
+ if self.needcheck(pl2):
tocheck.append(pl2)
checked[pl2] = pl2
return
@@ -146,18 +159,18 @@
while True:
answer = pywikibot.input('[y]es/[n]o/[i]gnore/[h]elp for options?')
if answer == 'y':
- cls.include(pl, summary=summary)
+ self.include(pl, summary=summary)
break
if answer == 'c':
- cls.include(pl, realinclude=False)
+ self.include(pl, realinclude=False)
break
if answer == 'k':
if pl.exists() and not pl.isRedirectPage():
linkterm = pywikibot.input(
'In what manner should it be alphabetized?')
- cls.include(pl, linkterm=linkterm, summary=summary)
+ self.include(pl, linkterm=linkterm, summary=summary)
break
- cls.include(pl, summary=summary)
+ self.include(pl, summary=summary)
break
elif answer == 'n':
excludefile.write('%s\n' % pl.title())
@@ -166,7 +179,7 @@
break
elif answer == 'h':
pywikibot.output("""
-[m]ore: Show the beginning of the page text
+[m]ore: show more content of the page starting from the beginning
sort [k]ey: Add with sort key like [[Category|Title]]
[s]kip: Add the page, but skip checking links
[c]heck: Do not add the page, but do check links
@@ -177,16 +190,16 @@
pagetitle = pywikibot.input('Specify page to add:')
page = pywikibot.Page(pywikibot.Site(), pagetitle)
if page not in checked.keys():
- cls.include(page, summary=summary)
+ self.include(page, summary=summary)
elif answer == 's':
if not pl.exists():
pywikibot.output('Page does not exist; not added.')
elif pl.isRedirectPage():
pywikibot.output(
'Redirect page. Will be included normally.')
- cls.include(pl, realinclude=False)
+ self.include(pl, realinclude=False)
else:
- cls.include(pl, checklinks=False, summary=summary)
+ self.include(pl, checklinks=False, summary=summary)
break
elif answer == 'l':
pywikibot.output('Number of pages still to check: {}'
@@ -214,47 +227,38 @@
@param args: command line arguments
@type args: list of unicode
"""
- global main_ns, skipdates
- global mysite
- global workingcat, parentcats, removeparent
- global checkforward, checkbackward
+ global workingcat, parentcats
global checked, tocheck
global excludefile
- main_ns = True
- skipdates = False
- removeparent = True
- checkforward = True
- checkbackward = True
checked = {}
tocheck = DequeGenerator()
- checkbroken = True
workingcatname = ''
+ options = {}
local_args = pywikibot.handle_args(args)
for arg in local_args:
- if arg.startswith('-nodate'):
- skipdates = True
- elif arg.startswith('-forward'):
- checkbackward = False
- checkbroken = False
- elif arg.startswith('-exist'):
- checkbroken = False
- elif arg.startswith('-keepparent'):
- removeparent = False
- elif arg.startswith('-all'):
- main_ns = False
- elif not workingcatname:
- workingcatname = arg
+ option = arg[1:]
+ if not arg.startswith('-'):
+ if not workingcatname:
+ workingcatname = arg
+ else:
+ pywikibot.warning('Working category "{}" is already given.'
+ .format(workingcatname))
+ else:
+ options[option] = True
if not workingcatname:
pywikibot.bot.suggest_help(missing_parameters=['working category'])
- sys.exit(0)
+ return
mysite = pywikibot.Site()
summary = i18n.twtranslate(mysite, 'makecat-create',
{'cat': workingcatname})
+
+ bot = MakeCatBot(site=mysite, **options)
+
workingcat = pywikibot.Category(mysite,
'%s%s'
% (mysite.namespaces.CATEGORY,
@@ -310,13 +314,13 @@
for pl in articles:
checked[pl] = pl
- MakeCatBot.include(pl, summary=summary)
+ bot.include(pl, summary=summary)
gen = pagegenerators.DequePreloadingGenerator(tocheck)
for page in gen:
- if checkbroken or page.exists():
- MakeCatBot.asktoadd(page, summary)
+ if bot.checkbroken or page.exists():
+ bot.asktoadd(page, summary)
if __name__ == '__main__':
--
To view, visit https://gerrit.wikimedia.org/r/458749
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I7e6b18b046052e83d0b4848d537d2b62957d61d6
Gerrit-Change-Number: 458749
Gerrit-PatchSet: 6
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/458465 )
Change subject: [fix] Skip QueryStringParamsTestCase.test_no_params() for status 503
......................................................................
[fix] Skip QueryStringParamsTestCase.test_no_params() for status 503
Skip http_tests.QueryStringParamsTestCase.test_no_params() for status 503
Bug: T203637
Change-Id: Ie3e26e409c37f5dbfff2c92123d91713f0d4ee9d
---
M tests/http_tests.py
1 file changed, 17 insertions(+), 4 deletions(-)
Approvals:
Framawiki: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/http_tests.py b/tests/http_tests.py
index 6b6c89d..5125eec 100644
--- a/tests/http_tests.py
+++ b/tests/http_tests.py
@@ -643,9 +643,17 @@
urldecoded query string parameters.
"""
+ def setUp(self):
+ """Set up tests."""
+ super(QueryStringParamsTestCase, self).setUp()
+ self.url = self.get_httpbin_url('/get')
+
def test_no_params(self):
"""Test fetch method with no parameters."""
- r = http.fetch(uri=self.get_httpbin_url('/get'), params={})
+ r = http.fetch(uri=self.url, params={})
+ if r.status == 503: # T203637
+ unittest.skipTest('503: Service currently not available for '
+ + self.url)
self.assertEqual(r.status, 200)
content = json.loads(r.text)
@@ -658,7 +666,10 @@
HTTPBin returns the args in their urldecoded form, so what we put in should be
the same as what we get out.
"""
- r = http.fetch(uri=self.get_httpbin_url('/get'), params={'fish&chips': 'delicious'})
+ r = http.fetch(uri=self.url, params={'fish&chips': 'delicious'})
+ if r.status == 503: # T203637
+ unittest.skipTest('503: Service currently not available for '
+ + self.url)
self.assertEqual(r.status, 200)
content = json.loads(r.text)
@@ -671,8 +682,10 @@
HTTPBin returns the args in their urldecoded form, so what we put in should be
the same as what we get out.
"""
- r = http.fetch(uri=self.get_httpbin_url('/get'),
- params={'fish%26chips': 'delicious'})
+ r = http.fetch(uri=self.url, params={'fish%26chips': 'delicious'})
+ if r.status == 503: # T203637
+ unittest.skipTest('503: Service currently not available for '
+ + self.url)
self.assertEqual(r.status, 200)
content = json.loads(r.text)
--
To view, visit https://gerrit.wikimedia.org/r/458465
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie3e26e409c37f5dbfff2c92123d91713f0d4ee9d
Gerrit-Change-Number: 458465
Gerrit-PatchSet: 7
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/459233 )
Change subject: [bugfix] Add support for wikimania.wikimedia.org
......................................................................
[bugfix] Add support for wikimania.wikimedia.org
New wiki where apparently all Wikimanias will be organized and
documented as of now on, instead of having one wiki created per year. It
currently lacks family support so no pywikibot can operate there without
creating a custom file. This patch adds a `wikimania` code in the
`wikimediachapter` family file (*.wikimedia.org wikis) so it can work.
Bug: T203868
Change-Id: If481af829fccda417945607016442d842e841977
---
M pywikibot/families/wikimediachapter_family.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/families/wikimediachapter_family.py b/pywikibot/families/wikimediachapter_family.py
index 1f12b76..23c4257 100644
--- a/pywikibot/families/wikimediachapter_family.py
+++ b/pywikibot/families/wikimediachapter_family.py
@@ -23,7 +23,7 @@
codes = [
'am', 'ar', 'bd', 'be', 'br', 'ca', 'cn', 'co', 'dk', 'ec', 'et', 'fi',
'id', 'il', 'mai', 'mk', 'mx', 'nl', 'no', 'nyc', 'pl', 'pt', 'rs',
- 'ru', 'se', 'tr', 'ua', 'uk', 've', 'wb',
+ 'ru', 'se', 'tr', 'ua', 'uk', 've', 'wb', 'wikimania',
]
@classproperty
--
To view, visit https://gerrit.wikimedia.org/r/459233
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: If481af829fccda417945607016442d842e841977
Gerrit-Change-Number: 459233
Gerrit-PatchSet: 1
Gerrit-Owner: MarcoAurelio <maurelio(a)tools.wmflabs.org>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/458823 )
Change subject: Remove cryptography<2.3 from python<=2.7.6 requirements
......................................................................
Remove cryptography<2.3 from python<=2.7.6 requirements
It's better to let users deal with the error rather than to have an
insecure dependency in requirements.
- Remove cryptography>=1.3.4,<2.3 from requirements
- Use requests[security] instead of individually installing them.
The change will cause test failures on Travis-CI's
Python 2.7_with_system_site_packages job. Reconfigure that job to use a
Xenial dist instead of Trusty which has a more up-to-date ssl module.
Note that although Toolforge currently has an old Python version (2.7.6),
but the ssl module is recent enough to not have this issue. So, this change
will not affect Toolforge users.
Bug: T203435
Change-Id: Ia7a1672cadf45a15a12969598f95f5cc5384995d
---
M .travis.yml
M requests-requirements.txt
M requirements.txt
M setup.py
4 files changed, 5 insertions(+), 16 deletions(-)
Approvals:
Framawiki: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.travis.yml b/.travis.yml
index 479b58b..30e5218 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -131,7 +131,7 @@
include:
- python: '2.7_with_system_site_packages'
env: LANGUAGE=nb FAMILY=wikipedia DIST=trusty PYSETUP_TEST_EXTRAS=1 PYWIKIBOT_TEST_NO_RC=1
- dist: trusty
+ dist: xenial
sudo: required
addons:
apt:
diff --git a/requests-requirements.txt b/requests-requirements.txt
index 98c4f2c..1e18a8d 100644
--- a/requests-requirements.txt
+++ b/requests-requirements.txt
@@ -3,10 +3,4 @@
requests>=2.9,!=2.18.2
# requests security extra
-# Bug T105767 on Python 2.7 release 9+
-cryptography>=1.3.4 ; python_full_version == '2.7.7' or python_full_version == '2.7.8'
-cryptography>=1.3.4,<2.3 ; python_full_version <= '2.7.6'
-pyOpenSSL>=0.14,!=17.2.0 ; python_full_version < '2.7.9'
-idna>=2.0.0 ; python_full_version < '2.7.9'
-# https://github.com/eliben/pycparser/issues/147
-pycparser != 2.14
+requests[security] ; python_full_version > '2.7.6' and python_full_version < '2.7.9'
diff --git a/requirements.txt b/requirements.txt
index 18c5c52..66019c6 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -22,13 +22,7 @@
requests>=2.9,!=2.18.2
# requests security extra
-cryptography>=1.3.4 ; python_full_version == '2.7.7' or python_full_version == '2.7.8'
-cryptography>=1.3.4,<2.3 ; python_full_version <= '2.7.6'
-pyOpenSSL>=0.14,!=17.2.0 ; python_full_version < '2.7.9'
-
-idna>=2.0.0 ; python_full_version < '2.7.9'
-# https://github.com/eliben/pycparser/issues/147
-pycparser != 2.14
+requests[security] ; python_full_version > '2.7.6' and python_full_version < '2.7.9'
future>=0.15.0 ; python_full_version < '2.7.3'
diff --git a/setup.py b/setup.py
index 2bf1b9c..4494d88 100644
--- a/setup.py
+++ b/setup.py
@@ -131,13 +131,14 @@
if PYTHON_VERSION == (2, 7, 2):
dependencies.append('future>=0.15.0') # Bug fixes for HTMLParser
- if PYTHON_VERSION < (2, 7, 9):
+ if (2, 7, 6) < PYTHON_VERSION < (2, 7, 9):
# Python versions before 2.7.9 will cause urllib3 to trigger
# InsecurePlatformWarning warnings for all HTTPS requests. By
# installing with security extras, requests will automatically set
# them up and the warnings will stop. See
# <https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwar…>
# for more details.
+ # There is no secure version of cryptography for Python 2.7.6 or older.
dependencies += extra_deps['security']
script_deps['data_ingestion.py'] = extra_deps['csv']
--
To view, visit https://gerrit.wikimedia.org/r/458823
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia7a1672cadf45a15a12969598f95f5cc5384995d
Gerrit-Change-Number: 458823
Gerrit-PatchSet: 5
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/458821 )
Change subject: [bugfix] Fix doc error introduced in cca2d26a97f5
......................................................................
[bugfix] Fix doc error introduced in cca2d26a97f5
Bug: T187009
Change-Id: I0d94c01400ed6705b0e77b80c0e1df648e12d5a6
---
M pywikibot/site.py
1 file changed, 1 insertion(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 5ac00c9..6d7ef3e 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -4714,8 +4714,7 @@
only list non-patrolled edits; if None, list all
@type patrolled: bool or None
@param top_only: if True, only list changes that are the latest
- revision
- (default False)
+ revision (default False)
@type top_only: bool
@param user: if not None, only list edits by this user or users
@type user: basestring|list
--
To view, visit https://gerrit.wikimedia.org/r/458821
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I0d94c01400ed6705b0e77b80c0e1df648e12d5a6
Gerrit-Change-Number: 458821
Gerrit-PatchSet: 1
Gerrit-Owner: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/458727 )
Change subject: [IMPR] Change option shortcuts
......................................................................
[IMPR] Change option shortcuts
- change T(ext) to M(ore) as this is more usual to display more text
- change Z(ap) to T(title) to change the title
- change eX(cept) to S(kip) for skipping further checkings
- change A(dd) to O(ther) due to not collide with "always" option later
- change O(ther) to H(elp) to show a options help list
- decrease nesting depth of some options
3rd step detached from Id7ca3461d for easier reviewing
Change-Id: Ic71775e1eeccd797ac34893a3c2dc4b78d71c51a
---
M scripts/makecat.py
1 file changed, 34 insertions(+), 37 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/makecat.py b/scripts/makecat.py
index fdb164d..3d5e589 100755
--- a/scripts/makecat.py
+++ b/scripts/makecat.py
@@ -27,18 +27,18 @@
When running the bot, you will get one by one a number by pages.
You can choose:
-* Y(es) - include the page
-* N(o) - do not include the page or
-* I(gnore) - do not include the page, but if you meet it again, ask again.
+* [y]es - include the page
+* [n]o - do not include the page or
+* [i]gnore - do not include the page, but if you meet it again, ask again.
Other possibilities:
-* T(ext) - show the beginning of the page text
-* Z(ap) - add under another title (as [[Category|Title]])
-* eX(cept) - add the page, but do not check links to and from it
-* C(heck) - check links to and from the page, but do not add the page itself
-* A(dd) - add another page, which may have been included before
-* L(ist) - show current list of pages to include or to check
+* [m]ore - show more content of the page starting from the beginning
+* sort [k]ey - add with sort key like [[Category|Title]]
+* [s]kip - add the page, but skip checking links to and from it
+* [c]heck - check links to and from the page, but do not add the page itself
+* [o]ther - add another page, which may have been included before
+* [l]ist - show current list of pages to include or to check
"""
# (C) Andre Engels, 2004
@@ -144,20 +144,19 @@
pywikibot.output('')
pywikibot.output('== {} =='.format(pl.title()))
while True:
- answer = pywikibot.input('[y]es/[n]o/[i]gnore/[o]ther options?')
+ answer = pywikibot.input('[y]es/[n]o/[i]gnore/[h]elp for options?')
if answer == 'y':
cls.include(pl, summary=summary)
break
if answer == 'c':
cls.include(pl, realinclude=False)
break
- if answer == 'z':
- if pl.exists():
- if not pl.isRedirectPage():
- linkterm = pywikibot.input(
- 'In what manner should it be alphabetized?')
- cls.include(pl, linkterm=linkterm, summary=summary)
- break
+ if answer == 'k':
+ if pl.exists() and not pl.isRedirectPage():
+ linkterm = pywikibot.input(
+ 'In what manner should it be alphabetized?')
+ cls.include(pl, linkterm=linkterm, summary=summary)
+ break
cls.include(pl, summary=summary)
break
elif answer == 'n':
@@ -165,31 +164,29 @@
break
elif answer == 'i':
break
+ elif answer == 'h':
+ pywikibot.output("""
+[m]ore: Show the beginning of the page text
+sort [k]ey: Add with sort key like [[Category|Title]]
+[s]kip: Add the page, but skip checking links
+[c]heck: Do not add the page, but do check links
+[o]ther: Add another page
+[l]ist: Show a list of the pages to check
+""")
elif answer == 'o':
- pywikibot.output(
- 't: Give the beginning of the text of the page')
- pywikibot.output(
- 'z: Add under another title (as [[Category|Title]])')
- pywikibot.output(
- 'x: Add the page, but do not check links to and from it')
- pywikibot.output('c: Do not add the page, but do check links')
- pywikibot.output('a: Add another page')
- pywikibot.output('l: Give a list of the pages to check')
- elif answer == 'a':
pagetitle = pywikibot.input('Specify page to add:')
page = pywikibot.Page(pywikibot.Site(), pagetitle)
if page not in checked.keys():
cls.include(page, summary=summary)
- elif answer == 'x':
- if pl.exists():
- if pl.isRedirectPage():
- pywikibot.output(
- 'Redirect page. Will be included normally.')
- cls.include(pl, realinclude=False)
- else:
- cls.include(pl, checklinks=False, summary=summary)
- else:
+ elif answer == 's':
+ if not pl.exists():
pywikibot.output('Page does not exist; not added.')
+ elif pl.isRedirectPage():
+ pywikibot.output(
+ 'Redirect page. Will be included normally.')
+ cls.include(pl, realinclude=False)
+ else:
+ cls.include(pl, checklinks=False, summary=summary)
break
elif answer == 'l':
pywikibot.output('Number of pages still to check: {}'
@@ -197,7 +194,7 @@
pywikibot.output('Pages to be checked:')
pywikibot.output(' - '.join(page.title() for page in tocheck))
pywikibot.output('== {} =='.format(pl.title()))
- elif answer == 't':
+ elif answer == 'm':
pywikibot.output('== {} =='.format(pl.title()))
try:
pywikibot.output('' + pl.get(get_redirect=True)[0:ctoshow])
--
To view, visit https://gerrit.wikimedia.org/r/458727
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic71775e1eeccd797ac34893a3c2dc4b78d71c51a
Gerrit-Change-Number: 458727
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/458473 )
Change subject: [doc] Update doc for makecat.py
......................................................................
[doc] Update doc for makecat.py
- describe some undocumented options
- remove R(emove) option which isn't implemented
detached from Id7ca3461
Change-Id: I42690d413dce56b6773c1ea7403d63f2b1c2d330
---
M scripts/makecat.py
1 file changed, 28 insertions(+), 23 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/makecat.py b/scripts/makecat.py
index 743a67b..511dd77 100755
--- a/scripts/makecat.py
+++ b/scripts/makecat.py
@@ -1,40 +1,45 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
-This bot takes as its argument the name of a new or existing category.
+Bot to add new or existing categories to pages.
-It will then try to find new articles for this category
-(pages linked to and from pages already in the category),
+This bot takes as its argument the name of a new or existing category.
+Multiple categories may be given. It will then try to find new articles
+for these categories (pages linked to and from pages already in the category),
asking the user which pages to include and which not.
The following command line parameters are supported:
--nodates Automatically skip all pages that are years or dates
- (years only work AD, dates only for certain languages).
+-nodates Automatically skip all pages that are years or dates
+ (years only work AD, dates only for certain languages).
--forward Only check pages linked from pages already in the category,
- not pages linking to them. Is less precise but quite a bit faster.
+-forward Only check pages linked from pages already in the category,
+ not pages linking to them. Is less precise but quite a bit faster.
--exist Only ask about pages that do actually exist;
- drop any titles of non-existing pages silently.
- If -forward is chosen, -exist is automatically implied.
+-exist Only ask about pages that do actually exist;
+ drop any titles of non-existing pages silently.
+ If -forward is chosen, -exist is automatically implied.
--keepparent Do not remove parent categories of the category to be worked on.
+-keepparent Do not remove parent categories of the category to be worked on.
--all Work on all pages (default: only main namespace)
+-all Work on all pages (default: only main namespace)
-When running the bot, you will get one by one a number by pages. You can
-choose:
-Y(es) - include the page
-N(o) - do not include the page or
-I(gnore) - do not include the page, but if you meet it again, ask again.
-X - add the page, but do not check links to and from it
+When running the bot, you will get one by one a number by pages.
+You can choose:
-Other possiblities:
-A(dd) - add another page, which may have been one that was included before
-C(heck) - check links to and from the page, but do not add the page itself
-R(emove) - remove a page that is already in the list
-L(ist) - show current list of pages to include or to check
+* Y(es) - include the page
+* N(o) - do not include the page or
+* I(gnore) - do not include the page, but if you meet it again, ask again.
+
+Other possibilities:
+
+* T(ext) - show the beginning of the page text
+* Z(ap) - add under another title (as [[Category|Title]])
+* eX(cept) - add the page, but do not check links to and from it
+* C(heck) - check links to and from the page, but do not add the page itself
+* A(dd) - add another page, which may have been included before
+* L(ist) - show current list of pages to include or to check
+
"""
# (C) Andre Engels, 2004
# (C) Pywikibot team, 2005-2018
--
To view, visit https://gerrit.wikimedia.org/r/458473
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I42690d413dce56b6773c1ea7403d63f2b1c2d330
Gerrit-Change-Number: 458473
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/458508 )
Change subject: [IMPR] Simplify needcheck method
......................................................................
[IMPR] Simplify needcheck method
2nd step detached from Id7ca3461d for easier reviewing
Change-Id: I96f503d45a81d430fea1e202b3d8dcb66174e30c
---
M scripts/makecat.py
1 file changed, 4 insertions(+), 10 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/makecat.py b/scripts/makecat.py
index 82f8b5e..325fa4e 100755
--- a/scripts/makecat.py
+++ b/scripts/makecat.py
@@ -59,18 +59,12 @@
"""Bot tries to find new articles for a given category."""
@staticmethod
- def needcheck(pl):
+ def needcheck(page):
"""Verify whether the current page may be processed."""
global main_ns, checked, skipdates
- if main_ns:
- if pl.namespace() != 0:
- return False
- if pl in checked:
- return False
- if skipdates:
- if pl.autoFormat()[0] is not None:
- return False
- return True
+ return not (main_ns and page.namespace() != 0
+ or page in checked
+ or skipdates and page.autoFormat()[0] is not None)
def change_category(self, page, catlist):
"""Change the category of page."""
--
To view, visit https://gerrit.wikimedia.org/r/458508
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I96f503d45a81d430fea1e202b3d8dcb66174e30c
Gerrit-Change-Number: 458508
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)