Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
utnapischtim committed Jun 25, 2024
1 parent df92d80 commit 7df2e51
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
5 changes: 4 additions & 1 deletion invenio_records_lom/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

"""Utilities for creation of LOM-compliant metadata."""

from .metadata import LOMCourseMetadata, LOMMetadata
from .metadata import LOMCourseMetadata, LOMMetadata, LOMRecordData
from .statistics import build_record_unique_id
from .util import (
DotAccessWrapper,
LOMDuplicateRecordError,
check_about_duplicate,
create_record,
get_learningresourcetypedict,
get_oefosdict,
)
Expand All @@ -24,8 +25,10 @@
"get_oefosdict",
"LOMMetadata",
"LOMCourseMetadata",
"LOMRecordData",
"make_lom_vcard",
"build_record_unique_id",
"check_about_duplicate",
"create_record",
"LOMDuplicateRecordError",
)
19 changes: 15 additions & 4 deletions invenio_records_lom/utils/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)


class LOMRecordData:
class LOMRecordData(dict):
"""LOM record data."""

def __init__(
Expand All @@ -35,12 +35,23 @@ def __init__(
**kwargs: dict,
) -> None:
"""Construct."""
self.update(**kwargs)
self.resource_type = resource_type
self.pids = pids
self.metadata = (
metadata if not isinstance(metadata, LOMMetadata) else LOMMetadata(metadata)
metadata
if isinstance(metadata, LOMMetadata)
else LOMMetadata(metadata, overwritable=True)
)
self.kwargs = kwargs

@property
def json(self) -> dict:
"""json"""
return {
"pids": self.pids,
"metadata": self.metadata.json,
"resource_type": self.resource_type,
}


class BaseLOMMetadata:
Expand Down Expand Up @@ -213,7 +224,7 @@ def create(
def append_course(self, course: LOMCourseMetadata) -> None:
"""Append course."""
# pylint: disable-next=unsupported-membership-test
if "courses" not in self.record["metadata"]:
if "courses" not in self.record:
self.record["courses"] = []

courses = self.record["courses"]
Expand Down

0 comments on commit 7df2e51

Please sign in to comment.