jenkins-bot merged this change.
[IMPR] Simplify bot.calledModuleName method using pathlib
Change-Id: I86245c6e60f4302a235e3bd80ba3f2b757b45307
---
M pywikibot/bot.py
1 file changed, 6 insertions(+), 6 deletions(-)
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 change 578302. To unsubscribe, or for help writing mail filters, visit settings.