Monday, July 23, 2018

‘datetime.time object’ has no attribute ‘date’

How can contain a datetime.time value?

>>> from lino import startup
>>> startup('lino_welfare.projects.eupen.settings.doctests')
>>> from lino.api.doctest import *
>>> translation.activate('fr')
>>> from django.utils import timezone
>>> now =
>>>, 7, 23)
>>> type(now)
<type 'datetime.datetime'>

The presence_certificate.body.html was using lino_xl.lib.excerpts.Excerpt.time instead of

It took me half an hour to verify that this issue was actually already fixed in January 2018. But they didn’t yet upgrade since then, and I didn’t register the issue as a ticket. So now I opened #2443.

Using data from Wikidata

Yesterday I did my first steps with pywikibot.

My first script:

import pywikibot
site = pywikibot.Site('en', 'wikipedia')
page = pywikibot.Page(site, 'User:LucSaffre/sandbox')
page.text = page.text.replace('foo', 'bar')'Replaced foo by bar')  # Saves the page using the given summary

My second script:

from pprint import pprint
import pywikibot
site = pywikibot.Site('en', 'wikipedia')  # The site we want to run our bot on
if False:  # works
    page = pywikibot.Page(site, 'User:LucSaffre/sandbox')
    page.text = page.text.replace('foo', 'bar')'kkk')  # Saves the page

# compare    
page = pywikibot.Page(site, "Vana-Vigala")
item = pywikibot.ItemPage.fromPage(page)
claims = item.get()['claims']
for k in claims.keys():
    print(k, claims[k])

My first script with a concrete goal (it would be nice if my commondata project would become useless):

..literalinclude:: pwb/

Next step on that script would be to also print the claims (as explained in Data Harves tutorial). I got stuck when I realized that the ISO code fields seem to be empty when I run that query on

EDIT: I later also forked the wikidata project on GitHub and got the following script to tun:

from wikidatafun import getAllCountries
for i, c in enumerate(getAllCountries()):
    print(i, c)