jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/i18n/+/1137736?usp=email )
Change subject: Localisation updates from https://translatewiki.net.
......................................................................
Localisation updates from https://translatewiki.net.
Change-Id: If01755473295480eddba02fc52f52140a195d3ee
---
M redirect/lb.json
1 file changed, 3 insertions(+), 2 deletions(-)
Approvals:
jenkins-bot: Verified
L10n-bot: Looks good to me, approved
diff --git a/redirect/lb.json b/redirect/lb.json
index ec5f69e..ceaadd7 100644
--- a/redirect/lb.json
+++ b/redirect/lb.json
@@ -3,13 +3,14 @@
"authors": [
"Les Meloures",
"MarcoAurelio",
- "Robby"
+ "Robby",
+ "Volvox"
]
},
"redirect-broken-redirect-template": "{{Läschen|1=Defekt Viruleedung}}",
"redirect-fix-broken-moved": "Futtis Viruleedung op déi geréckelt Zilsäit %(to)s gouf gefléckt",
"redirect-fix-double": "Duebel Viruleedung gefléckt → %(to)s",
"redirect-fix-loop": "Verbesserung vun der Viruleedungsschleef op %(to)s",
- "redirect-remove-broken": "Viruleedung op eng geläscht Säit oder eng Säit déi et net gëtt",
+ "redirect-remove-broken": "Viruleedung op eng geläscht Säit oder eng Säit, déi et net gëtt",
"redirect-remove-loop": "Viruleedung där hiert Zil zu enger endlos Schleef féiert"
}
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/i18n/+/1137736?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/i18n
Gerrit-Branch: master
Gerrit-Change-Id: If01755473295480eddba02fc52f52140a195d3ee
Gerrit-Change-Number: 1137736
Gerrit-PatchSet: 1
Gerrit-Owner: L10n-bot <l10n-bot(a)translatewiki.net>
Gerrit-Reviewer: L10n-bot <l10n-bot(a)translatewiki.net>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1132163?usp=email )
Change subject: [IMPR] Improve cleanUpLinks/handleOneLink
......................................................................
[IMPR] Improve cleanUpLinks/handleOneLink
Combine the result string with f-string. The performance
increases by 3 % (only)
Bug: T390068
Change-Id: Ib430f1c5aace753f84de7836d8d43b4c60869b02
---
M pywikibot/cosmetic_changes.py
1 file changed, 18 insertions(+), 23 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index 4bf1fdc..463e346 100644
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -50,7 +50,7 @@
'your_script_name_2']
"""
#
-# (C) Pywikibot team, 2006-2024
+# (C) Pywikibot team, 2006-2025
#
# Distributed under the terms of the MIT license.
#
@@ -538,11 +538,11 @@
This function will:
* Replace underscores with spaces
- * Move leading and trailing spaces out of the wikilink and into the
- surrounding text
+ * Move leading and trailing spaces out of the wikilink and into
+ the surrounding text
* Convert URL-encoded characters into Unicode-encoded characters
- * Move trailing characters out of the link and make the link without
- using a pipe, if possible
+ * Move trailing characters out of the link and make the link
+ without using a pipe, if possible
* Capitalize the article title of the link, if appropriate
.. versionchanged:: 8.4
@@ -560,7 +560,7 @@
encodings=self.site.encodings())
label = match['label']
trailingChars = match['linktrail']
- newline = match['newline']
+ newline = match['newline'] or ''
# entire link but convert URL-encoded text
oldlink = url2string(match.group(),
encodings=self.site.encodings())
@@ -582,16 +582,15 @@
if not in_main_namespace:
return oldlink
- # Replace underlines by spaces, also multiple underlines
- titleWithSection = re.sub('_+', ' ', titleWithSection)
- # Remove double spaces
- titleWithSection = re.sub(' +', ' ', titleWithSection)
+ # Replace underlines by spaces, remove double spaces
+ titleWithSection = re.sub('[_ ]+', ' ', titleWithSection)
# Remove unnecessary leading spaces from title,
# but remember if we did this because we eventually want
# to re-add it outside of the link later.
titleLength = len(titleWithSection)
titleWithSection = titleWithSection.lstrip()
- hadLeadingSpaces = len(titleWithSection) != titleLength
+ hadLeadingSpaces = not newline \
+ and len(titleWithSection) != titleLength
hadTrailingSpaces = False
# Remove unnecessary trailing spaces from title,
# but remember if we did this because it may affect
@@ -609,13 +608,15 @@
# Remove unnecessary initial and final spaces from label.
# Please note that some editors prefer spaces around pipes.
# (See [[en:Wikipedia:Semi-bots]]). We remove them anyway.
- if label is not None:
+ if label is None:
+ label = titleWithSection
+ else:
# Remove unnecessary leading spaces from label,
# but remember if we did this because we want
# to re-add it outside of the link later.
labelLength = len(label)
label = label.lstrip()
- hadLeadingSpaces = len(label) != labelLength
+ hadLeadingSpaces = not newline and len(label) != labelLength
# Remove unnecessary trailing spaces from label,
# but remember if we did this because it affects
# the linktrail.
@@ -623,8 +624,7 @@
labelLength = len(label)
label = label.rstrip()
hadTrailingSpaces = len(label) != labelLength
- else:
- label = titleWithSection
+
if trailingChars:
label += trailingChars
@@ -643,7 +643,6 @@
and trailR.sub('', label[len(titleWithSection):]) == ''):
newLink = (f'[[{label[:len(titleWithSection)]}]]'
f'{label[len(titleWithSection):]}')
-
else:
# Try to capitalize the first letter of the title.
# Not useful for languages that don't capitalize nouns.
@@ -653,19 +652,15 @@
if self.site.sitename == 'wikipedia:de':
titleWithSection = first_upper(titleWithSection)
newLink = f'[[{titleWithSection}|{label}]]'
+
# re-add spaces that were pulled out of the link.
# Examples:
# text[[ title ]]text -> text [[title]] text
# text[[ title | name ]]text -> text [[title|name]] text
# text[[ title |name]]text -> text[[title|name]]text
# text[[title| name]]text -> text [[title|name]]text
- if hadLeadingSpaces and not newline:
- newLink = ' ' + newLink
- if hadTrailingSpaces:
- newLink += ' '
- if newline:
- newLink = newline + newLink
- return newLink
+ return f"{newline}{' ' if hadLeadingSpaces else ''}" \
+ f"{newLink}{' ' if hadTrailingSpaces else ''}"
trailR = re.compile(self.site.linktrail())
# The regular expression which finds links. Results consist of four groups:
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1132163?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ib430f1c5aace753f84de7836d8d43b4c60869b02
Gerrit-Change-Number: 1132163
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot