Skip to content

Commit

Permalink
refactor: use data source correctly
Browse files Browse the repository at this point in the history
provide correct field names and values
  • Loading branch information
babslgam authored and koeaw committed Mar 19, 2024
1 parent 0e63037 commit b37d59c
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions apis_ontology/scripts/import_zotero_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from apis_core.apis_relations.models import Property
from apis_ontology.models import Expression, Work
from .additional_infos import WORK_TYPES, ZOTERO_CREATORS_MAPPING
from .utils import create_import_name, create_import_date_string, convert_year_only_date
from .utils import create_import_date_string, convert_year_only_date
from .import_helpers import (
create_triple,
create_source,
Expand Down Expand Up @@ -90,18 +90,10 @@ def import_work_collections(zot, coll_id, include_subs=True):
sub_ids.append(d["key"])

# check all required sub collections are present
dt_string = create_import_date_string()
import_name = create_import_name(
[
collection_data["name"],
dt_string,
],
import_source="Zotero",
)

for coll_id in sub_ids:
imported, failed = import_items_from_collection(
zot, coll_id, include_subs=True, import_name=import_name
zot, coll_id, include_subs=True, import_name=collection_data["name"]
)
success.append(imported)
failure.append(failed)
Expand Down Expand Up @@ -300,16 +292,6 @@ def import_items_from_collection(zot, coll_key, include_subs=True, import_name=N
"""
collection_data = get_collection_data(zot, coll_key, include_subs=include_subs)

if not import_name:
dt_string = create_import_date_string()
import_name = create_import_name(
[
collection_data["name"],
dt_string,
],
import_source="Zotero",
)

success, failure = import_items(collection_data["items"], import_name)

return success, failure
Expand All @@ -325,7 +307,7 @@ def import_items(collection_items, import_name):
success = []
failure = []

source, created = create_source(import_name)
source, created = create_source(import_name, "", "", "", "Zotero")
importable, non_importable = get_valid_collection_items(collection_items)

if importable:
Expand Down

0 comments on commit b37d59c

Please sign in to comment.