Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1034863?usp=email )
Change subject: [doc] Fix some sphinx errors
......................................................................
[doc] Fix some sphinx errors
Change-Id: I4f1420c5a08e51288be888ce07e138fe3b90c9bf
---
M scripts/add_text.py
M scripts/category_graph.py
M scripts/harvest_template.py
3 files changed, 45 insertions(+), 40 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/add_text.py b/scripts/add_text.py
index c490139..d5c07bd 100755
--- a/scripts/add_text.py
+++ b/scripts/add_text.py
@@ -38,25 +38,25 @@
Examples
--------
-1. Append 'hello world' to the bottom of the sandbox:
+Append 'hello world' to the bottom of the sandbox:
python pwb.py add_text -page:Wikipedia:Sandbox \
--summary:"Bot: pywikibot practice" -text:"hello world"
+ -summary:"Bot: pywikibot practice" -text:"hello world"
-2. Add a template to the top of the pages with 'category:catname':
+Add a template to the top of the pages with 'category:catname':
python pwb.py add_text -cat:catname -summary:"Bot: Adding a template" \
--text:"{{Something}}" -except:"\{\{([Tt]emplate:|)[Ss]omething" -up
+ -text:"{{Something}}" -except:"\{\{([Tt]emplate:|)[Ss]omething" -up
-3. Command used on it.wikipedia to put the template in the page without any
- category:
+Command used on it.wikipedia to put the template in the page without any
+category:
python pwb.py add_text -except:"\{\{([Tt]emplate:|)[Cc]ategorizzare" \
--text:"{{Categorizzare}}" -excepturl:"class='catlinks'>" -uncat \
--summary:"Bot: Aggiungo template Categorizzare"
+ -text:"{{Categorizzare}}" -excepturl:"class='catlinks'>" -uncat \
+ -summary:"Bot: Aggiungo template Categorizzare"
"""
#
-# (C) Pywikibot team, 2007-2023
+# (C) Pywikibot team, 2007-2024
#
# Distributed under the terms of the MIT license.
#
diff --git a/scripts/category_graph.py b/scripts/category_graph.py
index 9be4863..829abb7 100755
--- a/scripts/category_graph.py
+++ b/scripts/category_graph.py
@@ -26,13 +26,16 @@
Example
-------
+Visualizes main category:
+
pwb.py -v category_graph -from
-Extended example with style settings::
+Extended example with style settings:
pwb.py category_graph -from Life -downsize 1.5 \
--style 'graph[rankdir=BT ranksep=0.5] node[shape=circle style=filled \
-fillcolor=green] edge[style=dashed penwidth=3]'
+ -style 'graph[rankdir=BT ranksep=0.5] node[shape=circle style=filled \
+ fillcolor=green] edge[style=dashed penwidth=3]'
+
.. versionadded:: 8.0
"""
diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py
index 6fc06c9..55f0344 100755
--- a/scripts/harvest_template.py
+++ b/scripts/harvest_template.py
@@ -1,16 +1,17 @@
#!/usr/bin/env python3
-r"""
-Template harvesting script.
+r"""Template harvesting script.
Usage (see below for explanations and examples):
python pwb.py harvest_template -transcludes:"..." \
-[default optional arguments] template_parameter PID \
-[local optional arguments] [template_parameter PID [local optional arguments]]
+ [default optional arguments] template_parameter PID \
+ [local optional arguments] \
+ [template_parameter PID [local optional arguments]]
python pwb.py harvest_template [generators] -template:"..." \
-[default optional arguments] template_parameter PID \
-[local optional arguments] [template_parameter PID [local optional arguments]]
+ [default optional arguments] template_parameter PID \
+ [local optional arguments] \
+ [template_parameter PID [local optional arguments]]
This will work on all pages that transclude the template in the article
namespace
@@ -52,35 +53,35 @@
"P18" (image):
python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
--template:"Infobox person" image P18
+ -template:"Infobox person" image P18
-The following command will behave the same as the previous example and also
-try to import [[links]] from "birth_place" parameter of the same template
-as Wikidata property "P19" (place of birth):
+The following command will behave the same as the previous example and
+also try to import [[links]] from "birth_place" parameter of the same
+template as Wikidata property "P19" (place of birth):
python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
--template:"Infobox person" image P18 birth_place P19
+ -template:"Infobox person" image P18 birth_place P19
The following command will import both "birth_place" and "death_place"
-params with -islink modifier, ie. the bot will try to import values, even
-if it doesn't find a [[link]]:
+params with -islink modifier, ie. the bot will try to import values,
+even if it doesn't find a [[link]]:
python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
--template:"Infobox person" -islink birth_place P19 death_place P20
+ -template:"Infobox person" -islink birth_place P19 death_place P20
The following command will do the same but only "birth_place" can be
imported without a link:
python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
--template:"Infobox person" birth_place P19 -islink death_place P20
+ -template:"Infobox person" birth_place P19 -islink death_place P20
-The following command will import an occupation from "occupation" parameter
-of "Infobox person" on English Wikipedia as Wikidata property "P106"
-(occupation). The page won't be skipped if the item already has that
-property but there is not the new value:
+The following command will import an occupation from "occupation"
+parameter of "Infobox person" on English Wikipedia as Wikidata property
+"P106" (occupation). The page won't be skipped if the item already has
+that property but there is not the new value:
python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
--template:"Infobox person" occupation P106 -exists:p
+ -template:"Infobox person" occupation P106 -exists:p
The following command will import band members from the "current_members"
parameter of "Infobox musical artist" on English Wikipedia as Wikidata
@@ -88,16 +89,17 @@
if each is linked, and will not add duplicate claims for the same member:
python pwb.py harvest_template -lang:en -family:wikipedia -namespace:0 \
--template:"Infobox musical artist" current_members P527 -exists:p -multi
+ -template:"Infobox musical artist" current_members P527 -exists:p -multi
-The following command will import the category's main topic from the first
-anonymous parameter of "Cat main" on English Wikipedia as Wikidata property
-"P301" (category's main topic) and whenever a new value is imported,
-the inverse claim is imported to the topic item as Wikidata property "P910"
-(topic's main category) unless a claim of that property is already there:
+The following command will import the category's main topic from the
+first anonymous parameter of "Cat main" on English Wikipedia as Wikidata
+property "P301" (category's main topic) and whenever a new value is
+imported, the inverse claim is imported to the topic item as Wikidata
+property "P910" (topic's main category) unless a claim of that property
+is already there:
python pwb.py harvest_template -lang:en -family:wikipedia -namespace:14 \
--template:"Cat main" 1 P301 -inverse:P910 -islink
+ -template:"Cat main" 1 P301 -inverse:P910 -islink
.. note:: This script is a
@@ -107,7 +109,7 @@
the -inverse option.
"""
#
-# (C) Pywikibot team, 2013-2023
+# (C) Pywikibot team, 2013-2024
#
# Distributed under the terms of MIT license.
#
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1034863?usp=email
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: I4f1420c5a08e51288be888ce07e138fe3b90c9bf
Gerrit-Change-Number: 1034863
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
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/+/1034543?usp=email )
Change subject: [doc] Add a hint how to use empty string arguments with PowerShell
......................................................................
[doc] Add a hint how to use empty string arguments with PowerShell
Bug: T364689
Change-Id: I1647f58ce09572322d9d836b79e509b9a5bd1167
---
M scripts/replace.py
1 file changed, 35 insertions(+), 15 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/scripts/replace.py b/scripts/replace.py
index e9f4db5..cb075d9 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -103,33 +103,51 @@
-fullsummary Use one large summary for all command line replacements.
-other: First argument is the old text, second argument is the new
- text. If the -regex argument is given, the first argument
- will be regarded as a regular expression, and the second
- argument might contain expressions like \1 or \g<name>.
- It is possible to introduce more than one pair of old text
- and replacement.
+
+*Replacement parameters*
+ Replacement parameters are pairs of arguments given to the script.
+ The First argument is the old text to be replaced, the second
+ argument is the new text. If the ``-regex`` argument is given, the
+ first argument will be regarded as a regular expression, and the
+ second argument might contain expressions like ``\1`` or ``\g<name>``.
+ The second parameter can also be specified as empty string, usually
+ ``""``. It is possible to introduce more than one pair of
+ replacement parameters.
+
+.. admonition:: **Empty string arguments with PowerShell**
+ :class: attention
+
+ Using PowerShell as command shell removes empty strings during
+ PowerShell's command line parsing. To enable empty strings with
+ PowerShell you have either to escape quotation marks with gravis
+ symbols in front of them like ```"`"`` or to disable command line
+ parsing with ``--%`` symbol for all following command parts like
+ :samp:`python pwb replace --% -start:! foo ""` which disables parsing
+ for all replace options and arguments following this delimiter and
+ enables empty strings.
Examples
--------
-If you want to change templates from the old syntax, e.g. {{msg:Stub}}, to the
-new syntax, e.g. {{Stub}}, download an XML dump file (pages-articles) from
-https://dumps.wikimedia.org, then use this command:
+If you want to change templates from the old syntax, e.g.
+``{{msg:Stub}}``, to the new syntax, e.g. ``{{Stub}}``, download an XML
+dump file (pages-articles) from https://dumps.wikimedia.org, then use
+this command:
python pwb.py replace -xml -regex "{{msg:(.*?)}}" "{{\1}}"
-If you have a dump called foobar.xml and want to fix typos in articles, e.g.
-Errror -> Error, use this:
+If you have a dump called ``foobar.xml`` and want to fix typos in
+articles, e.g. Errror -> Error, use this:
python pwb.py replace -xml:foobar.xml "Errror" "Error" -namespace:0
If you want to do more than one replacement at a time, use this:
python pwb.py replace -xml:foobar.xml "Errror" "Error" "Faail" "Fail" \
--namespace:0
+ -namespace:0
-If you have a page called 'John Doe' and want to fix the format of ISBNs, use:
+If you have a page called 'John Doe' and want to fix the format of ISBNs,
+use:
python pwb.py replace -page:John_Doe -fix:isbn
@@ -138,8 +156,10 @@
python pwb.py replace referer referrer -file:typos.txt -excepttext:HTTP
-Please type "python pwb.py replace -help | more" if you can't read
-the top of the help.
+
+.. seealso:: :mod:`scripts.template` to modify or remove templates.
+.. Please type "python pwb.py replace -help | more" if you can't read
+ the top of the help.
"""
#
# (C) Pywikibot team, 2004-2024
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1034543?usp=email
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: I1647f58ce09572322d9d836b79e509b9a5bd1167
Gerrit-Change-Number: 1034543
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <dalangi-ctr(a)wikimedia.org>
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/+/1032812?usp=email )
Change subject: [doc] fix deprecation list
......................................................................
[doc] fix deprecation list
Change-Id: I81459c13284b21687b82f3319c96ce5d4216aae7
Signed-off-by: Xqt <info(a)gno.de>
---
M ROADMAP.rst
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 1bfeda5..d1ef503 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -66,7 +66,7 @@
* 7.5.0: :mod:`textlib`.tzoneFixedOffset class will be removed in favour of :class:`time.TZoneFixedOffset`
* 7.4.0: ``FilePage.usingPages()`` was renamed to :meth:`using_pages()<pywikibot.FilePage.using_pages>`
* 7.3.0: Old color escape sequences like ``\03{color}`` is deprecated in favour of new color format like <<color>>
-* 7.3.0: ``linkitrail`` method of :class:`family.Family` is deprecated; use :meth:`APISite.linktrail()
+* 7.3.0: ``linktrail`` method of :class:`family.Family` is deprecated; use :meth:`APISite.linktrail()
<pywikibot.site._apisite.APISite.linktrail>` instead
* 7.2.0: ``tb`` parameter of :func:`exception()<pywikibot.exception>` function was renamed to ``exc_info``
* 7.2.0: XMLDumpOldPageGenerator is deprecated in favour of a ``content`` parameter of
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1032812?usp=email
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: I81459c13284b21687b82f3319c96ce5d4216aae7
Gerrit-Change-Number: 1032812
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged