Skip to content

Commit

Permalink
Merge branch 'main' into issue-10
Browse files Browse the repository at this point in the history
  • Loading branch information
glenrobson committed Nov 11, 2022
2 parents 326da5a + fa98eb5 commit e80ff93
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions iiif_prezi3/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ def json(self, **kwargs):

def jsonld(self, **kwargs):
# approach 6- use the pydantic .dict() function to get the dict with pydantic options, add the context at the top and dump to json with modified kwargs
pydantic_args = ["include", "exclude", "by_alias", "encoder"]
excluded_args = ["exclude_unset", "exclude_defaults", "exclude_none", "by_alias"]
pydantic_args = ["include", "exclude", "encoder"]
dict_kwargs = dict([(arg, kwargs[arg]) for arg in kwargs.keys() if arg in pydantic_args])
json_kwargs = dict([(arg, kwargs[arg]) for arg in kwargs.keys() if arg not in pydantic_args])
return json.dumps({"@context": "http://iiif.io/api/presentation/3/context.json", **self.dict(exclude_unset=False, exclude_defaults=False, exclude_none=True, by_alias=True, **dict_kwargs)}, **json_kwargs)

json_kwargs = dict([(arg, kwargs[arg]) for arg in kwargs.keys() if arg not in pydantic_args + excluded_args])
return json.dumps({"@context": "http://iiif.io/api/presentation/3/context.json",
**self.dict(exclude_unset=False, exclude_defaults=False, exclude_none=True, by_alias=True, **dict_kwargs)}, **json_kwargs)

def jsonld_dict(self, **kwargs):
pydantic_args = ["include", "exclude", "by_alias", "encoder"]
pydantic_args = ["include", "exclude", "encoder"]
dict_kwargs = dict([(arg, kwargs[arg]) for arg in kwargs.keys() if arg in pydantic_args])
return {"@context": "http://iiif.io/api/presentation/3/context.json", **self.dict(exclude_unset=False, exclude_defaults=False, exclude_none=True, by_alias=True, **dict_kwargs)}

return {"@context": "http://iiif.io/api/presentation/3/context.json",
**self.dict(exclude_unset=False, exclude_defaults=False, exclude_none=True, by_alias=True, **dict_kwargs)}

0 comments on commit e80ff93

Please sign in to comment.