Skip to content

Commit

Permalink
chore: merge dublette class into one class (DEV-1831) #322
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum committed Mar 10, 2023
1 parent 512de36 commit e5cddf5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/dsp_tools/models/ontology.py
Expand Up @@ -7,23 +7,12 @@
from pystrict import strict

from dsp_tools.models.connection import Connection
from dsp_tools.models.helpers import Actions, BaseError, Context, DateTimeStamp, OntoIri, WithId
from dsp_tools.models.helpers import Actions, BaseError, Context, DateTimeStamp, WithId
from dsp_tools.models.model import Model
from dsp_tools.models.project import Project
from dsp_tools.models.propertyclass import PropertyClass
from dsp_tools.models.resourceclass import ResourceClass


class SetEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, set):
return list(obj)
elif isinstance(obj, Context):
return obj.toJsonObj()
elif isinstance(obj, OntoIri):
return {"iri": obj.iri, "hashtag": obj.hashtag}
return json.JSONEncoder.default(self, obj)

from dsp_tools.models.set_encoder import SetEncoder

"""
This model implements the handling of ontologies. It is to note that ResourceClasses, PropertyClasses
Expand Down
6 changes: 6 additions & 0 deletions src/dsp_tools/models/set_encoder.py
@@ -1,8 +1,14 @@
import json

from dsp_tools.models.helpers import Context, OntoIri


class SetEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, set):
return list(obj)
elif isinstance(obj, Context):
return obj.toJsonObj()
elif isinstance(obj, OntoIri):
return {"iri": obj.iri, "hashtag": obj.hashtag}
return json.JSONEncoder.default(self, obj)

0 comments on commit e5cddf5

Please sign in to comment.