jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/673555 )
Change subject: [IMPR] use sys.exit() instead of exit() ......................................................................
[IMPR] use sys.exit() instead of exit()
Change-Id: I4a6611ead6d361cd407567afeb022d6bf471af14 --- M scripts/archive/compat2core.py M scripts/harvest_template.py M scripts/maintenance/cache.py 3 files changed, 9 insertions(+), 10 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/archive/compat2core.py b/scripts/archive/compat2core.py index 8fde419..f9ee6bc 100755 --- a/scripts/archive/compat2core.py +++ b/scripts/archive/compat2core.py @@ -25,13 +25,14 @@ python pwb.py compat2core <scriptname> -warnonly """ # -# (C) Pywikibot team, 2014-2020 +# (C) Pywikibot team, 2014-2021 # # Distributed under the terms of the MIT license. # import codecs import os import re +import sys
import pywikibot
@@ -155,7 +156,7 @@ 'Please input the .py file to convert ' '(no input to leave):') if not self.source: - exit() + sys.exit() if not self.source.endswith('.py'): self.source += '.py' if os.path.exists(self.source): @@ -174,7 +175,7 @@ 'Destination file is {}.'.format(self.dest), default=True, automatic_quit=False): pywikibot.output('Quitting...') - exit() + sys.exit()
def convert(self): """Convert script.""" diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py index 85665c7..81f83de 100755 --- a/scripts/harvest_template.py +++ b/scripts/harvest_template.py @@ -92,6 +92,7 @@ # Distributed under the terms of MIT License. # import signal +import sys
from typing import Any, Optional
@@ -182,9 +183,7 @@ """Fetch redirects of the title, so we can check against them.""" temp = pywikibot.Page(pywikibot.Site(), title, ns=10) if not temp.exists(): - pywikibot.error('Template {} does not exist.' - .format(temp.title())) - exit() + sys.exit('Template {} does not exist.'.format(temp.title()))
# Put some output here since it can take a while pywikibot.output('Finding redirects...') diff --git a/scripts/maintenance/cache.py b/scripts/maintenance/cache.py index 6a8b1b2..f7f4212 100755 --- a/scripts/maintenance/cache.py +++ b/scripts/maintenance/cache.py @@ -72,6 +72,7 @@ import hashlib import os import pickle +import sys
import pywikibot
@@ -418,13 +419,11 @@ command = 'has_password(entry)' elif arg == '-c': if command: - pywikibot.error('Only one command may be executed.') - exit(1) + sys.exit('Only one command may be executed.') command = '' elif arg == '-o': if output: - pywikibot.error('Only one output may be defined.') - exit(1) + sys.exit('Only one output may be defined.') output = '' else: if not cache_paths:
pywikibot-commits@lists.wikimedia.org