[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2017-05-05 Thread Sovmogil
Sovmogil added a comment.
Thank you @Lokal_Profil . The solution worked.TASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_Profil, SovmogilCc: Sovmogil, Mike_Peel, Holger, daniel, Magul, ChongDae, Strainu, gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, Adik2382, Th3d3v1ls, Ramalepe, Liugev6, Tbscho, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, Avicennasis, Sn1per, jayvdb, Ricordisamoa, Dalba, Masti, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2017-05-05 Thread Lokal_Profil
Lokal_Profil added a comment.
@Sovmogil you need to use the newest version on pip 3.0.xxxTASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_ProfilCc: Sovmogil, Mike_Peel, Holger, daniel, Magul, ChongDae, Strainu, gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, Adik2382, Th3d3v1ls, Ramalepe, Liugev6, Tbscho, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, Avicennasis, Sn1per, jayvdb, Ricordisamoa, Dalba, Masti, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2017-05-05 Thread Sovmogil
Sovmogil added a comment.
Hi!
I am sorry, but 
with this version:

Pywikibot: pywikibot/__init__.py (c4ccfae, -1 (unknown), 2017/05/05, 01:02:04, n/a)
Release version: 2.0rc5
httplib2 version: 0.9.1
  cacerts: D:\SNMs\refinery\pywikibot\core_stable\externals\httplib2\python3\httplib2\cacerts.txt
certificate test: ok
Python: 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)]
  unicode test: ok
PYWIKIBOT2_DIR: Not set
PYWIKIBOT2_DIR_PWB:
PYWIKIBOT2_NO_USER_CONFIG: Not set
Config base dir: D:\SNMs\refinery\pywikibot\core_stable
Usernames for family "wikipedia":
ru: Sovmogil (no sysop configured)

and with this script --

import pywikibot

from pywikibot import pagegenerators as pg

def list_template_usage(site_obj, tmpl_name):
"""
Takes Site object and template name and returns a generator.

The function expects a Site object (pywikibot.Site()) and
a template name (String). It creates a list of all
pages using that template and returns them as a generator.
The generator will load 50 pages at a time for iteration.
"""
name = "{}:{}".format(site_obj.namespace(10), tmpl_name)
tmpl_page = pywikibot.Page(site_obj, name)
ref_gen = pg.ReferringPageGenerator(tmpl_page, _onlyTemplateInclusion_=True)
filter_gen = pg.NamespaceFilterPageGenerator(ref_gen, namespaces=[0])
generator = site_obj.preloadpages(filter_gen, groupsize=20, templates=False, langlinks=False)
return generator

site = pywikibot.Site("ru", 'wikipedia')
tmpl_gen = list_template_usage(site, "geo-stub")

for page in tmpl_gen:
item = pywikibot.ItemPage.fromPage(page)
print(item.getID())

I am stil getting this error -- 

D:\SNMs\refinery\pywikibot\core_stable>python testpull02.py
Retrieving 20 pages from wikipedia:ru.
Q5214867
Q4163312
Q4289585
Traceback (most recent call last):
  File "testpull02.py", line 25, in 
item = pywikibot.ItemPage.fromPage(page)
  File "D:\SNMs\refinery\pywikibot\core_stable\pywikibot\page.py", line 3556, in fromPage
if not lazy_load and not i.exists():
  File "D:\SNMs\refinery\pywikibot\core_stable\pywikibot\page.py", line 3158, in exists
self.get()
  File "D:\SNMs\refinery\pywikibot\core_stable\pywikibot\page.py", line 3576, in get
c = Claim.fromJSON(self.repo, claim)
  File "D:\SNMs\refinery\pywikibot\core_stable\pywikibot\page.py", line 3995, in fromJSON
claim.type, lambda value, site: value)(value, site)
  File "D:\SNMs\refinery\pywikibot\core_stable\pywikibot\page.py", line 3942, in 
'quantity': lambda value, site: pywikibot.WbQuantity.fromWikibase(value),
  File "D:\SNMs\refinery\pywikibot\core_stable\pywikibot\__init__.py", line 512, in fromWikibase
upperBound = eval(wb['upperBound'])
KeyError: 'upperBound'

I've read it was kind of fixed, but it seems to be not... Any suggestions how it is to be better handled please.

Thank you for your timeTASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_Profil, SovmogilCc: Sovmogil, Mike_Peel, Holger, daniel, Magul, ChongDae, Strainu, gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, Adik2382, Th3d3v1ls, Ramalepe, Liugev6, Tbscho, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, Avicennasis, Sn1per, jayvdb, Ricordisamoa, Dalba, Masti, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2017-02-28 Thread Lokal_Profil
Lokal_Profil added a comment.
Per T150210#2954454 you will need to raise this on the tasks for making a new release. At this point 2.0r5 is so far behind master that it might not be possible to reliably backport individual patches.TASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_ProfilCc: Mike_Peel, Holger, daniel, Magul, ChongDae, Strainu, gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, Adik2382, Th3d3v1ls, Ramalepe, Liugev6, Tbscho, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, Avicennasis, Sn1per, jayvdb, Ricordisamoa, Dalba, Masti, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2017-02-27 Thread Mike_Peel
Mike_Peel added a comment.
Please consider fixing this in 2.0rc5/the pip install version. I just came across this, and spent the time to debug my code to make sure that wasn't the problem, tracked down the problematic value on a Wikidata entry, wrote a test script that demonstrates the issue, tested it on several computers, and came here to submit the bug - only to then find this thread. If the pip version was up-to-date, none of that would have been necessary. :-(TASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_Profil, Mike_PeelCc: Mike_Peel, Holger, daniel, Magul, ChongDae, Strainu, gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, Adik2382, Th3d3v1ls, Ramalepe, Liugev6, Tbscho, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, Avicennasis, Sn1per, jayvdb, Ricordisamoa, Dalba, Masti, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2017-01-19 Thread Holger
Holger added a comment.
Is this fix already in 2.0rc5?
Getting this error in lots of places.
Thanks :)TASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_Profil, HolgerCc: Holger, daniel, Magul, ChongDae, Strainu, gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, Th3d3v1ls, Ramalepe, Liugev6, Tbscho, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, Avicennasis, jayvdb, Ricordisamoa, Wesalius, Dalba, Masti, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2016-11-28 Thread gerritbot
gerritbot added a comment.
Change 322672 merged by jenkins-bot:
Require site object only for older MediaWiki installations

https://gerrit.wikimedia.org/r/322672TASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_Profil, gerritbotCc: daniel, Magul, ChongDae, Strainu, gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, Ramalepe, Liugev6, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, jayvdb, Ricordisamoa, Wesalius, Dalba, Masti, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2016-11-28 Thread Lokal_Profil
Lokal_Profil added a comment.
@Strainu No reply on the list. I would suggest merging the patch as I've already seen a couple of questions from people running on Wikidata.TASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_ProfilCc: daniel, Magul, ChongDae, Strainu, gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, Ramalepe, Liugev6, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, jayvdb, Ricordisamoa, Wesalius, Dalba, Masti, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2016-11-22 Thread Lokal_Profil
Lokal_Profil added a comment.

In T150210#2810877, @Strainu wrote:
Since backwards compatibility will be broken anyway, the question is if we should keep the extra code that handles older versions of Wikibase. Is there any data on the number of Wikibase installations out there?


I pinged the pywikibot list to see if anyone is using pywikibot for other wikibase installations but my gut feeling says it's unlikely.TASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_ProfilCc: daniel, Magul, ChongDae, Strainu, gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, Ramalepe, Liugev6, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, jayvdb, Ricordisamoa, Wesalius, Dalba, Masti, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2016-11-21 Thread Strainu
Strainu added a comment.
Since backwards compatibility will be broken anyway, the question is if we should keep the extra code that handles older versions of Wikibase. Is there any data on the number of Wikibase installations out there?TASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_Profil, StrainuCc: daniel, Magul, ChongDae, Strainu, gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, Ramalepe, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, jayvdb, Ricordisamoa, Wesalius, Dalba, Masti, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2016-11-21 Thread gerritbot
gerritbot added a comment.
Change 322672 had a related patch set uploaded (by Lokal Profil):
Require site object only for older MediaWiki installations

https://gerrit.wikimedia.org/r/322672TASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_Profil, gerritbotCc: daniel, Magul, ChongDae, Strainu, gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, Ramalepe, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, jayvdb, Ricordisamoa, Wesalius, Dalba, Masti, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2016-11-21 Thread Lokal_Profil
Lokal_Profil added a comment.
OK. So the current patch was merged which allows pywikibot to go on dealing with Wikidata.

To avoid the scenario which @daniel mentions a follow-up patch can be submitted which changes _require_errors() to False instead if no site object is provided. I we put together that patch but am ok with either solution.

More importantly this change (or changes) should be pushed to the 2.0 branch to ensure they can also deal with unbound errors correctly.TASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_ProfilCc: daniel, Magul, ChongDae, Strainu, gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, Ramalepe, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, jayvdb, Ricordisamoa, Wesalius, Dalba, Masti, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2016-11-21 Thread daniel
daniel added a comment.
@Strainu defaulting to +/-0 was nearly always definitely wrong. +/-0 means ABSOLUTE precision. That does not exist for any measured quantity, only for definitions and exact counts.

Omitted bounds does not have the same semantics as +/-0 at all. A bot is going to change many (not all) instances of +/-0 to unbounded, because +/-0 was abused a lot on wikidata to prevent the uncertainty bounds to be displayed. The same bot will also change many (not all) +/-1 quantities to unbound, because +/-1 was the old default.

In any case, please DO NOT use +/-0 as the default for value imports, ever. It's semantically wrong in almost all cases. Always has been.TASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_Profil, danielCc: daniel, Magul, ChongDae, Strainu, gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, Ramalepe, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, jayvdb, Ricordisamoa, Wesalius, Dalba, Masti, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2016-11-21 Thread gerritbot
gerritbot added a comment.
Change 320649 merged by jenkins-bot:
[Breaking]Make uncertainties in WbQuantity optional

https://gerrit.wikimedia.org/r/320649TASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_Profil, gerritbotCc: Magul, ChongDae, Strainu, gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, Ramalepe, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, jayvdb, Ricordisamoa, Wesalius, Dalba, Masti, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2016-11-10 Thread Strainu
Strainu added a comment.

In T150210#2785021, @Lokal_Profil wrote:
My worry is that the current solution would require everyone who wants their bot to correctly handle Quantities on Wikidata to update their code (adding the site object). Whereas if they ignore the warning they can happily go on mishandling them (which affects T142087).

After thinking about this some more one solution would be to have _require_errors() return False instead if no site object is provided. That way Wikidata users will automatically get the desired behaviour without changing anything.


Having the default accommodate the newest version seems like a good idea, but I don't think the current version would qualify as "incorrect", even from an ontology POV. It would simply be a QuantityValue instead of an UnboundedQuantityValue. I would expect a maintenance script to be run after the change if the intention is to move all Quantities with upper/lower bound 0 to UnboundedQuantityValue. I'm not familiar enough with ontologies to be able to say if this is needed/desirable.TASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_Profil, StrainuCc: Strainu, gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, jayvdb, Ricordisamoa, Wesalius, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2016-11-09 Thread Strainu
Strainu added a comment.
Great job keeping the backwards compatibility! I say submit the code with the current logic and remove the extra logic later if the code becomes unmaintainable (this will eventually happen after a few more breaking changes to wikibase).TASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_Profil, StrainuCc: Strainu, gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, jayvdb, Ricordisamoa, Wesalius, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2016-11-09 Thread Lokal_Profil
Lokal_Profil added a comment.

In T150210#2783476, @gerritbot wrote:
Change 320649 had a related patch set uploaded (by Lokal Profil):
 Make uncertainties in WbQuantity optional

https://gerrit.wikimedia.org/r/320649


There is a lot of extra code in here just to ensure this is compatible with older versions of WikiBase.

Specifically WbQuantity now requires a site object which it then only uses to check the MediaWiki version of the site. To me that feels like unnecessary overhead (and would require a lot of people update their client code)

A solution would be to simply ignore older versions of WikiBase (everything works fine as long as you supply an error) and maybe just listen for "pywikibot.data.api.APIError: invalid-snak" when someone tries to add a Claim where the target is WbQuantity and if so raise an error/warning suggesting "this might be due to you not specifying an error"?TASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_ProfilCc: gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, jayvdb, Ricordisamoa, Wesalius, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs


[Pywikipedia-bugs] [Maniphest] [Commented On] T150210: Make WbQuantity handle case without errors

2016-11-09 Thread gerritbot
gerritbot added a comment.
Change 320649 had a related patch set uploaded (by Lokal Profil):
Make uncertainties in WbQuantity optional

https://gerrit.wikimedia.org/r/320649TASK DETAILhttps://phabricator.wikimedia.org/T150210EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lokal_Profil, gerritbotCc: gerritbot, Aklapper, Lokal_Profil, pywikibot-bugs-list, MayS, Mdupont, JJMC89, jayvdb, Ricordisamoa, Wesalius, Alchimista, Rxy___
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs