jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1179258?usp=email )
Change subject: [fixes] Improve parameter_help formatting and _load_file
readability
......................................................................
[fixes] Improve parameter_help formatting and _load_file readability
- parameter_help: improve wording for CLI help output
- _load_file: use pathlib for modern path handling and clarify docstring
Change-Id: I2ecc278de04339961ecc6a8f851f45be1e6d1ba7
---
M pywikibot/fixes.py
1 file changed, 30 insertions(+), 24 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/fixes.py b/pywikibot/fixes.py
index db65059..684850c 100644
--- a/pywikibot/fixes.py
+++ b/pywikibot/fixes.py
@@ -1,18 +1,18 @@
"""File containing all standard fixes."""
#
-# (C) Pywikibot team, 2008-2022
+# (C) Pywikibot team, 2008-2025
#
# Distributed under the terms of the MIT license.
#
from __future__ import annotations
-import os.path
+from pathlib import Path
from pywikibot import config
parameter_help = """
- Currently available predefined fixes are:
+ Currently available predefined fixes:
* HTML - Convert HTML tags to wiki syntax, and
fix XHTML.
@@ -20,21 +20,20 @@
* syntax - Try to fix bad wiki markup. Do not run
this in automatic mode, as the bot may
make mistakes.
- * syntax-safe - Like syntax, but less risky, so you can
- run this in automatic mode.
- * case-de - fix upper/lower case errors in German
- * grammar-de - fix grammar and typography in German
- * vonbis - Ersetze Binde-/Gedankenstrich durch "bis"
- in German
- * music - Links auf Begriffsklärungen in German
- * datum - specific date formats in German
- * correct-ar - Typo corrections for Arabic Wikipedia and any
- Arabic wiki.
- * yu-tld - Fix links to .yu domains because it is
- disabled, see:
+ * syntax-safe - Like syntax, but less risky; can be run
+ in automatic mode.
+ * case-de - Fix upper/lower case errors in German.
+ * grammar-de - Fix grammar and typography in German.
+ * vonbis - Replace hyphens or dashes with "bis"
+ in German.
+ * music - Links to disambiguation pages in German.
+ * datum - Specific date formats in German.
+ * correct-ar - Typo corrections for Arabic Wikipedia
+ and other Arabic wikis.
+ * yu-tld - Fix links to .yu domains, which are disabled.
+ See:
https://lists.wikimedia.org/pipermail/wikibots-l/2009-February/000290.html
- * fckeditor - Try to convert FCKeditor HTML tags to wiki
- syntax.
+ * fckeditor - Convert FCKeditor HTML tags to wiki syntax.
"""
__doc__ += parameter_help
@@ -673,20 +672,27 @@
'msg': 'pywikibot-fixes-fckeditor',
'replacements': [
# replace <br> with a new line
- (r'(?i)<br>', r'\n'),
+ (r'(?i)<br>', r'\n'),
# replace with a space
- (r'(?i) ', r' '),
+ (r'(?i) ', r' '),
],
},
}
def _load_file(filename: str) -> bool:
- """Load the fixes from the given filename."""
- if os.path.exists(filename):
- # load binary, to let compile decode it according to the file header
- with open(filename, 'rb') as f:
- exec(compile(f.read(), filename, 'exec'), globals())
+ """Load the fixes from the given filename.
+
+ Returns True if the file existed and was loaded, False otherwise.
+
+ :meta public:
+ """
+ path = Path(filename)
+ if path.exists():
+ # Read file as binary, so that compile can detect encoding from header
+ with path.open('rb') as f:
+ code = compile(f.read(), filename, 'exec')
+ exec(code, globals()) # intentionally in globals
return True
return False
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1179258?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: I2ecc278de04339961ecc6a8f851f45be1e6d1ba7
Gerrit-Change-Number: 1179258
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]