jenkins-bot has submitted this change and it was merged.
Change subject: pep8-ified config2.py
......................................................................
pep8-ified config2.py
Note: test for variables was adapted slightly to prevent
E721 / do not compare types, use ‘isinstance()’ from triggering.
Instead of comparing the old type with type(None), the old *value*
is compared to None instead. This is also a nicer check conceptually.
Change-Id: Ibdfc17e86814a905e212bd454deba36c7995df4f
---
M pywikibot/config2.py
1 file changed, 21 insertions(+), 14 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index d6ad0bd..8fec8c0 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -7,8 +7,9 @@
#
__version__ = '$Id$'
-import os, re
+import os
import sys as __sys
+import re
import platform
# IMPORTANT:
@@ -72,8 +73,8 @@
#
# Security Connection for Wikimedia Projects
#
-use_SSL_onlogin = False # if available, use SSL when logging in
-use_SSL_always = False # if available, use SSL for all API queries
+use_SSL_onlogin = False # if available, use SSL when logging in
+use_SSL_always = False # if available, use SSL for all API queries
# Available security projects
available_ssl_project = [
@@ -92,6 +93,7 @@
# WARNING: this should NEVER be used in practice, ALWAYS supply a more
# relevant summary for bot edits
default_edit_summary = u'Wikipedia python library v.2'
+
# Get the names of all known families, and initialize
# with empty dictionaries
@@ -127,7 +129,7 @@
elif _win_version == 6:
base_dir = os.path.join(home, "AppData\\Roaming", NAME)
else:
- base_dir = os.path.join(home, "."+NAME)
+ base_dir = os.path.join(home, "." + NAME)
if not os.path.isdir(base_dir):
os.makedirs(base_dir, mode=0700)
if not os.path.isabs(base_dir):
@@ -144,9 +146,9 @@
_base_dir = _get_base_dir()
# families/ is a subdirectory of the directory in which config.py is found
for _filename in os.listdir(
- os.path.join(os.path.dirname(__file__), 'families')):
+ os.path.join(os.path.dirname(__file__), 'families')):
if _filename.endswith("_family.py"):
- familyName = _filename[ : -len("_family.py")]
+ familyName = _filename[:-len("_family.py")]
usernames[familyName] = {}
sysopnames[familyName] = {}
disambiguation_comment[familyName] = {}
@@ -180,8 +182,8 @@
# transliteration_target = console_encoding
# After emitting the warning, this last option will be set.
-transliteration_target = 'not set'
-
+transliteration_target = 'not set'
+
# The encoding in which textfiles are stored, which contain lists of page
# titles. The most used is: 'utf-8'. 'utf-8-sig' recognizes BOM but it is
# available on Python 2.5 or higher. For a complete list please see:
@@ -591,6 +593,7 @@
# End of configuration section
# ============================
+
def makepath(path):
"""Return a normalized absolute version of the path argument.
@@ -610,6 +613,7 @@
os.makedirs(dpath)
return os.path.normpath(os.path.abspath(path))
+
def datafilepath(*filename):
"""Return an absolute path to a data file in a standard location.
@@ -621,11 +625,12 @@
import os.path
return makepath(os.path.join(base_dir, *filename))
+
def shortpath(path):
"""Return a file path relative to config.base_dir."""
import os.path
if path.startswith(base_dir):
- return path[len(base_dir) + len(os.path.sep) : ]
+ return path[len(base_dir) + len(os.path.sep):]
return path
# System-level and User-level changes.
# Store current variables and their types.
@@ -651,10 +656,10 @@
execfile(_filename)
else:
print "WARNING: Skipped '%(fn)s': writeable by others."\
- % {'fn' :_filename}
+ % {'fn': _filename}
else:
print "WARNING: Skipped '%(fn)s': owned by someone else."\
- % {'fn' :_filename}
+ % {'fn': _filename}
# Test for obsoleted and/or unknown variables.
for _key, _val in globals().items():
@@ -663,7 +668,9 @@
elif _key in _gl:
nt = type(_val)
ot = _tp[_key]
- if nt == ot or _val is None or ot == type(None):
+ ov = _glv[_key]
+
+ if nt == ot or _val is None or ov is None: # nopep8
pass
elif nt is int and (ot is float or ot is bool):
pass
@@ -695,8 +702,8 @@
else:
transliteration_target = None
elif transliteration_target in ('None', 'none'):
- transliteration_target = None
-
+ transliteration_target = None
+
# Save base_dir for use by other modules
base_dir = _base_dir
--
To view, visit https://gerrit.wikimedia.org/r/79587
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibdfc17e86814a905e212bd454deba36c7995df4f
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Fixup for r77341: 'globals' should be 'global'
......................................................................
Fixup for r77341: 'globals' should be 'global'
Change-Id: Id16d18958c735e594605467d63ff716e38d6c039
---
M externals/__init__.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/externals/__init__.py b/externals/__init__.py
index c58c375..e7db1c4 100644
--- a/externals/__init__.py
+++ b/externals/__init__.py
@@ -210,7 +210,7 @@
return v == 'Y' or v == 'YES'
def show_patch_question():
- globals _patch_permission
+ global _patch_permission
if _patch_permission is None:
lowlevel_warning("Give externals permission to execute the patch command?"
" (y/N)")
--
To view, visit https://gerrit.wikimedia.org/r/79564
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id16d18958c735e594605467d63ff716e38d6c039
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Add an ItemPage.iterlinks function to yield sitelinks
......................................................................
Add an ItemPage.iterlinks function to yield sitelinks
Change-Id: I43ab820a5d97a22619dc5753d98bdd4ceec277f7
---
M pywikibot/page.py
1 file changed, 17 insertions(+), 0 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 72540eb..81daf92 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -2540,6 +2540,23 @@
'claims': self.claims
}
+ def iterlinks(self, family=None):
+ """
+ Iterates through all the sitelinks
+ @param family: string/Family object which represents what family of
+ links to iterate
+ @type family: str|pywikibot.family.Family
+ @return: iterator of pywikibot.Page objects
+ """
+ if not hasattr(self, 'sitelinks'):
+ self.get()
+ if not isinstance(family, pywikibot.family.Family):
+ family = pywikibot.site.Family(family)
+ for dbname in self.sitelinks:
+ pg = Page(pywikibot.site.APISite.fromDBName(dbname), self.sitelinks[dbname])
+ if not family or family == pg.site.family:
+ yield pg
+
def getSitelink(self, site, force=False):
"""
Returns the title (unicode string) for the specific site
--
To view, visit https://gerrit.wikimedia.org/r/79554
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I43ab820a5d97a22619dc5753d98bdd4ceec277f7
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: ask for permission to run patch command warning that several scripts might fail, if modules are not installed as needed
......................................................................
ask for permission to run patch command
warning that several scripts might fail, if modules are not installed as needed
Change-Id: Ieaea7b24bee1f569577a1c9ce9dfc9c6f84f4ef4
---
M externals/__init__.py
1 file changed, 18 insertions(+), 1 deletion(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/externals/__init__.py b/externals/__init__.py
index 83045f5..c58c375 100644
--- a/externals/__init__.py
+++ b/externals/__init__.py
@@ -162,6 +162,8 @@
'pydmtx', 'py_w3c', '_zbar', ]
# OPEN: 'opencv', 'slic', '_bob', 'xbob_flandmark',
+_patch_permission = None
+
import os
import sys
@@ -206,6 +208,15 @@
" (y/N)")
v = raw_input().upper()
return v == 'Y' or v == 'YES'
+
+def show_patch_question():
+ globals _patch_permission
+ if _patch_permission is None:
+ lowlevel_warning("Give externals permission to execute the patch command?"
+ " (y/N)")
+ v = raw_input().upper()
+ _patch_permission = (v == 'Y') or (v == 'YES')
+ return _patch_permission
def python_module_exists(module_name):
@@ -335,7 +346,7 @@
shutil.rmtree(os.path.join(path, '__setup_tmp/'))
result = 0
- if 'patch' in package:
+ if ('patch' in package) and show_patch_question():
lowlevel_warning(u'Install package "%s" by applying patch to %s.'
% (module, os.path.join(path, module)))
if sys.platform == 'win32':
@@ -389,6 +400,12 @@
return
lowlevel_warning(u'Package "%s" could not be found nor installed!' % m)
+ lowlevel_warning(u'Several scripts might fail, if some modules are not'
+ u' installed as needed! You can either install them'
+ u' by yourself to the system or extract them into the'
+ u' externals/ directory. If you chose to not install them'
+ u' this script will ask you again next time whether you'
+ u' whish to install the external code.')
def check_setup_all():
--
To view, visit https://gerrit.wikimedia.org/r/77341
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ieaea7b24bee1f569577a1c9ce9dfc9c6f84f4ef4
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: DrTrigon <dr.trigon(a)surfeu.ch>
Gerrit-Reviewer: DrTrigon <dr.trigon(a)surfeu.ch>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot