jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/844924 )
Change subject: [IMPR] Refactor delete.main() function
......................................................................
[IMPR] Refactor delete.main() function
- simplify arg parsing
- add a pagegenerators loop and create summary inside this loop.
At this point -undelete and -summary options are already seen.
- first ask for -file option in pg loop because -file may also have
a value argument. Unfortunately the summary creation still fails
if the page title was not given with the option e.g. for -link or
-imageused.
- use suggest_help() result to continue
Change-Id: I4f57bfc8808d5f19b0f99eaa5af391679adb554e
---
M scripts/delete.py
1 file changed, 26 insertions(+), 36 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/delete.py b/scripts/delete.py
index c563213..449e741 100755
--- a/scripts/delete.py
+++ b/scripts/delete.py
@@ -224,8 +224,7 @@
def main(*args: str) -> None:
- """
- Process command line arguments and invoke bot.
+ """Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
@@ -234,6 +233,7 @@
page_name = ''
summary = None
options = {}
+ pg_args = []
# read command line parameters
local_args = pywikibot.handle_args(args)
@@ -241,35 +241,31 @@
mysite = pywikibot.Site()
for arg in local_args:
-
- if arg == '-always':
- options['always'] = True
- elif arg.startswith('-summary'):
- if len(arg) == len('-summary'):
- summary = pywikibot.input('Enter a reason for the deletion:')
- else:
- summary = arg[len('-summary:'):]
- elif arg.startswith('-undelete'):
- options['undelete'] = True
- elif arg.startswith('-isorphan'):
- options['isorphan'] = int(arg[10:]) if arg[10:] != '' else 0
- if options['isorphan'] < 0:
- options['isorphan'] = False
- elif arg.startswith('-orphansonly'):
- if arg[13:]:
- namespaces = mysite.namespaces.resolve(arg[13:].split(','))
+ opt, _, value = arg.partition(':')
+ if opt in ('-always', '-undelete'):
+ options[opt[1:]] = True
+ elif opt == '-summary':
+ summary = value or pywikibot.input(
+ 'Enter a reason for the deletion:')
+ elif opt == '-isorphan':
+ value = int(value or 0)
+ options[opt[1:]] = value if value >= 0 else False
+ elif opt == '-orphansonly':
+ if value:
+ namespaces = mysite.namespaces.resolve(value.split(','))
else:
namespaces = mysite.namespaces
- options['orphansonly'] = namespaces
+ options[opt[1:]] = namespaces
else:
- gen_factory.handle_arg(arg)
- found = arg.find(':') + 1
- if found:
- page_name = arg[found:]
+ pg_args.append(arg)
- if not summary:
- un = 'un' if 'undelete' in options else ''
- if page_name:
+ un = 'un' if 'undelete' in options else ''
+ for arg in pg_args:
+ *_, page_name = arg.partition(':')
+ if gen_factory.handle_arg(arg) and not summary:
+ if arg.startswith('-file'):
+ summary = i18n.twtranslate(mysite, un + 'delete-from-file')
+ elif page_name:
if arg.startswith(('-cat', '-subcats')):
summary = i18n.twtranslate(mysite, 'delete-from-category',
{'page': page_name})
@@ -283,21 +279,15 @@
elif arg.startswith('-imageused'):
summary = i18n.twtranslate(mysite, un + 'delete-images',
{'page': page_name})
- elif arg.startswith('-file'):
- summary = i18n.twtranslate(mysite, un + 'delete-from-file')
- generator = gen_factory.getCombinedGenerator()
# We are just deleting pages, so we have no need of using a preloading
# page generator to actually get the text of those pages.
- if generator:
+ generator = gen_factory.getCombinedGenerator()
+ if not pywikibot.bot.suggest_help(missing_generator=not generator):
if summary is None:
- summary = pywikibot.input('Enter a reason for the {}deletion:'
- .format(['', 'un'][options
- .get('undelete', False)]))
+ summary = pywikibot.input(f'Enter a reason for the {un}deletion:')
bot = DeletionRobot(summary, generator=generator, **options)
bot.run()
- else:
- pywikibot.bot.suggest_help(missing_generator=True)
if __name__ == '__main__':
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/844924
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I4f57bfc8808d5f19b0f99eaa5af391679adb554e
Gerrit-Change-Number: 844924
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/855864 )
Change subject: [doc] Use 'furo' sphinx theme instead of 'natural'
......................................................................
[doc] Use 'furo' sphinx theme instead of 'natural'
- use html_theme = 'furo'
- disable 'natural' html_sidebars
- disable 'natural' html_style
- use multiple processes to build distribution
Bug: T322212
Change-Id: Iba1020afd28fc8be164f3f097a946caf1021e2e8
---
M docs/conf.py
M docs/requirements.txt
M tox.ini
3 files changed, 10 insertions(+), 9 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/conf.py b/docs/conf.py
index da8cdb2..b28e251 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -148,7 +148,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
-html_theme = 'nature'
+html_theme = 'furo'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
@@ -198,11 +198,12 @@
# Custom sidebar templates, maps document names to template names.
#
-html_sidebars = {
- '**': [
- 'searchbox.html', 'localtoc.html', 'relations.html', 'sourcelink.html',
- ]
-}
+# html_sidebars = {
+# '**': [
+# 'searchbox.html', 'localtoc.html', 'relations.html',
+# 'sourcelink.html',
+# ]
+# }
# Additional templates that should be rendered to pages, maps page names to
# template names.
@@ -376,7 +377,7 @@
# Pywikibot theme style
html_permalinks_icon = '#'
-html_style = 'css/pywikibot.css'
+# html_style = 'css/pywikibot.css'
extlinks = {
diff --git a/docs/requirements.txt b/docs/requirements.txt
index ac449c1..e287d85 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -1,5 +1,5 @@
# This is a PIP requirements file for building Sphinx documentation of pywikibot
# requirements.txt is also needed
-
+furo
sphinx >= 5.2.3
rstcheck >=6.1.0
\ No newline at end of file
diff --git a/tox.ini b/tox.ini
index 8ef0770..c26452c 100644
--- a/tox.ini
+++ b/tox.ini
@@ -83,7 +83,7 @@
[testenv:doc]
commands =
- sphinx-build -M html ./docs ./docs/_build
+ sphinx-build -M html ./docs ./docs/_build -j auto
rstcheck --version
rstcheck -r --report-level WARNING --ignore-roles api,phab .
basepython = python3.7
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/855864
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: tests
Gerrit-Change-Id: Iba1020afd28fc8be164f3f097a946caf1021e2e8
Gerrit-Change-Number: 855864
Gerrit-PatchSet: 5
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: KBach <kbach(a)wikimedia.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged