albertvillanova / WikidataBot

Wikidata bot
http://www.wikidata.org/wiki/User:AVMbot
0 stars 0 forks source link

[models] Statement instantiation crashes with TypeError: 'SiteLink' object is not subscriptable #43

Closed albertvillanova closed 4 years ago

albertvillanova commented 4 years ago
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~\projects\wikidata\WikidataBot\scripts\transfer_infotable.py in <module>
    870         positions = extract_positions(infotable_params)
    871         logger.info(f"Positions: {positions}")
--> 872         position_statements = create_position_statements(positions)
    873         if position_statements:
    874             # Get item

~\projects\wikidata\WikidataBot\scripts\transfer_infotable.py in create_position_statements(positions)
    743     # Create statements
    744     statements = [Statement(claim=position_claim, qualifiers=qualifiers, sources=sources)
--> 745                   for position_claim, qualifiers in statements]
    746     return statements
    747

~\projects\wikidata\WikidataBot\scripts\transfer_infotable.py in <listcomp>(.0)
    743     # Create statements
    744     statements = [Statement(claim=position_claim, qualifiers=qualifiers, sources=sources)
--> 745                   for position_claim, qualifiers in statements]
    746     return statements
    747

~\projects\wikidata\WikidataBot\wikidatabot\models.py in __init__(self, claim, rank, qualifiers, sources)
    161         self.sources = sources if sources else []  # TODO: better a dict or a Container
    162         # TODO: refactorize to repo
--> 163         self._statement = copy.deepcopy(claim._claim)
    164         self._set_rank(rank)
    165         if qualifiers is not None:

~\AppData\Local\Continuum\anaconda3\envs\wikidata\lib\copy.py in deepcopy(x, memo, _nil)
    178                     y = x
    179                 else:
--> 180                     y = _reconstruct(x, memo, *rv)
    181
    182     # If is its own copy, don't memoize.

~\AppData\Local\Continuum\anaconda3\envs\wikidata\lib\copy.py in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy)
    278     if state is not None:
    279         if deep:
--> 280             state = deepcopy(state, memo)
    281         if hasattr(y, '__setstate__'):
    282             y.__setstate__(state)

~\AppData\Local\Continuum\anaconda3\envs\wikidata\lib\copy.py in deepcopy(x, memo, _nil)
    148     copier = _deepcopy_dispatch.get(cls)
    149     if copier:
--> 150         y = copier(x, memo)
    151     else:
    152         try:

~\AppData\Local\Continuum\anaconda3\envs\wikidata\lib\copy.py in _deepcopy_dict(x, memo, deepcopy)
    238     memo[id(x)] = y
    239     for key, value in x.items():
--> 240         y[deepcopy(key, memo)] = deepcopy(value, memo)
    241     return y
    242 d[dict] = _deepcopy_dict

~\AppData\Local\Continuum\anaconda3\envs\wikidata\lib\copy.py in deepcopy(x, memo, _nil)
    178                     y = x
    179                 else:
--> 180                     y = _reconstruct(x, memo, *rv)
    181
    182     # If is its own copy, don't memoize.

~\AppData\Local\Continuum\anaconda3\envs\wikidata\lib\copy.py in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy)
    278     if state is not None:
    279         if deep:
--> 280             state = deepcopy(state, memo)
    281         if hasattr(y, '__setstate__'):
    282             y.__setstate__(state)

~\AppData\Local\Continuum\anaconda3\envs\wikidata\lib\copy.py in deepcopy(x, memo, _nil)
    148     copier = _deepcopy_dispatch.get(cls)
    149     if copier:
--> 150         y = copier(x, memo)
    151     else:
    152         try:

~\AppData\Local\Continuum\anaconda3\envs\wikidata\lib\copy.py in _deepcopy_dict(x, memo, deepcopy)
    238     memo[id(x)] = y
    239     for key, value in x.items():
--> 240         y[deepcopy(key, memo)] = deepcopy(value, memo)
    241     return y
    242 d[dict] = _deepcopy_dict

~\AppData\Local\Continuum\anaconda3\envs\wikidata\lib\copy.py in deepcopy(x, memo, _nil)
    178                     y = x
    179                 else:
--> 180                     y = _reconstruct(x, memo, *rv)
    181
    182     # If is its own copy, don't memoize.

~\AppData\Local\Continuum\anaconda3\envs\wikidata\lib\copy.py in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy)
    305                 key = deepcopy(key, memo)
    306                 value = deepcopy(value, memo)
--> 307                 y[key] = value
    308         else:
    309             for key, value in dictiter:

c:\users\avi14827\projects\wikidata\pywikibot\pywikibot\page.py in __setitem__(self, key, val)
   6496             val = SiteLink(val, key)
   6497         else:
-> 6498             val = SiteLink.fromJSON(val, self.repo)
   6499         if isinstance(key, pywikibot.site.BaseSite):
   6500             key = key.dbName()

c:\users\avi14827\projects\wikidata\pywikibot\pywikibot\page.py in fromJSON(cls, data, site)
   6437         @rtype: SiteLink
   6438         """
-> 6439         sl = cls(data['title'], data['site'])
   6440         repo = site or sl.site.data_repository()
   6441         for badge in data.get('badges', []):

TypeError: 'SiteLink' object is not subscriptable
albertvillanova commented 4 years ago

Why is there a SiteLink object?

albertvillanova commented 4 years ago

Fixed by: 26e47c9eb23566289b335baf4ed986d367a78e87