From 82249915dfc19bee14034da72087875b7a2b0c07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Katja=20Ber=C4=8Di=C4=8D?= Date: Thu, 30 Nov 2023 10:27:17 -0500 Subject: [PATCH] Better import status messages --- web/slurper/management/commands/import_wikidata.py | 9 +++++++-- web/slurper/source_wikidata.py | 3 +-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/web/slurper/management/commands/import_wikidata.py b/web/slurper/management/commands/import_wikidata.py index 1902a16..f3fc650 100644 --- a/web/slurper/management/commands/import_wikidata.py +++ b/web/slurper/management/commands/import_wikidata.py @@ -4,7 +4,12 @@ class Command(BaseCommand): def handle(self, *args, **options): - for slurper in source_wikidata.SLURPERS: + print("", end="") + n = len(source_wikidata.SLURPERS) + for i, slurper in enumerate(source_wikidata.SLURPERS): + print(f"\r query {i}/{n}: {slurper.source.label}".ljust(50), end="") slurper.save_items() - for slurper in source_wikidata.SLURPERS: + for i, slurper in enumerate(source_wikidata.SLURPERS): + print(f"\r links {i}/{n}: {slurper.source.label}".ljust(50), end="") slurper.save_links() + print("\r done.".ljust(60)) diff --git a/web/slurper/source_wikidata.py b/web/slurper/source_wikidata.py index f843282..2a780c8 100644 --- a/web/slurper/source_wikidata.py +++ b/web/slurper/source_wikidata.py @@ -167,11 +167,10 @@ def __init__(self, source, query): self.query = ( """ SELECT - DISTINCT ?item ?itemLabel ?itemDescription ?image + DISTINCT ?item ?itemLabel ?itemDescription ?image ?art """ + self._sparql_source_vars_select() + """ - ?art WHERE { """ + query