Setting “preferred rank” for latest population statements

I noticed that many German cities have lots of population statements with “point in time”, none of which has the preferred rank. Usually, it’s recommended to distinguish the “current” population (usually, the latest statement) by setting it to preferred rank, so that it can easily be queried for with wdt:. In general, determining the best statement requires human oversight (the latest statement could come from a sketchy source, so perhaps the second latest would be preferred), but in most of these cases, all population statements on an item have the same reference (some population table by some statistical state office). I decided that I could fix those cases with a bot.

(Note: all this text was written after-the-fact, so I’m sometimes talking about the code in the past tense.)

Preface: pywikibot update

Wikidata was recently updated for improved quantity precision handling (see here for details). pywikibot was already updated for these changes, but the version installed on PAWS (or at least, on my server) was outdated. To fix this, I updated pywikibot from the terminal:

cd /srv/paws/pwb
git pull
mv ../lib/python3.4/site-packages/pywikibot{,-bak}
cp -a pywikibot/ ../lib/python3.4/site-packages/

Putting together the bot

I assembled the bot in typical PAWS fashion: playing around until things started falling together :)

We start with some boilerplate, copied from older bots:

import pywikibot as pwb
from pywikibot import pagegenerators as pg
site = pwb.Site("wikidata", "wikidata")
repo = site.data_repository()

We get a test item and play with it. (Most commands in this phase are no longer visbile, but it’s essentially lots of tab completion and dir(…).)

item = pwb.ItemPage(repo, "Q61668")
x = item.get()["claims"]["P1082"][0].qualifiers["P585"][0].getTarget()
"P585" in item.get()["claims"]["P1082"][0].qualifiers
True

This function gets the “point in time” qualifier of a claim and converts it to an ISO 8601 date/time string, which can be compared with the </> operators (the normal WbTime class isn’t comparable).

def pointInTime(claim):
    return claim.qualifiers["P585"][0].getTarget().toTimestr()

Search for the latest and second-latest population claim of the item.

latest = None
secondLatest = None
for claim in item.get()["claims"]["P1082"]:
    if "P585" in claim.qualifiers:
        if latest == None:
            latest = claim
        else:
            if pointInTime(claim) > pointInTime(latest):
                secondLatest = latest
                latest = claim

A function that returns the “reference URL” source of a claim, if it exists.

def refUrlSource(claim):
    if len(claim.sources) == 1 and "P854" in claim.sources[0] and len(claim.sources[0]["P854"]) == 1:
        return claim.sources[0]["P854"][0]
    else:
        return None

I only want to set the latest statement to preferred rank if it has exactly the same source as the second-latest one. Can we compare sources by simply comparing their JSON content? Turns out, yes!

source = refUrlSource(latest)
source.toJSON()
{'datatype': 'url',
 'datavalue': {'type': 'string',
  'value': 'http://www.statistik.baden-wuerttemberg.de/BevoelkGebiet/Bevoelkerung/01515020.tab?R=GS118081'},
 'hash': '7c41b8390b7d528f3aadd7cb37133ed6e2c10989',
 'property': 'P854',
 'snaktype': 'value'}
source2 = refUrlSource(secondLatest)
source2.toJSON()
{'datatype': 'url',
 'datavalue': {'type': 'string',
  'value': 'http://www.statistik.baden-wuerttemberg.de/BevoelkGebiet/Bevoelkerung/01515020.tab?R=GS118081'},
 'hash': '7c41b8390b7d528f3aadd7cb37133ed6e2c10989',
 'property': 'P854',
 'snaktype': 'value'}
source.toJSON() == source2.toJSON()
True

Set the rank to preferred. (This doesn’t yet do anything on Wikidata, it only sets a field of the local value.)

latest.rank = 'preferred'

Actually edit the item on Wikidata.

item.editEntity(summary='set preferred rank (pywikibot test)')
# it worked! (reminder: item is Q61668)

Put all of this in a function (and also print what we’re doing). By this time, I had also created a wiki user page that I could link to in the edit summary.

def processItem(item):
    latest = None
    secondLatest = None
    for claim in item.get()["claims"]["P1082"]:
        if "P585" in claim.qualifiers:
            if latest == None:
                latest = claim
            else:
                if pointInTime(claim) > pointInTime(latest):
                    secondLatest = latest
                    latest = claim
    if refUrlSource(latest).toJSON() == refUrlSource(secondLatest).toJSON():
        print('Editing item ' + item.id)
        latest.rank = 'preferred'
        item.editEntity(summary='set latest statement to preferred rank: https://www.wikidata.org/wiki/User:TweetsFactsAndQueries/LatestPopulation')

Second test run. (There’s no print output – that’s what reminded me to add a print to the query above.)

processItem(pwb.ItemPage(repo, "Q82911"))

Third test run, now with print.

processItem(pwb.ItemPage(repo, "Q332952"))
Editing item Q332952

A query that finds us all cities with more than one wdt: population statements.

query="""
SELECT ?item (COUNT(?population) AS ?count) WHERE {
  ?item wdt:P31/wdt:P279* wd:Q15284;
        wdt:P17 wd:Q183;
        wdt:P1082 ?population.
}
GROUP BY ?item
HAVING(?count > 1)
ORDER BY DESC(?count)
"""

A generator for the query…

generator = pg.WikidataSPARQLPageGenerator(query, site)

…and now we run the query and process all the items.

Turns out I was a bit sloppy and didn’t handle some Nones correctly.

for item in generator:
    processItem(item)
Editing item Q527625
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-94-d3acc9017e5d> in <module>()
      1 for item in generator:
----> 2     processItem(item)

<ipython-input-90-06b783927ed1> in processItem(item)
     10                     secondLatest = latest
     11                     latest = claim
---> 12     if refUrlSource(latest).toJSON() == refUrlSource(secondLatest).toJSON():
     13         print('Editing item ' + item.id)
     14         latest.rank = 'preferred'

AttributeError: 'NoneType' object has no attribute 'toJSON'

Update processItem to correctly handle missing sources (if source1 is not None…).

def processItem(item):
    latest = None
    secondLatest = None
    for claim in item.get()["claims"]["P1082"]:
        if "P585" in claim.qualifiers:
            if latest == None:
                latest = claim
            else:
                if pointInTime(claim) > pointInTime(latest):
                    secondLatest = latest
                    latest = claim
    source1 = refUrlSource(latest)
    source2 = refUrlSource(secondLatest)
    if source1 is not None and source2 is not None and source1.toJSON() == source2.toJSON():
        print('Editing item ' + item.id)
        latest.rank = 'preferred'
        item.editEntity(summary='set latest statement to preferred rank: https://www.wikidata.org/wiki/User:TweetsFactsAndQueries/LatestPopulation')

Another test edit (successful).

processItem(pwb.ItemPage(repo, "Q505447"))
Editing item Q505447

Run the query again. We immediately run into the next None issue.

for item in pg.WikidataSPARQLPageGenerator(query, site):
    processItem(item)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-97-3203f0f8012d> in <module>()
      1 for item in pg.WikidataSPARQLPageGenerator(query, site):
----> 2     processItem(item)

<ipython-input-95-6f0843a0d9f4> in processItem(item)
     11                     latest = claim
     12     source1 = refUrlSource(latest)
---> 13     source2 = refUrlSource(secondLatest)
     14     if source1 is not None and source2 is not None and source1.toJSON() == source2.toJSON():
     15         print('Editing item ' + item.id)

<ipython-input-75-088a3699cf42> in refUrlSource(claim)
      1 def refUrlSource(claim):
----> 2     if len(claim.sources) == 1 and "P854" in claim.sources[0] and len(claim.sources[0]["P854"]) == 1:
      3         return claim.sources[0]["P854"][0]
      4     else:
      5         return None

AttributeError: 'NoneType' object has no attribute 'sources'

Update refUrlSource to handle missing claims.

def refUrlSource(claim):
    if claim is not None and len(claim.sources) == 1 and "P854" in claim.sources[0] and len(claim.sources[0]["P854"]) == 1:
        return claim.sources[0]["P854"][0]
    else:
        return None

Run the query once more. This time, it works! It runs for quite a while before something crashes.

for item in pg.WikidataSPARQLPageGenerator(query, site):
    processItem(item)
Editing item Q507113
Editing item Q81088
Sleeping for 8.4 seconds, 2016-12-03 21:13:54
Editing item Q540595
Sleeping for 8.8 seconds, 2016-12-03 21:14:04
Editing item Q61731
Sleeping for 8.5 seconds, 2016-12-03 21:14:14
Editing item Q557773
Sleeping for 8.5 seconds, 2016-12-03 21:14:24
Editing item Q81504
Sleeping for 8.7 seconds, 2016-12-03 21:14:34
Editing item Q552240
Sleeping for 8.6 seconds, 2016-12-03 21:14:44
Editing item Q61739
Sleeping for 7.6 seconds, 2016-12-03 21:14:55
Editing item Q81642
Sleeping for 8.9 seconds, 2016-12-03 21:15:04
Editing item Q550528
Sleeping for 8.3 seconds, 2016-12-03 21:15:15
Editing item Q61736
Sleeping for 9.0 seconds, 2016-12-03 21:15:24
Editing item Q550582
Sleeping for 8.4 seconds, 2016-12-03 21:15:34
Editing item Q632859
Sleeping for 8.8 seconds, 2016-12-03 21:15:44
Editing item Q404053
Sleeping for 8.8 seconds, 2016-12-03 21:15:54
Editing item Q520595
Sleeping for 8.5 seconds, 2016-12-03 21:16:04
Editing item Q4019
Sleeping for 9.0 seconds, 2016-12-03 21:16:14
Editing item Q529054
Sleeping for 9.1 seconds, 2016-12-03 21:16:24
Editing item Q547710
Sleeping for 8.1 seconds, 2016-12-03 21:16:35
Editing item Q505478
Sleeping for 8.8 seconds, 2016-12-03 21:16:44
Editing item Q550750
Sleeping for 8.5 seconds, 2016-12-03 21:16:54
Editing item Q81404
Sleeping for 8.4 seconds, 2016-12-03 21:17:05
Editing item Q80502
Sleeping for 8.1 seconds, 2016-12-03 21:17:15
Editing item Q557816
Sleeping for 8.5 seconds, 2016-12-03 21:17:24
Editing item Q332952
Sleeping for 8.7 seconds, 2016-12-03 21:17:34
Editing item Q488708
Sleeping for 8.3 seconds, 2016-12-03 21:17:45
Editing item Q431175
Sleeping for 8.6 seconds, 2016-12-03 21:17:54
Editing item Q557734
Sleeping for 8.6 seconds, 2016-12-03 21:18:04
Editing item Q538724
Sleeping for 8.3 seconds, 2016-12-03 21:18:15
Editing item Q506450
Sleeping for 8.6 seconds, 2016-12-03 21:18:24
Editing item Q83091
Sleeping for 8.8 seconds, 2016-12-03 21:18:34
Editing item Q632905
Sleeping for 8.8 seconds, 2016-12-03 21:18:44
Editing item Q6979
Sleeping for 8.3 seconds, 2016-12-03 21:18:55
Editing item Q7050
Sleeping for 8.4 seconds, 2016-12-03 21:19:05
Editing item Q81216
Sleeping for 8.8 seconds, 2016-12-03 21:19:14
Editing item Q373824
Sleeping for 8.7 seconds, 2016-12-03 21:19:24
Editing item Q536448
Sleeping for 8.9 seconds, 2016-12-03 21:19:34
Editing item Q586965
Sleeping for 8.3 seconds, 2016-12-03 21:19:45
Editing item Q557768
Sleeping for 8.0 seconds, 2016-12-03 21:19:55
Editing item Q632798
Sleeping for 8.3 seconds, 2016-12-03 21:20:05
Editing item Q248127
Sleeping for 8.1 seconds, 2016-12-03 21:20:15
Editing item Q507721
Sleeping for 8.4 seconds, 2016-12-03 21:20:25
Editing item Q7039
Sleeping for 8.8 seconds, 2016-12-03 21:20:34
Editing item Q632790
Sleeping for 8.7 seconds, 2016-12-03 21:20:44
Editing item Q505920
Sleeping for 8.4 seconds, 2016-12-03 21:20:55
Editing item Q557664
Sleeping for 8.8 seconds, 2016-12-03 21:21:04
Editing item Q80487
Sleeping for 8.5 seconds, 2016-12-03 21:21:15
Editing item Q550661
Sleeping for 8.5 seconds, 2016-12-03 21:21:25
Editing item Q544761
Sleeping for 8.3 seconds, 2016-12-03 21:21:35
Editing item Q533966
Sleeping for 8.3 seconds, 2016-12-03 21:21:45
Editing item Q80809
Sleeping for 8.5 seconds, 2016-12-03 21:21:55
Editing item Q62121
Sleeping for 8.4 seconds, 2016-12-03 21:22:05
Editing item Q518981
Sleeping for 8.9 seconds, 2016-12-03 21:22:14
Editing item Q632914
Sleeping for 8.9 seconds, 2016-12-03 21:22:24
Editing item Q81903
Sleeping for 8.7 seconds, 2016-12-03 21:22:35
Editing item Q81994
Sleeping for 8.8 seconds, 2016-12-03 21:22:44
Editing item Q385687
Sleeping for 8.5 seconds, 2016-12-03 21:22:55
Editing item Q536304
Sleeping for 8.6 seconds, 2016-12-03 21:23:05
Editing item Q81012
Sleeping for 8.7 seconds, 2016-12-03 21:23:15
Editing item Q62064
Sleeping for 8.6 seconds, 2016-12-03 21:23:25
Editing item Q503260
Sleeping for 8.8 seconds, 2016-12-03 21:23:34
Editing item Q542545
Sleeping for 8.5 seconds, 2016-12-03 21:23:45
Editing item Q3834
Sleeping for 7.7 seconds, 2016-12-03 21:23:56
Editing item Q503220
Sleeping for 8.0 seconds, 2016-12-03 21:24:05
Editing item Q540673
Sleeping for 8.7 seconds, 2016-12-03 21:24:15
Editing item Q506597
Sleeping for 8.9 seconds, 2016-12-03 21:24:24
Editing item Q62062
Sleeping for 8.3 seconds, 2016-12-03 21:24:35
Editing item Q80505
Sleeping for 9.0 seconds, 2016-12-03 21:24:44
Editing item Q311771
Sleeping for 8.9 seconds, 2016-12-03 21:24:54
Editing item Q16077
Sleeping for 8.8 seconds, 2016-12-03 21:25:05
Editing item Q572443
Sleeping for 8.6 seconds, 2016-12-03 21:25:15
Editing item Q61639
Sleeping for 8.8 seconds, 2016-12-03 21:25:25
Editing item Q528062
Sleeping for 7.2 seconds, 2016-12-03 21:25:36
Editing item Q83050
Sleeping for 8.5 seconds, 2016-12-03 21:25:45
Editing item Q550711
Sleeping for 8.3 seconds, 2016-12-03 21:25:55
Editing item Q61995
Sleeping for 8.5 seconds, 2016-12-03 21:26:05
Editing item Q62122
Sleeping for 8.9 seconds, 2016-12-03 21:26:15
Editing item Q550620
Sleeping for 8.7 seconds, 2016-12-03 21:26:25
Editing item Q22960
Sleeping for 8.8 seconds, 2016-12-03 21:26:35
Editing item Q473107
Sleeping for 8.7 seconds, 2016-12-03 21:26:45
Editing item Q62069
Sleeping for 8.8 seconds, 2016-12-03 21:26:55
Editing item Q489911
Sleeping for 8.1 seconds, 2016-12-03 21:27:05
Editing item Q542576
Sleeping for 8.9 seconds, 2016-12-03 21:27:15
Editing item Q22959
Sleeping for 8.9 seconds, 2016-12-03 21:27:25
Editing item Q622
Sleeping for 8.1 seconds, 2016-12-03 21:27:35
Editing item Q550673
Sleeping for 8.5 seconds, 2016-12-03 21:27:45
Editing item Q632420
Sleeping for 8.8 seconds, 2016-12-03 21:27:55
Editing item Q538658
Sleeping for 8.8 seconds, 2016-12-03 21:28:05
Editing item Q14866
Sleeping for 8.7 seconds, 2016-12-03 21:28:15
Editing item Q82825
Sleeping for 8.4 seconds, 2016-12-03 21:28:25
Editing item Q533667
Sleeping for 8.8 seconds, 2016-12-03 21:28:35
Editing item Q632421
Sleeping for 8.6 seconds, 2016-12-03 21:28:45
Editing item Q22965
Sleeping for 8.5 seconds, 2016-12-03 21:28:55
Editing item Q550786
Sleeping for 8.3 seconds, 2016-12-03 21:29:05
Editing item Q81277
Sleeping for 8.8 seconds, 2016-12-03 21:29:15
Editing item Q81102
Sleeping for 8.9 seconds, 2016-12-03 21:29:25
Editing item Q1584
Sleeping for 8.9 seconds, 2016-12-03 21:29:35
Editing item Q83202
Sleeping for 8.1 seconds, 2016-12-03 21:29:45
Editing item Q473710
Sleeping for 8.2 seconds, 2016-12-03 21:29:55
Editing item Q61925
Sleeping for 8.5 seconds, 2016-12-03 21:30:05
Editing item Q62034
Sleeping for 8.3 seconds, 2016-12-03 21:30:15
Editing item Q80526
Sleeping for 8.5 seconds, 2016-12-03 21:30:25
Editing item Q529216
Sleeping for 8.9 seconds, 2016-12-03 21:30:35
Editing item Q550669
Sleeping for 8.4 seconds, 2016-12-03 21:30:45
Editing item Q539876
Sleeping for 8.8 seconds, 2016-12-03 21:30:55
Editing item Q557618
Sleeping for 7.4 seconds, 2016-12-03 21:31:06
Editing item Q61634
Sleeping for 8.8 seconds, 2016-12-03 21:31:15
Editing item Q81026
Sleeping for 8.3 seconds, 2016-12-03 21:31:25
Editing item Q557679
Sleeping for 8.9 seconds, 2016-12-03 21:31:35
Editing item Q112559
Sleeping for 8.4 seconds, 2016-12-03 21:31:45
Editing item Q550773
Sleeping for 8.7 seconds, 2016-12-03 21:31:55
Editing item Q515191
Sleeping for 8.6 seconds, 2016-12-03 21:32:05
Editing item Q533735
Sleeping for 8.4 seconds, 2016-12-03 21:32:15
Editing item Q201907
Sleeping for 8.3 seconds, 2016-12-03 21:32:25
Editing item Q80480
Sleeping for 8.4 seconds, 2016-12-03 21:32:35
Editing item Q574269
Sleeping for 8.9 seconds, 2016-12-03 21:32:45
Editing item Q62019
Sleeping for 8.9 seconds, 2016-12-03 21:32:55
Editing item Q515637
Sleeping for 9.0 seconds, 2016-12-03 21:33:05
Editing item Q410980
Sleeping for 8.7 seconds, 2016-12-03 21:33:15
Editing item Q519688
Sleeping for 8.4 seconds, 2016-12-03 21:33:25
Editing item Q6832
Sleeping for 8.6 seconds, 2016-12-03 21:33:35
Editing item Q557710
Sleeping for 8.0 seconds, 2016-12-03 21:33:46
Editing item Q632934
Sleeping for 8.5 seconds, 2016-12-03 21:33:55
Editing item Q61909
Sleeping for 8.7 seconds, 2016-12-03 21:34:05
Editing item Q23007
Sleeping for 8.4 seconds, 2016-12-03 21:34:15
Editing item Q81124
Sleeping for 8.8 seconds, 2016-12-03 21:34:25
Editing item Q553808
Sleeping for 7.6 seconds, 2016-12-03 21:34:36
Editing item Q14853
Sleeping for 8.6 seconds, 2016-12-03 21:34:45
Editing item Q552134
Sleeping for 8.7 seconds, 2016-12-03 21:34:55
Editing item Q3232
Sleeping for 8.8 seconds, 2016-12-03 21:35:05
Editing item Q82197
Sleeping for 8.6 seconds, 2016-12-03 21:35:15
Editing item Q636197
Sleeping for 9.0 seconds, 2016-12-03 21:35:25
Editing item Q80494
Sleeping for 8.6 seconds, 2016-12-03 21:35:35
Editing item Q60136
Sleeping for 8.8 seconds, 2016-12-03 21:35:45
Editing item Q834905
Sleeping for 8.9 seconds, 2016-12-03 21:35:55
Editing item Q540568
Sleeping for 8.8 seconds, 2016-12-03 21:36:05
Editing item Q22877
Sleeping for 8.3 seconds, 2016-12-03 21:36:16
Editing item Q574223
Sleeping for 8.9 seconds, 2016-12-03 21:36:25
Editing item Q539774
Sleeping for 8.4 seconds, 2016-12-03 21:36:36
Editing item Q574246
Sleeping for 8.3 seconds, 2016-12-03 21:36:46
Editing item Q61724
Sleeping for 8.7 seconds, 2016-12-03 21:36:55
Editing item Q61989
Sleeping for 8.3 seconds, 2016-12-03 21:37:06
Editing item Q142169
Sleeping for 8.8 seconds, 2016-12-03 21:37:15
Editing item Q268734
Sleeping for 8.6 seconds, 2016-12-03 21:37:25
Editing item Q62021
Sleeping for 8.9 seconds, 2016-12-03 21:37:35
Editing item Q82717
Sleeping for 8.7 seconds, 2016-12-03 21:37:45
Editing item Q62101
Sleeping for 8.4 seconds, 2016-12-03 21:37:56
Editing item Q1228438
Sleeping for 8.7 seconds, 2016-12-03 21:38:05
Editing item Q6931
Sleeping for 8.7 seconds, 2016-12-03 21:38:15
Editing item Q53805
Sleeping for 8.3 seconds, 2016-12-03 21:38:26
Editing item Q550684
Sleeping for 8.7 seconds, 2016-12-03 21:38:35
Editing item Q80552
Sleeping for 8.8 seconds, 2016-12-03 21:38:45
Editing item Q550625
Sleeping for 8.7 seconds, 2016-12-03 21:38:55
Editing item Q632811
Sleeping for 8.9 seconds, 2016-12-03 21:39:05
Editing item Q557651
Sleeping for 8.7 seconds, 2016-12-03 21:39:15
Editing item Q389752
Sleeping for 7.9 seconds, 2016-12-03 21:39:26
Editing item Q539862
Sleeping for 8.2 seconds, 2016-12-03 21:39:36
Editing item Q550804
Sleeping for 8.9 seconds, 2016-12-03 21:39:45
Editing item Q509666
Sleeping for 8.8 seconds, 2016-12-03 21:39:55
Editing item Q7010
Sleeping for 8.2 seconds, 2016-12-03 21:40:06
Editing item Q539754
Sleeping for 9.0 seconds, 2016-12-03 21:40:15
Editing item Q518825
Sleeping for 8.6 seconds, 2016-12-03 21:40:25
Editing item Q61626
Sleeping for 8.1 seconds, 2016-12-03 21:40:36
Editing item Q83302
Sleeping for 8.9 seconds, 2016-12-03 21:40:45
Editing item Q61999
Sleeping for 8.9 seconds, 2016-12-03 21:40:55
Editing item Q60559
Sleeping for 8.9 seconds, 2016-12-03 21:41:05
Editing item Q4140
Sleeping for 9.0 seconds, 2016-12-03 21:41:15
Editing item Q82922
Sleeping for 9.0 seconds, 2016-12-03 21:41:25
Editing item Q62032
Sleeping for 8.7 seconds, 2016-12-03 21:41:35
Editing item Q527998
Sleeping for 8.5 seconds, 2016-12-03 21:41:46
Editing item Q80446
Sleeping for 8.7 seconds, 2016-12-03 21:41:55
Editing item Q81501
Sleeping for 8.2 seconds, 2016-12-03 21:42:06
Editing item Q521356
Sleeping for 8.6 seconds, 2016-12-03 21:42:16
Editing item Q550704
Sleeping for 8.9 seconds, 2016-12-03 21:42:25
Editing item Q538579
Sleeping for 8.3 seconds, 2016-12-03 21:42:36
Editing item Q473155
Sleeping for 8.7 seconds, 2016-12-03 21:42:46
Editing item Q61668
Sleeping for 8.7 seconds, 2016-12-03 21:42:56
Editing item Q384061
Sleeping for 8.5 seconds, 2016-12-03 21:43:06
Editing item Q557634
Sleeping for 8.9 seconds, 2016-12-03 21:43:15
Editing item Q606787
Sleeping for 8.7 seconds, 2016-12-03 21:43:26
Editing item Q549795
Sleeping for 8.4 seconds, 2016-12-03 21:43:36
Editing item Q80455
Sleeping for 8.5 seconds, 2016-12-03 21:43:46
Editing item Q505504
Sleeping for 8.5 seconds, 2016-12-03 21:43:56
Editing item Q61920
Sleeping for 8.8 seconds, 2016-12-03 21:44:05
Editing item Q61653
Sleeping for 8.8 seconds, 2016-12-03 21:44:15
Editing item Q557598
Sleeping for 8.8 seconds, 2016-12-03 21:44:26
Editing item Q521449
Sleeping for 8.2 seconds, 2016-12-03 21:44:36
Editing item Q519018
Sleeping for 8.7 seconds, 2016-12-03 21:44:46
Editing item Q61709
Sleeping for 8.8 seconds, 2016-12-03 21:44:56
Editing item Q81017
Sleeping for 7.8 seconds, 2016-12-03 21:45:07
Editing item Q538686
Sleeping for 8.3 seconds, 2016-12-03 21:45:16
Editing item Q574197
Sleeping for 8.9 seconds, 2016-12-03 21:45:25
Editing item Q80874
Sleeping for 8.6 seconds, 2016-12-03 21:45:36
Editing item Q82169
Sleeping for 8.8 seconds, 2016-12-03 21:45:46
Editing item Q81261
Sleeping for 8.6 seconds, 2016-12-03 21:45:56
Editing item Q263741
Sleeping for 8.7 seconds, 2016-12-03 21:46:06
Editing item Q161019
Sleeping for 8.4 seconds, 2016-12-03 21:46:16
Editing item Q505483
Sleeping for 8.9 seconds, 2016-12-03 21:46:26
Editing item Q14916
Sleeping for 8.7 seconds, 2016-12-03 21:46:36
Editing item Q14950
Sleeping for 8.6 seconds, 2016-12-03 21:46:46
Editing item Q81210
Sleeping for 8.5 seconds, 2016-12-03 21:46:56
Editing item Q81099
Sleeping for 8.0 seconds, 2016-12-03 21:47:06
Editing item Q557757
Sleeping for 8.9 seconds, 2016-12-03 21:47:16
Editing item Q539889
Sleeping for 8.4 seconds, 2016-12-03 21:47:26
Editing item Q62037
Sleeping for 8.8 seconds, 2016-12-03 21:47:36
Editing item Q574188
Sleeping for 7.9 seconds, 2016-12-03 21:47:47
Editing item Q83144
Sleeping for 8.7 seconds, 2016-12-03 21:47:56
Editing item Q355264
Sleeping for 8.5 seconds, 2016-12-03 21:48:06
Editing item Q200744
Sleeping for 8.9 seconds, 2016-12-03 21:48:16
Editing item Q533995
Sleeping for 8.3 seconds, 2016-12-03 21:48:26
Editing item Q81484
Sleeping for 8.7 seconds, 2016-12-03 21:48:36
Editing item Q632889
Sleeping for 9.0 seconds, 2016-12-03 21:48:46
Editing item Q545164
Sleeping for 8.8 seconds, 2016-12-03 21:48:56
Editing item Q61651
Sleeping for 8.5 seconds, 2016-12-03 21:49:06
Editing item Q81122
Sleeping for 7.7 seconds, 2016-12-03 21:49:17
Editing item Q542172
Sleeping for 8.8 seconds, 2016-12-03 21:49:26
Editing item Q61636
Sleeping for 8.8 seconds, 2016-12-03 21:49:36
Editing item Q538110
Sleeping for 8.7 seconds, 2016-12-03 21:49:46
Editing item Q528029
Sleeping for 8.8 seconds, 2016-12-03 21:49:56
Editing item Q527597
Sleeping for 8.6 seconds, 2016-12-03 21:50:06
Editing item Q82911
Sleeping for 8.7 seconds, 2016-12-03 21:50:16
Editing item Q551998
Sleeping for 9.0 seconds, 2016-12-03 21:50:26
Editing item Q83214
Sleeping for 8.4 seconds, 2016-12-03 21:50:36
Editing item Q551628
Sleeping for 8.8 seconds, 2016-12-03 21:50:46
Editing item Q80539
Sleeping for 8.4 seconds, 2016-12-03 21:50:56
Editing item Q508851
Sleeping for 8.7 seconds, 2016-12-03 21:51:06
Editing item Q61707
Sleeping for 9.2 seconds, 2016-12-03 21:51:15
Editing item Q4037
Sleeping for 8.1 seconds, 2016-12-03 21:51:27
Editing item Q6874
Sleeping for 8.8 seconds, 2016-12-03 21:51:36
Editing item Q547357
Sleeping for 8.9 seconds, 2016-12-03 21:51:46
Editing item Q550693
Sleeping for 8.6 seconds, 2016-12-03 21:51:56
Editing item Q705735
Sleeping for 8.9 seconds, 2016-12-03 21:52:06
Editing item Q148343
Sleeping for 8.9 seconds, 2016-12-03 21:52:16
Editing item Q13622
Sleeping for 8.7 seconds, 2016-12-03 21:52:26
Editing item Q569502
Sleeping for 8.8 seconds, 2016-12-03 21:52:36
Editing item Q22962
Sleeping for 8.6 seconds, 2016-12-03 21:52:46
Editing item Q61837
Sleeping for 8.3 seconds, 2016-12-03 21:52:56
Editing item Q540556
Sleeping for 8.6 seconds, 2016-12-03 21:53:06
Editing item Q504457
Sleeping for 8.6 seconds, 2016-12-03 21:53:16
Editing item Q80610
Sleeping for 8.4 seconds, 2016-12-03 21:53:26
Editing item Q62010
Sleeping for 8.6 seconds, 2016-12-03 21:53:36
Editing item Q61698
Sleeping for 8.7 seconds, 2016-12-03 21:53:46
Editing item Q340782
Sleeping for 8.8 seconds, 2016-12-03 21:53:56
Editing item Q80565
Sleeping for 8.8 seconds, 2016-12-03 21:54:06
Editing item Q527855
Sleeping for 8.2 seconds, 2016-12-03 21:54:17
Editing item Q557784
Sleeping for 8.5 seconds, 2016-12-03 21:54:26
Editing item Q83129
Sleeping for 8.8 seconds, 2016-12-03 21:54:36
Editing item Q542399
Sleeping for 8.5 seconds, 2016-12-03 21:54:46
Editing item Q533808
Sleeping for 8.4 seconds, 2016-12-03 21:54:57
Editing item Q83092
Sleeping for 8.8 seconds, 2016-12-03 21:55:06
Editing item Q60237
Sleeping for 8.5 seconds, 2016-12-03 21:55:16
Editing item Q705778
Sleeping for 8.7 seconds, 2016-12-03 21:55:26
Editing item Q82285
Sleeping for 8.8 seconds, 2016-12-03 21:55:36
Editing item Q545371
Sleeping for 8.6 seconds, 2016-12-03 21:55:46
Editing item Q61912
Sleeping for 9.0 seconds, 2016-12-03 21:55:56
Editing item Q557646
Sleeping for 8.0 seconds, 2016-12-03 21:56:07
Editing item Q62042
Sleeping for 8.8 seconds, 2016-12-03 21:56:16
Editing item Q80444
Sleeping for 8.8 seconds, 2016-12-03 21:56:26
Editing item Q506780
Sleeping for 8.7 seconds, 2016-12-03 21:56:36
Editing item Q81817
Sleeping for 8.4 seconds, 2016-12-03 21:56:47
Editing item Q82220
Sleeping for 8.8 seconds, 2016-12-03 21:56:56
Editing item Q81350
Sleeping for 8.8 seconds, 2016-12-03 21:57:06
Editing item Q538615
Sleeping for 8.9 seconds, 2016-12-03 21:57:16
Editing item Q47167
Sleeping for 8.7 seconds, 2016-12-03 21:57:26
Editing item Q82053
Sleeping for 8.5 seconds, 2016-12-03 21:57:37
Editing item Q61656
Sleeping for 8.3 seconds, 2016-12-03 21:57:47
Editing item Q81862
Sleeping for 8.9 seconds, 2016-12-03 21:57:56
Editing item Q481414
Sleeping for 8.2 seconds, 2016-12-03 21:58:07
Editing item Q2341049
Sleeping for 8.2 seconds, 2016-12-03 21:58:17
Editing item Q705746
Sleeping for 8.8 seconds, 2016-12-03 21:58:26
Editing item Q27918
Sleeping for 8.9 seconds, 2016-12-03 21:58:36
Editing item Q80783
Sleeping for 9.0 seconds, 2016-12-03 21:58:46
Editing item Q4044
Sleeping for 8.4 seconds, 2016-12-03 21:58:57
Editing item Q550630
Sleeping for 8.5 seconds, 2016-12-03 21:59:07
Editing item Q62008
Sleeping for 8.5 seconds, 2016-12-03 21:59:17
Editing item Q80548
Sleeping for 8.8 seconds, 2016-12-03 21:59:26
Editing item Q187544
Sleeping for 8.3 seconds, 2016-12-03 21:59:37
Editing item Q62017
Sleeping for 8.7 seconds, 2016-12-03 21:59:46
Editing item Q534681
Sleeping for 8.8 seconds, 2016-12-03 21:59:56
Editing item Q574252
Sleeping for 8.6 seconds, 2016-12-03 22:00:07
Editing item Q80543
Sleeping for 8.5 seconds, 2016-12-03 22:00:17
Editing item Q22884
Sleeping for 8.7 seconds, 2016-12-03 22:00:26
Editing item Q15979
Sleeping for 8.9 seconds, 2016-12-03 22:00:36
Editing item Q179013
Sleeping for 9.0 seconds, 2016-12-03 22:00:46
Editing item Q632820
Sleeping for 8.4 seconds, 2016-12-03 22:00:57
Editing item Q80708
Sleeping for 8.4 seconds, 2016-12-03 22:01:07
Editing item Q14905
Sleeping for 8.6 seconds, 2016-12-03 22:01:17
Editing item Q34773
Sleeping for 8.6 seconds, 2016-12-03 22:01:27
Editing item Q632412
Sleeping for 8.3 seconds, 2016-12-03 22:01:37
Editing item Q80571
Sleeping for 8.7 seconds, 2016-12-03 22:01:47
Editing item Q61997
Sleeping for 8.9 seconds, 2016-12-03 22:01:56
Editing item Q83271
Sleeping for 8.6 seconds, 2016-12-03 22:02:07
Editing item Q550986
Sleeping for 8.5 seconds, 2016-12-03 22:02:17
Editing item Q546393
Sleeping for 8.8 seconds, 2016-12-03 22:02:27
Editing item Q534331
Sleeping for 8.5 seconds, 2016-12-03 22:02:37
Editing item Q550682
Sleeping for 8.9 seconds, 2016-12-03 22:02:46
Editing item Q3786
Sleeping for 8.5 seconds, 2016-12-03 22:02:57
Editing item Q550627
Sleeping for 8.9 seconds, 2016-12-03 22:03:06
Editing item Q83153
Sleeping for 8.9 seconds, 2016-12-03 22:03:16
Editing item Q14893
Sleeping for 8.7 seconds, 2016-12-03 22:03:27
Editing item Q572427
Sleeping for 8.8 seconds, 2016-12-03 22:03:37
Editing item Q61835
Sleeping for 8.7 seconds, 2016-12-03 22:03:47
Editing item Q83140
Sleeping for 8.9 seconds, 2016-12-03 22:03:56
Editing item Q535222
Sleeping for 9.0 seconds, 2016-12-03 22:04:06
Editing item Q62003
Sleeping for 8.5 seconds, 2016-12-03 22:04:17
Editing item Q550659
Sleeping for 8.0 seconds, 2016-12-03 22:04:27
Editing item Q705521
Sleeping for 8.2 seconds, 2016-12-03 22:04:37
Editing item Q506821
Sleeping for 8.3 seconds, 2016-12-03 22:04:47
Editing item Q83107
Sleeping for 8.4 seconds, 2016-12-03 22:04:57
Editing item Q4051
Sleeping for 9.0 seconds, 2016-12-03 22:05:06
Editing item Q529205
Sleeping for 8.0 seconds, 2016-12-03 22:05:17
Editing item Q550679
Sleeping for 8.7 seconds, 2016-12-03 22:05:27
Editing item Q81051
Sleeping for 8.3 seconds, 2016-12-03 22:05:37
Editing item Q538801
Sleeping for 8.5 seconds, 2016-12-03 22:05:47
Editing item Q80618
Sleeping for 8.4 seconds, 2016-12-03 22:05:57
Editing item Q502780
Sleeping for 8.9 seconds, 2016-12-03 22:06:07
Editing item Q504451
Sleeping for 8.2 seconds, 2016-12-03 22:06:17
Editing item Q550771
Sleeping for 8.2 seconds, 2016-12-03 22:06:27
Editing item Q163344
Sleeping for 8.0 seconds, 2016-12-03 22:06:38
Editing item Q527580
Sleeping for 8.8 seconds, 2016-12-03 22:06:47
Editing item Q80700
Sleeping for 8.7 seconds, 2016-12-03 22:06:57
Editing item Q80636
Sleeping for 8.4 seconds, 2016-12-03 22:07:07
Editing item Q62079
Sleeping for 8.4 seconds, 2016-12-03 22:07:17
Editing item Q636063
Sleeping for 8.2 seconds, 2016-12-03 22:07:27
Editing item Q61827
Sleeping for 8.4 seconds, 2016-12-03 22:07:37
Editing item Q550726
Sleeping for 9.0 seconds, 2016-12-03 22:07:47
Editing item Q632838
Sleeping for 8.8 seconds, 2016-12-03 22:07:57
Editing item Q550651
Sleeping for 9.0 seconds, 2016-12-03 22:08:07
Editing item Q165015
Sleeping for 8.5 seconds, 2016-12-03 22:08:17
Editing item Q16100
Sleeping for 8.4 seconds, 2016-12-03 22:08:27
Editing item Q515280
Sleeping for 8.0 seconds, 2016-12-03 22:08:38
Editing item Q628990
Sleeping for 8.1 seconds, 2016-12-03 22:08:48
Editing item Q81143
Sleeping for 8.1 seconds, 2016-12-03 22:08:57
Editing item Q80515
Sleeping for 8.1 seconds, 2016-12-03 22:09:07
Editing item Q557718
Sleeping for 8.9 seconds, 2016-12-03 22:09:17
Editing item Q550764
Sleeping for 8.8 seconds, 2016-12-03 22:09:27
Editing item Q505447
Sleeping for 8.6 seconds, 2016-12-03 22:09:37
Editing item Q83212
Sleeping for 9.1 seconds, 2016-12-03 22:09:47
Editing item Q534060
Sleeping for 8.9 seconds, 2016-12-03 22:09:57
Editing item Q925847
Sleeping for 8.7 seconds, 2016-12-03 22:10:07
Editing item Q80665
Sleeping for 8.8 seconds, 2016-12-03 22:10:17
Editing item Q266170
Sleeping for 8.7 seconds, 2016-12-03 22:10:27
Editing item Q81682
Sleeping for 9.3 seconds, 2016-12-03 22:10:36
Editing item Q518078
Sleeping for 8.2 seconds, 2016-12-03 22:10:47
Editing item Q388453
Sleeping for 8.6 seconds, 2016-12-03 22:10:57
Editing item Q515323
Sleeping for 9.0 seconds, 2016-12-03 22:11:07
Editing item Q61729
Sleeping for 8.5 seconds, 2016-12-03 22:11:17
Editing item Q80639
Sleeping for 8.8 seconds, 2016-12-03 22:11:27
Editing item Q8336
Sleeping for 8.6 seconds, 2016-12-03 22:11:37
Editing item Q515999
Sleeping for 9.0 seconds, 2016-12-03 22:11:47
Editing item Q61738
Sleeping for 8.6 seconds, 2016-12-03 22:11:57
Editing item Q83074
Sleeping for 8.3 seconds, 2016-12-03 22:12:07
Editing item Q515671
Sleeping for 8.9 seconds, 2016-12-03 22:12:17
Editing item Q550649
Sleeping for 8.8 seconds, 2016-12-03 22:12:27
Editing item Q519779
Sleeping for 8.6 seconds, 2016-12-03 22:12:37
Editing item Q537241
Sleeping for 8.9 seconds, 2016-12-03 22:12:47
Editing item Q552099
Sleeping for 8.9 seconds, 2016-12-03 22:12:57
Editing item Q62026
Sleeping for 8.9 seconds, 2016-12-03 22:13:07
Editing item Q519997
Sleeping for 9.0 seconds, 2016-12-03 22:13:17
Editing item Q2302546
Sleeping for 8.7 seconds, 2016-12-03 22:13:27
Editing item Q557698
Sleeping for 8.8 seconds, 2016-12-03 22:13:37
Editing item Q80577
Sleeping for 8.8 seconds, 2016-12-03 22:13:47
Editing item Q566612
Sleeping for 8.8 seconds, 2016-12-03 22:13:57
Editing item Q83205
Sleeping for 8.4 seconds, 2016-12-03 22:14:07
Editing item Q548684
Sleeping for 8.7 seconds, 2016-12-03 22:14:17
Editing item Q62039
Sleeping for 8.6 seconds, 2016-12-03 22:14:27
Editing item Q80717
Sleeping for 8.9 seconds, 2016-12-03 22:14:37
Editing item Q61645
Sleeping for 7.6 seconds, 2016-12-03 22:14:48
Editing item Q384264
Sleeping for 8.7 seconds, 2016-12-03 22:14:57
Editing item Q1969963
Sleeping for 8.8 seconds, 2016-12-03 22:15:07
Editing item Q540770
Sleeping for 8.8 seconds, 2016-12-03 22:15:17
Editing item Q539825
Sleeping for 8.8 seconds, 2016-12-03 22:15:27
Editing item Q4072
Sleeping for 9.0 seconds, 2016-12-03 22:15:37
Editing item Q545124
Sleeping for 8.6 seconds, 2016-12-03 22:15:47
Editing item Q532622
Sleeping for 8.9 seconds, 2016-12-03 22:15:57
Editing item Q16015
Sleeping for 8.7 seconds, 2016-12-03 22:16:07
Editing item Q520583
Sleeping for 9.1 seconds, 2016-12-03 22:16:17
Editing item Q61733
Sleeping for 8.5 seconds, 2016-12-03 22:16:28
Editing item Q83221
Sleeping for 8.6 seconds, 2016-12-03 22:16:37
Editing item Q550793
Sleeping for 8.8 seconds, 2016-12-03 22:16:47
Editing item Q278647
Sleeping for 8.9 seconds, 2016-12-03 22:16:57
Editing item Q53751
Sleeping for 8.9 seconds, 2016-12-03 22:17:07
Editing item Q81905
Sleeping for 8.0 seconds, 2016-12-03 22:17:18
Editing item Q83062
Sleeping for 8.6 seconds, 2016-12-03 22:17:27
Editing item Q557779
Sleeping for 8.7 seconds, 2016-12-03 22:17:37
Editing item Q557671
Sleeping for 8.5 seconds, 2016-12-03 22:17:48
Editing item Q557727
Sleeping for 8.2 seconds, 2016-12-03 22:17:58
Editing item Q6869
Sleeping for 8.8 seconds, 2016-12-03 22:18:07
Editing item Q515356
Sleeping for 9.0 seconds, 2016-12-03 22:18:17
Editing item Q518889
Sleeping for 8.6 seconds, 2016-12-03 22:18:28
Editing item Q61647
Sleeping for 8.7 seconds, 2016-12-03 22:18:37
Editing item Q529240
Sleeping for 8.4 seconds, 2016-12-03 22:18:48
Editing item Q61632
Sleeping for 8.8 seconds, 2016-12-03 22:18:57
Editing item Q506803
Sleeping for 8.6 seconds, 2016-12-03 22:19:07
Editing item Q528047
Sleeping for 8.3 seconds, 2016-12-03 22:19:18
Editing item Q519281
Sleeping for 8.6 seconds, 2016-12-03 22:19:28
Editing item Q550715
Sleeping for 8.8 seconds, 2016-12-03 22:19:37
Editing item Q550730
Sleeping for 8.3 seconds, 2016-12-03 22:19:48
Editing item Q515372
Sleeping for 8.8 seconds, 2016-12-03 22:19:57
Editing item Q520414
Sleeping for 8.9 seconds, 2016-12-03 22:20:07
Editing item Q506788
Sleeping for 8.6 seconds, 2016-12-03 22:20:18
Editing item Q62125
Sleeping for 8.7 seconds, 2016-12-03 22:20:28
Editing item Q521524
Sleeping for 8.6 seconds, 2016-12-03 22:20:38
Editing item Q3865
Sleeping for 8.5 seconds, 2016-12-03 22:20:48
Editing item Q515002
Sleeping for 8.7 seconds, 2016-12-03 22:20:58
Editing item Q81724
Sleeping for 8.6 seconds, 2016-12-03 22:21:08
Editing item Q81921
Sleeping for 8.9 seconds, 2016-12-03 22:21:17
Editing item Q61754
Sleeping for 8.3 seconds, 2016-12-03 22:21:28
Editing item Q80795
Sleeping for 8.6 seconds, 2016-12-03 22:21:38
Editing item Q515885
Sleeping for 9.0 seconds, 2016-12-03 22:21:47
Editing item Q504910
Sleeping for 8.8 seconds, 2016-12-03 22:21:58
Editing item Q557628
Sleeping for 8.9 seconds, 2016-12-03 22:22:07
Editing item Q503285
Sleeping for 8.8 seconds, 2016-12-03 22:22:18
Editing item Q83072
Sleeping for 8.5 seconds, 2016-12-03 22:22:28
Editing item Q515264
Sleeping for 8.9 seconds, 2016-12-03 22:22:37
Editing item Q26344
Sleeping for 8.3 seconds, 2016-12-03 22:22:48
Editing item Q542533
Sleeping for 8.8 seconds, 2016-12-03 22:22:58
Editing item Q80713
Sleeping for 8.8 seconds, 2016-12-03 22:23:08
Editing item Q22873
Sleeping for 8.9 seconds, 2016-12-03 22:23:17
Editing item Q334623
Sleeping for 8.5 seconds, 2016-12-03 22:23:28
Editing item Q14947
Sleeping for 8.9 seconds, 2016-12-03 22:23:38
Editing item Q534107
Sleeping for 8.9 seconds, 2016-12-03 22:23:47
Editing item Q61640
Sleeping for 8.9 seconds, 2016-12-03 22:23:57
Editing item Q62027
Sleeping for 8.8 seconds, 2016-12-03 22:24:08
Editing item Q537696
Sleeping for 8.8 seconds, 2016-12-03 22:24:18
Editing item Q61992
Sleeping for 8.9 seconds, 2016-12-03 22:24:28
Editing item Q403573
Sleeping for 9.0 seconds, 2016-12-03 22:24:37
Editing item Q62001
Sleeping for 8.2 seconds, 2016-12-03 22:24:48
Editing item Q518794
Sleeping for 8.3 seconds, 2016-12-03 22:24:58
Editing item Q533853
Sleeping for 8.5 seconds, 2016-12-03 22:25:08
Editing item Q82141
Sleeping for 8.4 seconds, 2016-12-03 22:25:18
Editing item Q3951
Sleeping for 8.1 seconds, 2016-12-03 22:25:28
Editing item Q7032
Sleeping for 8.9 seconds, 2016-12-03 22:25:38
Editing item Q160936
Sleeping for 8.3 seconds, 2016-12-03 22:25:48
Editing item Q503878
Sleeping for 8.7 seconds, 2016-12-03 22:25:58
Editing item Q529099
Sleeping for 8.5 seconds, 2016-12-03 22:26:08
Editing item Q518965
Sleeping for 8.6 seconds, 2016-12-03 22:26:18
Editing item Q16048
Sleeping for 8.4 seconds, 2016-12-03 22:26:28
WARNING: API error modification-failed: [[Q19589616|Q19589616]] not found
---------------------------------------------------------------------------
APIError                                  Traceback (most recent call last)
<ipython-input-99-3203f0f8012d> in <module>()
      1 for item in pg.WikidataSPARQLPageGenerator(query, site):
----> 2     processItem(item)

<ipython-input-95-6f0843a0d9f4> in processItem(item)
     15         print('Editing item ' + item.id)
     16         latest.rank = 'preferred'
---> 17         item.editEntity(summary='set latest statement to preferred rank: https://www.wikidata.org/wiki/User:TweetsFactsAndQueries/LatestPopulation')

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in editEntity(self, data, **kwargs)
   3809 
   3810         updates = self.repo.editEntity(self._defined_by(singular=True), data,
-> 3811                                        baserevid=baserevid, **kwargs)
   3812         self.latest_revision_id = updates['entity']['lastrevid']
   3813 

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in callee(self, *args, **kwargs)
   1328             else:
   1329                 raise Exception("Not implemented")
-> 1330             return fn(self, *args, **kwargs)
   1331 
   1332         if not __debug__:

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in editEntity(self, identification, data, bot, **kwargs)
   7263         params['data'] = json.dumps(data)
   7264         req = self._simple_request(**params)
-> 7265         data = req.submit()
   7266         return data
   7267 

/srv/paws/lib/python3.4/site-packages/pywikibot/data/api.py in submit(self)
   2187                               % result)
   2188 
-> 2189                 raise APIError(**result['error'])
   2190             except TypeError:
   2191                 raise RuntimeError(result)

APIError: modification-failed: [[Q19589616|Q19589616]] not found [messages:[{'parameters': ['[[Q19589616|Q19589616]]'], 'html': {'*': '<a href="/wiki/Q19589616" class="mw-redirect" title="Q19589616">Q19589616</a> not found'}, 'name': 'wikibase-validator-no-such-entity'}]; help:See https://www.wikidata.org/w/api.php for API usage]

(I was a bit confused what caused this error. Actual reason is further down below, but at first I just continued to run the bot.)

# looks like someone merged the item with another one…
# but as far as I can tell it didn’t have any population statements beforehand,
# so why did we try to operate on it in the first place?
for item in pg.WikidataSPARQLPageGenerator(query, site):
    processItem(item)
Editing item Q520595
Editing item Q4019
Sleeping for 8.2 seconds, 2016-12-03 22:44:44
Editing item Q547710
Sleeping for 9.0 seconds, 2016-12-03 22:44:53
Editing item Q488708
Sleeping for 8.1 seconds, 2016-12-03 22:45:04
Editing item Q332952
Sleeping for 8.8 seconds, 2016-12-03 22:45:13
Editing item Q506450
Sleeping for 8.0 seconds, 2016-12-03 22:45:24
Editing item Q6979
Sleeping for 8.0 seconds, 2016-12-03 22:45:34
Editing item Q373824
Sleeping for 8.0 seconds, 2016-12-03 22:45:44
Editing item Q7039
Sleeping for 8.9 seconds, 2016-12-03 22:45:53
Editing item Q3834
Sleeping for 7.3 seconds, 2016-12-03 22:46:05
Editing item Q622
Sleeping for 7.4 seconds, 2016-12-03 22:46:15
Editing item Q14866
Sleeping for 8.8 seconds, 2016-12-03 22:46:23
Editing item Q6832
Sleeping for 6.7 seconds, 2016-12-03 22:46:35
Editing item Q61909
Sleeping for 8.3 seconds, 2016-12-03 22:46:44
Editing item Q23007
Sleeping for 8.6 seconds, 2016-12-03 22:46:54
Editing item Q14853
Sleeping for 8.1 seconds, 2016-12-03 22:47:04
Editing item Q3232
Sleeping for 8.5 seconds, 2016-12-03 22:47:14
Editing item Q6931
Sleeping for 8.0 seconds, 2016-12-03 22:47:24
Editing item Q7010
Sleeping for 8.0 seconds, 2016-12-03 22:47:34
Editing item Q4140
Sleeping for 9.0 seconds, 2016-12-03 22:47:43

Next morning, I came back to find the bot finished. But my main query still returned results, so I just ran it again…

for item in pg.WikidataSPARQLPageGenerator(query, site):
    processItem(item)
Editing item Q520595
WARNING: API error badtoken: Invalid token
Sleeping for 9.8 seconds, 2016-12-04 07:57:51
Editing item Q4019
Sleeping for 8.9 seconds, 2016-12-04 07:58:02
Editing item Q547710
Sleeping for 9.1 seconds, 2016-12-04 07:58:12
Editing item Q488708
Sleeping for 8.0 seconds, 2016-12-04 07:58:23
Editing item Q332952
Sleeping for 8.7 seconds, 2016-12-04 07:58:32
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/srv/paws/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    385             try:  # Python 2.7, use buffering of HTTP responses
--> 386                 httplib_response = conn.getresponse(buffering=True)
    387             except TypeError:  # Python 2.6 and older, Python 3

TypeError: getresponse() got an unexpected keyword argument 'buffering'

During handling of the above exception, another exception occurred:

KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-103-3203f0f8012d> in <module>()
      1 for item in pg.WikidataSPARQLPageGenerator(query, site):
----> 2     processItem(item)

<ipython-input-95-6f0843a0d9f4> in processItem(item)
      2     latest = None
      3     secondLatest = None
----> 4     for claim in item.get()["claims"]["P1082"]:
      5         if "P585" in claim.qualifiers:
      6             if latest == None:

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in get(self, force, get_redirect, *args, **kwargs)
   3990         @raise NotImplementedError: a value in args or kwargs
   3991         """
-> 3992         data = super(ItemPage, self).get(force, *args, **kwargs)
   3993 
   3994         if self.isRedirectPage() and not get_redirect:

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in get(self, force, *args, **kwargs)
   3556 
   3557             try:
-> 3558                 data = self.repo.loadcontent(identification)
   3559             except APIError as err:
   3560                 if err.code == 'no-such-entity':

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in loadcontent(self, identification, *props)
   7161                                     props=props if props else False)
   7162         req = self._simple_request(**params)
-> 7163         data = req.submit()
   7164         if 'success' not in data:
   7165             raise api.APIError(data['errors'])

/srv/paws/lib/python3.4/site-packages/pywikibot/data/api.py in submit(self)
   1952                 rawdata = http.request(
   1953                     site=self.site, uri=uri, method='GET' if use_get else 'POST',
-> 1954                     body=body, headers=headers)
   1955             except Server504Error:
   1956                 pywikibot.log(u"Caught HTTP 504 error; retrying")

/srv/paws/lib/python3.4/site-packages/pywikibot/tools/__init__.py in wrapper(*__args, **__kw)
   1445                              cls, depth)
   1446                     del __kw[old_arg]
-> 1447             return obj(*__args, **__kw)
   1448 
   1449         if not __debug__:

/srv/paws/lib/python3.4/site-packages/pywikibot/comms/http.py in request(site, uri, method, body, headers, **kwargs)
    307     headers['user-agent'] = user_agent(site, format_string)
    308 
--> 309     r = fetch(baseuri, method, body, headers, **kwargs)
    310     return r.content
    311 

/srv/paws/lib/python3.4/site-packages/pywikibot/comms/http.py in fetch(uri, method, body, headers, default_error_handling, **kwargs)
    457     @rtype: L{threadedhttp.HttpRequest}
    458     """
--> 459     request = _enqueue(uri, method, body, headers, **kwargs)
    460     assert(request._data is not None)  # if there's no data in the answer we're in trouble
    461     # Run the error handling callback in the callers thread so exceptions

/srv/paws/lib/python3.4/site-packages/pywikibot/comms/http.py in _enqueue(uri, method, body, headers, **kwargs)
    439     request = threadedhttp.HttpRequest(
    440         uri, method, body, all_headers, callbacks, **kwargs)
--> 441     _http_process(session, request)
    442     return request
    443 

/srv/paws/lib/python3.4/site-packages/pywikibot/comms/http.py in _http_process(session, http_request)
    359         response = session.request(method, uri, data=body, headers=headers,
    360                                    auth=auth, timeout=timeout,
--> 361                                    verify=not ignore_validation)
    362     except Exception as e:
    363         http_request.data = e

/srv/paws/lib/python3.4/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    473         }
    474         send_kwargs.update(settings)
--> 475         resp = self.send(prep, **send_kwargs)
    476 
    477         return resp

/srv/paws/lib/python3.4/site-packages/requests/sessions.py in send(self, request, **kwargs)
    594 
    595         # Send the request
--> 596         r = adapter.send(request, **kwargs)
    597 
    598         # Total elapsed time of the request (approximately)

/srv/paws/lib/python3.4/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    421                     decode_content=False,
    422                     retries=self.max_retries,
--> 423                     timeout=timeout
    424                 )
    425 

/srv/paws/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, **response_kw)
    593                                                   timeout=timeout_obj,
    594                                                   body=body, headers=headers,
--> 595                                                   chunked=chunked)
    596 
    597             # If we're going to release the connection in ``finally:``, then

/srv/paws/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    387             except TypeError:  # Python 2.6 and older, Python 3
    388                 try:
--> 389                     httplib_response = conn.getresponse()
    390                 except Exception as e:
    391                     # Remove the TypeError from the exception chain in Python 3;

/usr/lib/python3.4/http/client.py in getresponse(self)
   1170             response = self.response_class(self.sock, method=self._method)
   1171 
-> 1172         response.begin()
   1173         assert response.will_close != _UNKNOWN
   1174         self.__state = _CS_IDLE

/usr/lib/python3.4/http/client.py in begin(self)
    349         # read until we get a non-100 response
    350         while True:
--> 351             version, status, reason = self._read_status()
    352             if status != CONTINUE:
    353                 break

/usr/lib/python3.4/http/client.py in _read_status(self)
    311 
    312     def _read_status(self):
--> 313         line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
    314         if len(line) > _MAXLINE:
    315             raise LineTooLong("status line")

/usr/lib/python3.4/socket.py in readinto(self, b)
    369         while True:
    370             try:
--> 371                 return self._sock.recv_into(b)
    372             except timeout:
    373                 self._timeout_occurred = True

/usr/lib/python3.4/ssl.py in recv_into(self, buffer, nbytes, flags)
    743                   "non-zero flags not allowed in calls to recv_into() on %s" %
    744                   self.__class__)
--> 745             return self.read(nbytes, buffer)
    746         else:
    747             return socket.recv_into(self, buffer, nbytes, flags)

/usr/lib/python3.4/ssl.py in read(self, len, buffer)
    615         try:
    616             if buffer is not None:
--> 617                 v = self._sslobj.read(len, buffer)
    618             else:
    619                 v = self._sslobj.read(len or 1024)

KeyboardInterrupt: 

…and again…

for item in pg.WikidataSPARQLPageGenerator(query, site):
    processItem(item)
Editing item Q520595
Editing item Q4019
Sleeping for 8.8 seconds, 2016-12-04 08:04:04
Editing item Q547710
Sleeping for 8.9 seconds, 2016-12-04 08:04:14
Editing item Q488708
Sleeping for 7.9 seconds, 2016-12-04 08:04:25
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-104-3203f0f8012d> in <module>()
      1 for item in pg.WikidataSPARQLPageGenerator(query, site):
----> 2     processItem(item)

<ipython-input-95-6f0843a0d9f4> in processItem(item)
     15         print('Editing item ' + item.id)
     16         latest.rank = 'preferred'
---> 17         item.editEntity(summary='set latest statement to preferred rank: https://www.wikidata.org/wiki/User:TweetsFactsAndQueries/LatestPopulation')

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in editEntity(self, data, **kwargs)
   3809 
   3810         updates = self.repo.editEntity(self._defined_by(singular=True), data,
-> 3811                                        baserevid=baserevid, **kwargs)
   3812         self.latest_revision_id = updates['entity']['lastrevid']
   3813 

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in callee(self, *args, **kwargs)
   1328             else:
   1329                 raise Exception("Not implemented")
-> 1330             return fn(self, *args, **kwargs)
   1331 
   1332         if not __debug__:

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in editEntity(self, identification, data, bot, **kwargs)
   7263         params['data'] = json.dumps(data)
   7264         req = self._simple_request(**params)
-> 7265         data = req.submit()
   7266         return data
   7267 

/srv/paws/lib/python3.4/site-packages/pywikibot/data/api.py in submit(self)
   1923                 return simulate
   1924             if self.throttle:
-> 1925                 self.site.throttle(write=self.write)
   1926             else:
   1927                 pywikibot.log(

/srv/paws/lib/python3.4/site-packages/pywikibot/throttle.py in __call__(self, requestsize, write)
    274             self.next_multiplicity = math.log(1 + requestsize) / math.log(2.0)
    275 
--> 276             self.wait(wait)
    277 
    278             if write:

/srv/paws/lib/python3.4/site-packages/pywikibot/throttle.py in wait(self, seconds)
    252             pywikibot.log(message)
    253 
--> 254         time.sleep(seconds)
    255 
    256     def __call__(self, requestsize=1, write=False):

KeyboardInterrupt: 

…and then I noticed that these edits weren’t showing up in my contributions or on the items’ histories, so I stopped the bot again. What’s the query again?

print(query)
SELECT ?item (COUNT(?population) AS ?count) WHERE {
  ?item wdt:P31/wdt:P279* wd:Q15284;
        wdt:P17 wd:Q183;
        wdt:P1082 ?population.
}
GROUP BY ?item
HAVING(?count > 1)
ORDER BY DESC(?count)

# d’oh!
# I was incorrectly including sites that only have multiple results because they have multiple paths to “municipaliy”,
# not because they actually have multiple population statements.
# Let’s only count the DISTINCT populations.

I realized the mistake, and fixed the query:

query="""
SELECT ?item (COUNT(DISTINCT ?population) AS ?count) WHERE {
  ?item wdt:P31/wdt:P279* wd:Q15284;
        wdt:P17 wd:Q183;
        wdt:P1082 ?population.
}
GROUP BY ?item
HAVING(?count > 1)
ORDER BY DESC(?count)
"""
for item in pg.WikidataSPARQLPageGenerator(query, site):
    processItem(item)
Editing item Q16048
WARNING: API error modification-failed: [[Q19589616|Q19589616]] not found
---------------------------------------------------------------------------
APIError                                  Traceback (most recent call last)
<ipython-input-110-3203f0f8012d> in <module>()
      1 for item in pg.WikidataSPARQLPageGenerator(query, site):
----> 2     processItem(item)

<ipython-input-95-6f0843a0d9f4> in processItem(item)
     15         print('Editing item ' + item.id)
     16         latest.rank = 'preferred'
---> 17         item.editEntity(summary='set latest statement to preferred rank: https://www.wikidata.org/wiki/User:TweetsFactsAndQueries/LatestPopulation')

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in editEntity(self, data, **kwargs)
   3809 
   3810         updates = self.repo.editEntity(self._defined_by(singular=True), data,
-> 3811                                        baserevid=baserevid, **kwargs)
   3812         self.latest_revision_id = updates['entity']['lastrevid']
   3813 

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in callee(self, *args, **kwargs)
   1328             else:
   1329                 raise Exception("Not implemented")
-> 1330             return fn(self, *args, **kwargs)
   1331 
   1332         if not __debug__:

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in editEntity(self, identification, data, bot, **kwargs)
   7263         params['data'] = json.dumps(data)
   7264         req = self._simple_request(**params)
-> 7265         data = req.submit()
   7266         return data
   7267 

/srv/paws/lib/python3.4/site-packages/pywikibot/data/api.py in submit(self)
   2187                               % result)
   2188 
-> 2189                 raise APIError(**result['error'])
   2190             except TypeError:
   2191                 raise RuntimeError(result)

APIError: modification-failed: [[Q19589616|Q19589616]] not found [messages:[{'parameters': ['[[Q19589616|Q19589616]]'], 'html': {'*': '<a href="/wiki/Q19589616" class="mw-redirect" title="Q19589616">Q19589616</a> not found'}, 'name': 'wikibase-validator-no-such-entity'}]; help:See https://www.wikidata.org/w/api.php for API usage]

I got the same error about the redirect again (see above), and realized what the actual reason was:

# The Crailsheim item had a link to a merged item.
# I guess that link is not automatically updated when the item is merged,
# but you’re not allowed to submit such a link (which editing the item apparently includes).
# Fixed by manually resolving the link on the item.

Run the bot one last time…

for item in pg.WikidataSPARQLPageGenerator(query, site):
    processItem(item)
Editing item Q16048
Editing item Q557825
Sleeping for 8.7 seconds, 2016-12-04 08:11:43
Editing item Q550644
Sleeping for 8.9 seconds, 2016-12-04 08:11:53
Editing item Q80483
Sleeping for 8.9 seconds, 2016-12-04 08:12:03
Editing item Q552003
Sleeping for 8.9 seconds, 2016-12-04 08:12:13
Editing item Q527868
Sleeping for 8.9 seconds, 2016-12-04 08:12:23
Editing item Q262485
Sleeping for 8.9 seconds, 2016-12-04 08:12:33
Editing item Q61701
Sleeping for 8.7 seconds, 2016-12-04 08:12:43
Editing item Q22958
Sleeping for 8.9 seconds, 2016-12-04 08:12:53
Editing item Q522526
Sleeping for 9.3 seconds, 2016-12-04 08:13:03
Editing item Q650568
Sleeping for 8.8 seconds, 2016-12-04 08:13:13
Editing item Q81265
Sleeping for 8.6 seconds, 2016-12-04 08:13:23
Editing item Q506549
Sleeping for 8.9 seconds, 2016-12-04 08:13:33
Editing item Q538672
Sleeping for 8.9 seconds, 2016-12-04 08:13:43
Editing item Q527642
Sleeping for 8.8 seconds, 2016-12-04 08:13:53
Editing item Q83079
Sleeping for 8.9 seconds, 2016-12-04 08:14:03
Editing item Q83227
Sleeping for 8.3 seconds, 2016-12-04 08:14:14
Editing item Q82927
Sleeping for 8.7 seconds, 2016-12-04 08:14:23
Editing item Q538630
Sleeping for 8.7 seconds, 2016-12-04 08:14:33
Editing item Q550754
Sleeping for 8.7 seconds, 2016-12-04 08:14:43
Editing item Q82741
Sleeping for 8.9 seconds, 2016-12-04 08:14:53
Editing item Q519987
Sleeping for 8.8 seconds, 2016-12-04 08:15:03
Editing item Q82007
Sleeping for 8.6 seconds, 2016-12-04 08:15:14
Editing item Q527951
Sleeping for 8.8 seconds, 2016-12-04 08:15:23
Editing item Q83131
Sleeping for 9.0 seconds, 2016-12-04 08:15:33
Editing item Q515800
Sleeping for 8.5 seconds, 2016-12-04 08:15:44
Editing item Q534155
Sleeping for 9.0 seconds, 2016-12-04 08:15:53
Editing item Q628178
Sleeping for 8.8 seconds, 2016-12-04 08:16:03
Editing item Q62023
Sleeping for 8.8 seconds, 2016-12-04 08:16:13
Editing item Q266250
Sleeping for 8.9 seconds, 2016-12-04 08:16:23
Editing item Q636023
Sleeping for 8.9 seconds, 2016-12-04 08:16:33
Editing item Q82430
Sleeping for 8.8 seconds, 2016-12-04 08:16:43
Editing item Q506323
Sleeping for 8.8 seconds, 2016-12-04 08:16:53
Editing item Q553770
Sleeping for 8.6 seconds, 2016-12-04 08:17:04
Editing item Q61890
Sleeping for 8.9 seconds, 2016-12-04 08:17:13
Editing item Q625651
Sleeping for 8.7 seconds, 2016-12-04 08:17:24
Editing item Q307399
Sleeping for 8.3 seconds, 2016-12-04 08:17:34
Editing item Q370971
Sleeping for 8.7 seconds, 2016-12-04 08:17:44
Editing item Q61642
Sleeping for 8.5 seconds, 2016-12-04 08:17:54
Editing item Q542630
Sleeping for 8.2 seconds, 2016-12-04 08:18:04
Editing item Q534202
Sleeping for 8.3 seconds, 2016-12-04 08:18:14
Editing item Q522302
Sleeping for 8.9 seconds, 2016-12-04 08:18:23
Editing item Q80560
Sleeping for 8.7 seconds, 2016-12-04 08:18:34
Editing item Q80691
Sleeping for 8.7 seconds, 2016-12-04 08:18:44
Editing item Q574203
Sleeping for 8.8 seconds, 2016-12-04 08:18:53
Editing item Q540583
Sleeping for 8.0 seconds, 2016-12-04 08:19:04
Editing item Q83230
Sleeping for 8.7 seconds, 2016-12-04 08:19:14
Editing item Q515176
Sleeping for 8.7 seconds, 2016-12-04 08:19:24
Editing item Q526213
Sleeping for 8.9 seconds, 2016-12-04 08:19:34
Editing item Q632770
Sleeping for 8.7 seconds, 2016-12-04 08:19:44
Editing item Q80458
Sleeping for 8.8 seconds, 2016-12-04 08:19:54
Editing item Q62013
Sleeping for 8.3 seconds, 2016-12-04 08:20:04
Editing item Q537729
Sleeping for 8.7 seconds, 2016-12-04 08:20:14
Editing item Q60556
Sleeping for 8.8 seconds, 2016-12-04 08:20:24
Editing item Q541161
Sleeping for 8.8 seconds, 2016-12-04 08:20:34
Editing item Q62014
Sleeping for 8.6 seconds, 2016-12-04 08:20:44
Editing item Q179890
Sleeping for 8.9 seconds, 2016-12-04 08:20:54
Editing item Q538643
Sleeping for 8.8 seconds, 2016-12-04 08:21:04
Editing item Q557640
Sleeping for 8.4 seconds, 2016-12-04 08:21:14
Editing item Q529259
Sleeping for 8.7 seconds, 2016-12-04 08:21:24
Editing item Q4072
Sleeping for 8.4 seconds, 2016-12-04 08:21:34
Editing item Q80819
Sleeping for 8.9 seconds, 2016-12-04 08:21:44
Editing item Q529271
Sleeping for 8.7 seconds, 2016-12-04 08:21:54
Editing item Q538599
Sleeping for 9.0 seconds, 2016-12-04 08:22:04
Editing item Q83252
Sleeping for 8.7 seconds, 2016-12-04 08:22:14
Editing item Q80464
Sleeping for 8.4 seconds, 2016-12-04 08:22:24
Editing item Q507836
Sleeping for 8.9 seconds, 2016-12-04 08:22:34
Editing item Q527922
Sleeping for 8.9 seconds, 2016-12-04 08:22:44
Editing item Q527898
Sleeping for 8.1 seconds, 2016-12-04 08:22:54
Editing item Q544758
Sleeping for 8.7 seconds, 2016-12-04 08:23:04
Editing item Q81721
Sleeping for 9.0 seconds, 2016-12-04 08:23:14
Editing item Q81084
Sleeping for 8.6 seconds, 2016-12-04 08:23:24
Editing item Q22876
Sleeping for 8.9 seconds, 2016-12-04 08:23:34
Editing item Q80472
Sleeping for 8.9 seconds, 2016-12-04 08:23:44
Editing item Q62030
Sleeping for 8.5 seconds, 2016-12-04 08:23:54
Editing item Q528076
Sleeping for 8.9 seconds, 2016-12-04 08:24:04
Editing item Q61665
Sleeping for 8.8 seconds, 2016-12-04 08:24:14
Editing item Q83135
Sleeping for 8.4 seconds, 2016-12-04 08:24:24
Editing item Q81625
Sleeping for 8.6 seconds, 2016-12-04 08:24:34
Editing item Q515988
Sleeping for 8.7 seconds, 2016-12-04 08:24:44
Editing item Q550761
Sleeping for 8.9 seconds, 2016-12-04 08:24:54
Editing item Q507671
Sleeping for 8.9 seconds, 2016-12-04 08:25:04
Editing item Q81423
Sleeping for 8.9 seconds, 2016-12-04 08:25:14
Editing item Q80644
Sleeping for 8.6 seconds, 2016-12-04 08:25:24
Editing item Q83143
Sleeping for 8.6 seconds, 2016-12-04 08:25:34
Editing item Q61734
Sleeping for 8.4 seconds, 2016-12-04 08:25:44
Editing item Q61840
Sleeping for 8.7 seconds, 2016-12-04 08:25:54
Editing item Q61637
Sleeping for 9.0 seconds, 2016-12-04 08:26:04
Editing item Q80461
Sleeping for 9.0 seconds, 2016-12-04 08:26:14
Editing item Q80592
Sleeping for 9.0 seconds, 2016-12-04 08:26:24
Editing item Q507755
Sleeping for 8.9 seconds, 2016-12-04 08:26:34
Editing item Q81726
Sleeping for 8.8 seconds, 2016-12-04 08:26:44
# done

…and we’re done. The remaining 12 results of the query were fixed manually: some had two preferred statements – someone had added a newer one and didn’t reset the older statement to normal rank – and some had a more complicated source situation.