jenkins-bot has submitted this change and it was merged.
Change subject: Allow pywikibot to load without a user-config.py
......................................................................
Allow pywikibot to load without a user-config.py
Set environment variable PYWIKIBOT2_NO_USER_CONFIG=1
to allow the library to load without a user-config.py
Emits a warning to help triage problems with this
functionality.
Change-Id: I8f77f7634989bef75701ed5cf952844e339c1243
---
M pywikibot/config2.py
1 file changed, 14 insertions(+), 6 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 6103f23..b967973 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -137,6 +137,8 @@
'.pywikibot' directory (Unix and similar) under the user's home
directory.
+ Set PYWIKIBOT2_NO_USER_CONFIG=1 to disable loading user-config.py
+
"""
NAME = "pywikibot"
base_dir = ""
@@ -176,11 +178,13 @@
if not os.path.exists(os.path.join(base_dir, "user-config.py")):
exc_text = ("No user-config.py found in directory '%(base_dir)s'.\n"
% locals())
- exc_text += " Please check that user-config.py is stored in the
correct location.\n"
- exc_text += " Directory where user-config.py is searched is
determined as follows:\n\n"
- exc_text += " " + _get_base_dir.__doc__
-
- raise RuntimeError(exc_text)
+ if os.environ.get('PYWIKIBOT2_NO_USER_CONFIG', '0') == '1':
+ print(exc_text)
+ else:
+ exc_text += " Please check that user-config.py is stored in the
correct location.\n"
+ exc_text += " Directory where user-config.py is searched is
determined as follows:\n\n"
+ exc_text += " " + _get_base_dir.__doc__
+ raise RuntimeError(exc_text)
return base_dir
@@ -704,7 +708,11 @@
# Get the user files
_thislevel = 0
-_fns = [os.path.join(_base_dir, "user-config.py")]
+if os.environ.get('PYWIKIBOT2_NO_USER_CONFIG', '0') == '1':
+ print("WARNING: Skipping loading of user-config.py.")
+ _fns = []
+else:
+ _fns = [os.path.join(_base_dir, "user-config.py")]
for _filename in _fns:
_thislevel += 1
if os.path.exists(_filename):
--
To view, visit https://gerrit.wikimedia.org/r/151658
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8f77f7634989bef75701ed5cf952844e339c1243
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits