Xqt has submitted this change and it was merged.
Change subject: Populate the revision dict if lastrev is not in it.
......................................................................
Populate the revision dict if lastrev is not in it.
This allows avoinding a KeyError when the timestamp is extracted.
Bug: 54995
Change-Id: I1f97dac718dc6b645b1b35af4a894b84e14e6385
---
M pywikibot/site.py
1 file changed, 2 insertions(+), 0 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
jenkins-bot: Checked
diff --git a/pywikibot/site.py b/pywikibot/site.py
index f14132c..fff2fe0 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -2691,6 +2691,8 @@
if bot:
params["bot"] = ""
if lastrev is not None:
+ if lastrev not in page._revisions:
+ self.loadrevisions(page)
params["basetimestamp"] = page._revisions[lastrev].timestamp
if minor:
params['minor'] = ""
--
To view, visit https://gerrit.wikimedia.org/r/87915
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1f97dac718dc6b645b1b35af4a894b84e14e6385
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Legoktm has submitted this change and it was merged.
Change subject: Also run automated tests on python 2.6
......................................................................
Also run automated tests on python 2.6
Change-Id: I30ba78f380fea19672f7b4a8882f06fee6164f22
---
M .travis.yml
1 file changed, 1 insertion(+), 0 deletions(-)
Approvals:
Legoktm: Verified; Looks good to me, approved
Addshore: Looks good to me, but someone else must approve
diff --git a/.travis.yml b/.travis.yml
index bae4070..857344d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,7 @@
language: python
python:
+ - '2.6'
- '2.7'
install:
--
To view, visit https://gerrit.wikimedia.org/r/87238
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I30ba78f380fea19672f7b4a8882f06fee6164f22
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Addshore <addshorewiki(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Aligned doc string with implementation
......................................................................
Aligned doc string with implementation
Change-Id: Icdf09fadbf2d89c41119f5220bb461176f33eeb1
---
M generate_user_files.py
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/generate_user_files.py b/generate_user_files.py
index 94ea4ec..914222a 100644
--- a/generate_user_files.py
+++ b/generate_user_files.py
@@ -25,7 +25,8 @@
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 (Windows) or
+ 3. 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.
--
To view, visit https://gerrit.wikimedia.org/r/87911
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icdf09fadbf2d89c41119f5220bb461176f33eeb1
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
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: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: add Qualifier write support
......................................................................
add Qualifier write support
qualifier read/write is enabled by
- editQualifier() api method in site.py
- addQualifier() front end method in page.py
Test edits:
https://www.wikidata.org/w/index.php?title=Q10834790&diff=67432217&oldid=67…https://www.wikidata.org/w/index.php?title=Q10772647&diff=67447518&oldid=67…
Change-Id: I917a69fff552be8b29a5d186d6b9f8df6eeea61d
---
M pywikibot/page.py
M pywikibot/site.py
2 files changed, 52 insertions(+), 7 deletions(-)
Approvals:
FelixReimann: Looks good to me, but someone else must approve
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index eefc5d9..57c3add 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -2768,7 +2768,7 @@
if self.isQualifier and self.isReference:
raise ValueError(u'Claim cannot be both a qualifier and reference.')
self.sources = []
- self.qualifiers = {}
+ self.qualifiers = collections.defaultdict(list)
self.target = None
self.snaktype = 'value'
self.rank = 'normal'
@@ -2810,10 +2810,8 @@
for prop in data['qualifiers']:
for qualifier in data['qualifiers'][prop]:
qual = Claim.qualifierFromJSON(site, qualifier)
- if prop in claim.qualifiers:
- claim.qualifiers[prop].append(qual)
- else:
- claim.qualifiers[prop] = [qual]
+ claim.qualifiers[prop].append(qual)
+
return claim
@staticmethod
@@ -2935,6 +2933,17 @@
source[claim.getID()].append(claim)
self.sources.append(source)
+ def addQualifier(self, qualifier, **kwargs):
+ """Adds the given qualifier
+
+ @param qualifier: the qualifier to add
+ @type qualifier: Claim
+ """
+ data = self.repo.editQualifier(self, qualifier, **kwargs)
+ qualifier.isQualifier = True
+ self.on_item.lastrevid = data['pageinfo']['lastrevid']
+ self.qualifiers[qualifier.getID()].append(qualifier)
+
def _formatDataValue(self):
"""
Format the target into the proper JSON datavalue that Wikibase wants
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 13477b0..f14132c 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3616,8 +3616,8 @@
@param new Whether to create a new one if the "source" already exists
@type new bool
"""
- if claim.isReference:
- raise ValueError("The claim cannot be a reference.")
+ if claim.isReference or claim.isQualifier:
+ raise ValueError("The claim cannot have a source.")
params = dict(action='wbsetreference',
statement=claim.snak,
)
@@ -3668,6 +3668,42 @@
return data
@must_be(group='user')
+ def editQualifier(self, claim, qualifier, new=False, bot=True, **kwargs):
+ """
+ Create/Edit a qualifier
+
+ @param claim: A Claim object to add the qualifier to
+ @type claim: pywikibot.Claim
+ @param qualifier: A Claim object to be used as a qualifier
+ @type qualifier: pywikibot.Claim
+ """
+ if claim.isReference or claim.isQualifier:
+ raise ValueError("The claim cannot have a qualifier.")
+ params = dict(action='wbsetqualifier',
+ claim=claim.snak,
+ )
+ if claim.on_item: # I can't think of when this would be false, but lets be safe
+ params['baserevid'] = claim.on_item.lastrevid
+ if bot:
+ params['bot'] = 1
+ if not new and hasattr(qualifier, 'hash'):
+ params['snakhash'] = qualifier.hash
+ params['token'] = self.token(claim, 'edit')
+ #build up the snak
+ if qualifier.getSnakType() == 'value':
+ params['value'] = json.dumps(qualifier._formatDataValue())
+ params['snaktype'] = qualifier.getSnakType()
+ params['property'] = qualifier.getID()
+
+ for arg in kwargs:
+ if arg in ['baserevid', 'summary']:
+ params[arg] = kwargs[arg]
+
+ req = api.Request(site=self, **params)
+ data = req.submit()
+ return data
+
+ @must_be(group='user')
def removeClaims(self, claims, bot=True, **kwargs):
params = dict(action='wbremoveclaims')
if bot:
--
To view, visit https://gerrit.wikimedia.org/r/81567
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I917a69fff552be8b29a5d186d6b9f8df6eeea61d
Gerrit-PatchSet: 9
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: FelixReimann <felix(a)fex-it.de>
Gerrit-Reviewer: FelixReimann <felix(a)fex-it.de>
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Use the API to retrieve redirects to the category redirect template (this time with caching)
......................................................................
Use the API to retrieve redirects to the category redirect template
(this time with caching)
Change-Id: I7af283b3b7a18bd713627cb5f1d8667773e3f3c6
---
M pywikibot/families/wikipedia_family.py
M pywikibot/family.py
2 files changed, 24 insertions(+), 10 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/families/wikipedia_family.py b/pywikibot/families/wikipedia_family.py
index 0149a8e..67f3fd4 100644
--- a/pywikibot/families/wikipedia_family.py
+++ b/pywikibot/families/wikipedia_family.py
@@ -54,11 +54,7 @@
'arz': (u'تحويل تصنيف',),
'cs': (u'Zastaralá kategorie',),
'da': (u'Kategoriomdirigering',),
- 'en': (u'Category redirect',
- u'Category Redirect',
- u"Categoryredirect",
- u'Catredirect',
- u'Cat redirect',),
+ 'en': (u'Category redirect',),
'es': (u'Categoría redirigida',),
'eu': (u'Kategoria redirect',),
'fa': (u'رده بهتر',
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 59484c9..a7c58d4 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -653,7 +653,6 @@
}
# A list of category redirect template names in different languages
- # Note: It *is* necessary to list template redirects here
self.category_redirect_templates = {
'_default': []
}
@@ -858,15 +857,34 @@
% {'language_code': code})
def category_redirects(self, code, fallback="_default"):
- if code in self.category_redirect_templates:
- return self.category_redirect_templates[code]
- elif fallback:
- return self.category_redirect_templates[fallback]
+ if not hasattr(self, "_catredirtemplates") or code not in self._catredirtemplates:
+ self.get_cr_templates(code, fallback)
+ if code in self._catredirtemplates:
+ return self._catredirtemplates[code]
else:
raise KeyError(
"ERROR: title for category redirect template in language '%s' unknown"
% code)
+ def get_cr_templates(self, code, fallback):
+ if not hasattr(self, "_catredirtemplates"):
+ self._catredirtemplates = {}
+ if code in self.category_redirect_templates:
+ cr_template = self.category_redirect_templates[code][0]
+ else:
+ cr_template = self.category_redirect_templates[fallback][0]
+ # start with list of category redirect templates from family file
+ cr_page = pywikibot.Page(pywikibot.Site(code, self),
+ "Template:" + cr_template)
+ cr_list = list(self.category_redirect_templates[code])
+ # retrieve all redirects to primary template from API,
+ # add any that are not already on the list
+ for t in cr_page.backlinks(filterRedirects=True, namespaces=10):
+ newtitle = t.title(withNamespace=False)
+ if newtitle not in cr_list:
+ cr_list.append(newtitle)
+ self._catredirtemplates[code] = cr_list
+
def disambig(self, code, fallback='_default'):
if code in self.disambiguationTemplates:
return self.disambiguationTemplates[code]
--
To view, visit https://gerrit.wikimedia.org/r/85203
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7af283b3b7a18bd713627cb5f1d8667773e3f3c6
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Russell Blau <russblau(a)imapmail.org>
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: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Aligned help with implementation
......................................................................
Aligned help with implementation
Change-Id: I32340b0ed4e6bf39a793ccb6b7288c02ed1b941c
---
M pywikibot/config2.py
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index ee62581..1085ddc 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -105,7 +105,8 @@
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 (Windows) or
+ 3. 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.
--
To view, visit https://gerrit.wikimedia.org/r/87016
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I32340b0ed4e6bf39a793ccb6b7288c02ed1b941c
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
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