Skip to content

Commit

Permalink
[#56] dataset_schema -> dataset_type
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed May 23, 2024
1 parent 5375232 commit 9b0abce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions ckanext/dcat/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@

class RDFProcessor(object):

def __init__(self, profiles=None, dataset_schema='dataset', compatibility_mode=False):
def __init__(self, profiles=None, dataset_type='dataset', compatibility_mode=False):
'''
Creates a parser or serializer instance
You can optionally pass a list of profiles to be used.
A scheming dataset type can be provided, in which case the scheming schema
will be loaded by the base profile so it can be used by other profiles.
In compatibility mode, some fields are modified to maintain
compatibility with previous versions of the ckanext-dcat parsers
(eg adding the `dcat_` prefix or storing comma separated lists instead
Expand All @@ -56,7 +59,7 @@ def __init__(self, profiles=None, dataset_schema='dataset', compatibility_mode=F
raise RDFProfileException(
'No suitable RDF profiles could be loaded')

self.dataset_schema = dataset_schema
self.dataset_type = dataset_type

if not compatibility_mode:
compatibility_mode = p.toolkit.asbool(
Expand Down Expand Up @@ -181,7 +184,7 @@ def datasets(self):
for profile_class in self._profiles:
profile = profile_class(
self.g,
dataset_schema=self.dataset_schema,
dataset_type=self.dataset_type,
compatibility_mode=self.compatibility_mode
)
profile.parse_dataset(dataset_dict, dataset_ref)
Expand Down
9 changes: 6 additions & 3 deletions ckanext/dcat/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,14 @@ class RDFProfile(object):

_dataset_schema = None

def __init__(self, graph, dataset_schema='dataset', compatibility_mode=False):
def __init__(self, graph, dataset_type='dataset', compatibility_mode=False):
'''Class constructor
Graph is an rdflib.Graph instance.
A scheming dataset type can be provided, in which case the scheming schema
will be loaded so it can be used by profiles.
In compatibility mode, some fields are modified to maintain
compatibility with previous versions of the ckanext-dcat parsers
(eg adding the `dcat_` prefix or storing comma separated lists instead
Expand All @@ -148,9 +151,9 @@ def __init__(self, graph, dataset_schema='dataset', compatibility_mode=False):
try:
schema_show = toolkit.get_action("scheming_dataset_schema_show")
try:
schema = schema_show({}, {"type": dataset_schema})
schema = schema_show({}, {"type": dataset_type})
except toolkit.ObjectNotFound:
raise toolkit.ObjectNotFound(f"Unknown dataset schema: {dataset_schema}")
raise toolkit.ObjectNotFound(f"Unknown dataset schema: {dataset_type}")

self._dataset_schema = schema

Expand Down

0 comments on commit 9b0abce

Please sign in to comment.