jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/578302 )
Change subject: [IMPR] Simplify bot.calledModuleName method using pathlib
......................................................................
[IMPR] Simplify bot.calledModuleName method using pathlib
Change-Id: I86245c6e60f4302a235e3bd80ba3f2b757b45307
---
M pywikibot/bot.py
1 file changed, 6 insertions(+), 6 deletions(-)
Approvals:
Dvorapa: Looks good to me, but someone else must approve
D3r1ck01: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index afafcc5..402eb32 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -103,6 +103,11 @@
except ImportError: # PY2
import ConfigParser as configparser # noqa: N813
+try:
+ from pathlib import Path
+except ImportError: # PY2
+ from pathlib2 import Path
+
from textwrap import fill
import pywikibot
@@ -878,12 +883,7 @@
@rtype: str
"""
- # get commandline arguments
- called = pywikibot.argvu[0].strip()
- if '.py' in called: # could end with .pyc, .pyw, etc. on some platforms
- # clip off the '.py?' filename extension
- called = called[:called.rindex('.py')]
- return os.path.basename(called)
+ return Path(pywikibot.argvu[0]).stem
def handle_args(args=None, do_help=True):
--
To view, visit
https://gerrit.wikimedia.org/r/578302
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I86245c6e60f4302a235e3bd80ba3f2b757b45307
Gerrit-Change-Number: 578302
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: jenkins-bot (75)