jenkins-bot has submitted this change and it was merged.
Change subject: [IMPR] Replace deprecated site.language() method with site.lang property
......................................................................
[IMPR] Replace deprecated site.language() method with site.lang property
Change-Id: I5cd27cbe175d4365c689158a92fcd083c9061900
---
M scripts/imagecopy.py
M scripts/imagecopy_self.py
2 files changed, 21 insertions(+), 22 deletions(-)
Approvals:
Xqt: Looks good to me, approved
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/imagecopy.py b/scripts/imagecopy.py
index 6882ebb..ce82757 100644
--- a/scripts/imagecopy.py
+++ b/scripts/imagecopy.py
@@ -77,7 +77,7 @@
#
# Another rewrite by:
# (C) Multichill 2008-2011
-# (C) Pywikibot team, 2007-2015
+# (C) Pywikibot team, 2007-2016
#
# Distributed under the terms of the MIT license.
#
@@ -256,7 +256,7 @@
def run(self):
"""Run the bot."""
- tosend = {'language': self.imagePage.site.language().encode('utf-8'),
+ tosend = {'language': self.imagePage.site.lang.encode('utf-8'),
'image': self.imagePage.title(
withNamespace=False).encode('utf-8'),
'newname': self.newname.encode('utf-8'),
@@ -282,7 +282,7 @@
# I want every picture to be tagged with the bottemplate so i can check
# my contributions later.
- CH = ('\n\n{{BotMoveToCommons|' + self.imagePage.site.language() +
+ CH = ('\n\n{{BotMoveToCommons|' + self.imagePage.site.lang +
'.' + self.imagePage.site.family.name +
'|year={{subst:CURRENTYEAR}}|month={{subst:CURRENTMONTHNAME}}'
'|day={{subst:CURRENTDAY}}}}' + CH)
@@ -307,16 +307,16 @@
imtxt = self.imagePage.get(force=True)
# Remove the move to commons templates
- if self.imagePage.site.language() in moveToCommonsTemplate:
+ if self.imagePage.site.lang in moveToCommonsTemplate:
for moveTemplate in moveToCommonsTemplate[
- self.imagePage.site.language()]:
+ self.imagePage.site.lang]:
imtxt = re.sub(u'(?i)\{\{' + moveTemplate + u'[^\}]*\}\}',
u'', imtxt)
# add {{NowCommons}}
- if self.imagePage.site.language() in nowCommonsTemplate:
+ if self.imagePage.site.lang in nowCommonsTemplate:
addTemplate = nowCommonsTemplate[
- self.imagePage.site.language()] % self.newname
+ self.imagePage.site.lang] % self.newname
else:
addTemplate = nowCommonsTemplate['_default'] % self.newname
diff --git a/scripts/imagecopy_self.py b/scripts/imagecopy_self.py
index 362b02a..93599b9 100644
--- a/scripts/imagecopy_self.py
+++ b/scripts/imagecopy_self.py
@@ -45,7 +45,7 @@
# English Wikipedia specific bot by:
# (C) Multichill 2010-2012
#
-# (C) Pywikibot team, 2010-2015
+# (C) Pywikibot team, 2010-2016
#
# Distributed under the terms of the MIT license.
#
@@ -357,7 +357,7 @@
text = imagepage.get()
foundMatch = False
- for (regex, replacement) in licenseTemplates[page.site.language()]:
+ for (regex, replacement) in licenseTemplates[page.site.lang]:
match = re.search(regex, text, flags=re.IGNORECASE)
if match:
foundMatch = True
@@ -375,7 +375,7 @@
"""
for template in imagepage.templates():
- if template in skipTemplates[imagepage.site.language()]:
+ if template in skipTemplates[imagepage.site.lang]:
pywikibot.output(
u'Found %s which is on the template skip list' % template)
return True
@@ -422,8 +422,7 @@
other_versions = u''
contents = {}
- for key, value in informationFields.get(
- imagepage.site.language()).items():
+ for key, value in informationFields.get(imagepage.site.lang).items():
contents[value] = u''
templates = imagepage.templatesWithParams()
@@ -437,10 +436,10 @@
field = field.lower().replace(u'_', u' ').strip()
# See if first part is in fields list
if field in informationFields.get(
- imagepage.site.language()).keys():
+ imagepage.site.lang).keys():
# Ok, field is good, store it.
contents[informationFields.get(
- imagepage.site.language()).get(field)] = value.strip()
+ imagepage.site.lang).get(field)] = value.strip()
# We now got the contents from the old information template.
# Let's get the info for the new one
@@ -480,7 +479,7 @@
# Still have to filter out crap like "see below" or "yes"
if contents[u'permission']:
# Strip of the license temlate if it's in the permission section
- for (regex, repl) in licenseTemplates[imagepage.site.language()]:
+ for (regex, repl) in licenseTemplates[imagepage.site.lang]:
contents[u'permission'] = re.sub(regex, u'',
contents[u'permission'],
flags=re.IGNORECASE)
@@ -501,10 +500,10 @@
# text = re.sub(u'== Licensing ==', u'', text, re.IGNORECASE)
# text = re.sub('\{\{(self|self2)\|[^\}]+\}\}', '', text, re.IGNORECASE)
- for toRemove in sourceGarbage[imagepage.site.language()]:
+ for toRemove in sourceGarbage[imagepage.site.lang]:
text = re.sub(toRemove, u'', text, flags=re.IGNORECASE)
- for (regex, repl) in licenseTemplates[imagepage.site.language()]:
+ for (regex, repl) in licenseTemplates[imagepage.site.lang]:
text = re.sub(regex, u'', text, flags=re.IGNORECASE)
text = pywikibot.removeCategoryLinks(text, imagepage.site()).strip()
@@ -577,7 +576,7 @@
family = site.family.name
result = u''
for (regex,
- replacement) in licenseTemplates[imagepage.site.language()]:
+ replacement) in licenseTemplates[imagepage.site.lang]:
match = re.search(regex, text, flags=re.IGNORECASE)
if match:
result = re.sub(regex, replacement, match.group(0),
@@ -967,16 +966,16 @@
imtxt = imagepage.get(force=True)
# Remove the move to commons templates
- if imagepage.site.language() in moveToCommonsTemplate:
+ if imagepage.site.lang in moveToCommonsTemplate:
for moveTemplate in moveToCommonsTemplate[
- imagepage.site.language()]:
+ imagepage.site.lang]:
imtxt = re.sub(u'(?i)\{\{' + moveTemplate +
u'[^\}]*\}\}', u'', imtxt)
# add {{NowCommons}}
- if imagepage.site.language() in nowCommonsTemplate:
+ if imagepage.site.lang in nowCommonsTemplate:
addTemplate = nowCommonsTemplate[
- imagepage.site.language()] % filename
+ imagepage.site.lang] % filename
else:
addTemplate = nowCommonsTemplate['_default'] % filename
--
To view, visit https://gerrit.wikimedia.org/r/292786
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5cd27cbe175d4365c689158a92fcd083c9061900
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Make password_file respect -dir flag
......................................................................
Make password_file respect -dir flag
password_file paths are now assumed to be relative to the user_config.py
in which it is specified.
For backwards compatibility it looks in the old place if no file is
found in the new one.
Bug: T139749
Change-Id: I777f352be698a4f9bd0e89facc5febd8ce92a0f7
---
M pywikibot/config2.py
M pywikibot/login.py
2 files changed, 11 insertions(+), 4 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index a1aa14f..54cfeee 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -208,7 +208,8 @@
available_ssl_project = []
# By default you are asked for a password on the terminal.
-# A password file may be used. e.g. password_file = ".passwd"
+# A password file may be used, e.g. password_file = ".passwd".
+# The path to the password file is relative to that of the user_config file.
# The password file should consist of lines containing
# Python tuples of any of the following formats:
# (code, family, username, password)
diff --git a/pywikibot/login.py b/pywikibot/login.py
index 20f38f7..d07ffc6 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -216,14 +216,20 @@
(u"wikipedia", u"my_wikipedia_user", u"my_wikipedia_pass")
(u"en", u"wikipedia", u"my_en_wikipedia_user", u"my_en_wikipedia_pass")
"""
+ # Set path to password file relative to the user_config
+ # but fall back on absolute path for backwards compatibility
+ password_file = os.path.join(config.base_dir, config.password_file)
+ if not os.path.isfile(password_file):
+ password_file = config.password_file
+
# We fix password file permission first,
# lift upper permission (regular file) from st_mode
# to compare it with private_files_permission.
- if os.stat(config.password_file).st_mode - stat.S_IFREG \
+ if os.stat(password_file).st_mode - stat.S_IFREG \
!= config.private_files_permission:
- os.chmod(config.password_file, config.private_files_permission)
+ os.chmod(password_file, config.private_files_permission)
- password_f = codecs.open(config.password_file, encoding='utf-8')
+ password_f = codecs.open(password_file, encoding='utf-8')
for line_nr, line in enumerate(password_f):
if not line.strip():
continue
--
To view, visit https://gerrit.wikimedia.org/r/305665
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I777f352be698a4f9bd0e89facc5febd8ce92a0f7
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Lokal Profil <lokal.profil(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Lokal Profil <lokal.profil(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [tox] flake8-coding 1.3 does not work with flake8 < 3
......................................................................
[tox] flake8-coding 1.3 does not work with flake8 < 3
- flake8-coding<1.3.0 is required for flake<3
see: https://integration.wikimedia.org/ci/job/tox/115/console
Bug: T143478
Change-Id: I17df5d6cf7e64c0f2409ef7af1b8e6933a551187
---
M tox.ini
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Lokal Profil: Looks good to me, approved
Xqt: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/tox.ini b/tox.ini
index 83ce047..3a5762d 100644
--- a/tox.ini
+++ b/tox.ini
@@ -55,7 +55,7 @@
hacking
flake8-docstrings>=0.2.6
flake8-putty>=0.3.2
- flake8-coding
+ flake8-coding<1.3.0
flake8-comprehensions
flake8-future-import
flake8-string-format
--
To view, visit https://gerrit.wikimedia.org/r/305779
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I17df5d6cf7e64c0f2409ef7af1b8e6933a551187
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Lokal Profil <lokal.profil(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPR] Add pageid property to Page object
......................................................................
[IMPR] Add pageid property to Page object
- pageid is sometimes needed e.g. for external web tools.
This patch implements a property method to get it without other page
related actions like Page.get().
- site.page_exists may just call page.pageid because that property method
calls loadpageinfo.
- use pageid instead of the internal _pageid in redirect.py
- add test for equality
Change-Id: If1bb4c4737015eb6044e9c524a61429a8ffce621
---
M pywikibot/page.py
M pywikibot/site.py
M scripts/redirect.py
M tests/site_tests.py
4 files changed, 16 insertions(+), 4 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 5c5f2e0..f0fd05e 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -242,6 +242,18 @@
return _depth
+ @property
+ def pageid(self):
+ """
+ Return pageid of the page.
+
+ @return: pageid or 0 if page does not exist
+ @rtype: int
+ """
+ if not hasattr(self, '_pageid'):
+ self.site.loadpageinfo(self)
+ return self._pageid
+
@deprecated_args(decode=None, savetitle="asUrl")
def title(self, underscore=False, withNamespace=True,
withSection=True, asUrl=False, asLink=False,
diff --git a/pywikibot/site.py b/pywikibot/site.py
index f8c6996..531b9b8 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -2965,9 +2965,7 @@
def page_exists(self, page):
"""Return True if and only if page is an existing page on site."""
- if not hasattr(page, "_pageid"):
- self.loadpageinfo(page)
- return page._pageid > 0
+ return page.pageid > 0
def page_restrictions(self, page):
"""Return a dictionary reflecting page protections."""
diff --git a/scripts/redirect.py b/scripts/redirect.py
index 4bc9c60..abe9b34 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -202,7 +202,7 @@
"""Generator that yields batches of 500 redirects as a list."""
apiQ = []
for page in self.get_redirect_pages_via_api():
- apiQ.append(str(page._pageid))
+ apiQ.append(str(page.pageid))
if len(apiQ) >= 500:
yield apiQ
apiQ = []
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 89bc75e..e56d9b2 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -2494,6 +2494,8 @@
# remove the pageids that have already been loaded above by pagelinks
# so that preloadpages will use the titles instead
for page in links:
+ if hasattr(page, '_pageid'):
+ self.assertEqual(page.pageid, page._pageid)
del page._pageid
for page in mysite.preloadpages(links):
--
To view, visit https://gerrit.wikimedia.org/r/297257
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If1bb4c4737015eb6044e9c524a61429a8ffce621
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>