Skip to content

Commit c09e77d

Browse files
lihaohong6LeMyst
andauthored
fix: let generate_entity_instances preserve login information (#912)
* fix: let generate_entity_instances preserve login information Fix #911 * Instantiate WikibaseIntegrator with is_bot argument Moved WikibaseIntegrator instantiation inside the loop and added the is_bot argument from kwargs. This allows for more flexible initialization based on provided keyword arguments. --------- Co-authored-by: Myst <1592048+LeMyst@users.noreply.github.com>
1 parent e77265e commit c09e77d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

wikibaseintegrator/wbi_helpers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,9 +739,9 @@ def generate_entity_instances(entities: str | list[str], allow_anonymous: bool =
739739
reply = mediawiki_api_call_helper(data=params, allow_anonymous=allow_anonymous, **kwargs)
740740

741741
entity_instances = []
742+
from wikibaseintegrator import WikibaseIntegrator
742743
for qid, v in reply['entities'].items():
743-
from wikibaseintegrator import WikibaseIntegrator
744-
wbi = WikibaseIntegrator()
744+
wbi = WikibaseIntegrator(is_bot=kwargs.get('is_bot', False), login=kwargs.get('login', None))
745745
f = [x for x in BaseEntity.__subclasses__() if x.ETYPE == v['type']][0]
746746
ii = f(api=wbi).from_json(v)
747747
entity_instances.append((qid, ii))
@@ -1034,3 +1034,4 @@ def download_entity_ttl(entity: str, wikibase_url: str | None = None, user_agent
10341034
# # It's really the good way to solve this?
10351035
# from wikibaseintegrator import wikibaseintegrator
10361036
# return wikibaseintegrator.wbi_helpers
1037+

0 commit comments

Comments
 (0)