File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -1003,7 +1003,7 @@ def test_wikidata_no_value_snak(self):
10031003 page = wptools .wikidata (skip = SKIP_FLAG , silent = SILENT_FLAG )
10041004 page .cache = {'wikidata' : wikidata_novalue_snak .cache }
10051005 page ._set_data ('wikidata' )
1006- self .assertEqual (len (page .data ['claims' ]), 1 )
1006+ self .assertEqual (len (page .data ['claims' ]), 2 )
10071007
10081008
10091009class WPToolsToolTestCase (unittest .TestCase ):
Original file line number Diff line number Diff line change @@ -360,21 +360,25 @@ def reduce_claims(query_claims):
360360 for ent in entities :
361361
362362 try :
363- snak = ent .get ('mainsnak' ).get ('datavalue' ).get ('value' )
363+ snak = ent .get ('mainsnak' )
364+ snaktype = snak .get ('snaktype' )
365+ value = snak .get ('datavalue' ).get ('value' )
364366 except AttributeError :
365- continue
367+ claims [ claim ] = []
366368
367369 try :
368- if snak .get ('id' ):
369- val = snak .get ('id' )
370- elif snak .get ('text' ):
371- val = snak .get ('text' )
372- elif snak .get ('time' ):
373- val = snak .get ('time' )
370+ if snaktype != 'value' :
371+ val = snaktype
372+ elif value .get ('id' ):
373+ val = value .get ('id' )
374+ elif value .get ('text' ):
375+ val = value .get ('text' )
376+ elif value .get ('time' ):
377+ val = value .get ('time' )
374378 else :
375- val = snak
379+ val = value
376380 except AttributeError :
377- val = snak
381+ val = value
378382
379383 if not val or not [x for x in val if x ]:
380384 raise ValueError ("%s %s" % (claim , ent ))
You can’t perform that action at this time.
0 commit comments