jenkins-bot has submitted this change and it was merged.
Change subject: Return the current directory if user-config.py exists in it
......................................................................
Return the current directory if user-config.py exists in it
It gives current directory overriding power over .pywikibot directory
Change-Id: I58169765676abd314be70de4d0aa522d1bf21358
---
M pywikibot/config2.py
1 file changed, 13 insertions(+), 4 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index c79dd80..2d3ce38 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# (C) Rob W.W. Hooft, 2003
-# (C) Pywikibot team, 2003-2013
+# (C) Pywikibot team, 2003-2014
#
# Distributed under the terms of the MIT license.
#
@@ -114,22 +114,29 @@
provided in this argument
2. If the user has a PYWIKIBOT2_DIR environment variable, use the value
of it
- 3. Use (and if necessary create) a 'pywikibot' folder under
+ 3. If user-config presents in current directory, use the current directory
+ 4. Use (and if necessary create) a 'pywikibot' folder under
'Application Data' or 'AppData\Roaming' (Windows) or
'.pywikibot' directory (Unix and similar) under the user's home
directory.
"""
NAME = "pywikibot"
+ base_dir = ""
for arg in sys.argv[1:]:
if arg.startswith("-dir:"):
base_dir = arg[5:]
sys.argv.remove(arg)
break
+ current_exists = os.path.exists(
+ os.path.join(os.path.abspath("."), "user-config.py"))
+ if current_exists and "PYWIKIBOT2_DIR" not in os.environ and not base_dir:
+ base_dir = os.path.abspath(".")
+ return base_dir
else:
if "PYWIKIBOT2_DIR" in os.environ:
base_dir = os.environ["PYWIKIBOT2_DIR"]
- else:
+ elif not base_dir:
is_windows = sys.platform == 'win32'
home = os.path.expanduser("~")
if is_windows:
@@ -164,7 +171,9 @@
# Save base_dir for use by other modules
base_dir = _base_dir
-
+for arg in sys.argv[1:]:
+ if arg.startswith("-verbose") or arg == "-v":
+ print "The base directory is %s" % base_dir
family_files = {}
--
To view, visit
https://gerrit.wikimedia.org/r/146692
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I58169765676abd314be70de4d0aa522d1bf21358
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>