jenkins-bot has submitted this change and it was merged.
Change subject: [FEAT] replace: Inform about missing user-fixes.py ......................................................................
[FEAT] replace: Inform about missing user-fixes.py
When the user-fixes.py file is missing, it now shows such a message in replace.py when an unknown fix was selected.
Change-Id: I6d271b363f62a9f0398917d5ab7016df1ac044a6 --- M pywikibot/fixes.py M scripts/replace.py 2 files changed, 10 insertions(+), 4 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/fixes.py b/pywikibot/fixes.py index 3fe8e1b..1eb1d91 100644 --- a/pywikibot/fixes.py +++ b/pywikibot/fixes.py @@ -7,6 +7,8 @@ # from __future__ import unicode_literals
+import os.path + from pywikibot import config
__version__ = '$Id$' @@ -629,10 +631,11 @@
# # Load the user fixes file. -try: - filename = config.datafilepath('user-fixes.py') +filename = config.datafilepath('user-fixes.py') +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')) -except IOError: - pass + user_fixes_loaded = True +else: + user_fixes_loaded = False diff --git a/scripts/replace.py b/scripts/replace.py index 19a7855..47cd2ac 100755 --- a/scripts/replace.py +++ b/scripts/replace.py @@ -861,6 +861,9 @@ except KeyError: pywikibot.output(u'Available predefined fixes are: %s' % ', '.join(fixes.fixes.keys())) + if not fixes.user_fixes_loaded: + pywikibot.output('The user fixes file could not be found: ' + '{0}'.format(fixes.filename)) return if "msg" in fix: if isinstance(fix['msg'], basestring):
pywikibot-commits@lists.wikimedia.org