Skip to content

Commit

Permalink
Remove pyld and use custom rdflib
Browse files Browse the repository at this point in the history
  • Loading branch information
avillar committed Jul 26, 2023
1 parent 53bc941 commit 4c4dbaa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
11 changes: 4 additions & 7 deletions ogc/bblocks/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
import json
import os
import shutil
from json import JSONDecodeError
from pathlib import Path
from typing import Any
from urllib.parse import urlsplit
from urllib.request import urlopen

import jsonschema
import pyld.jsonld
import requests
from jsonschema.validators import validator_for
from ogc.na.annotate_schema import SchemaResolver
from ogc.na.util import validate as shacl_validate, load_yaml, is_url
from pyld.jsonld import JsonLdError
from pyparsing import ParseBaseException
from rdflib import Graph
from yaml import MarkedYAMLError
Expand Down Expand Up @@ -121,8 +120,7 @@ def validate_inner():
'@context': new_context,
'@graph': json_doc,
}
jsonld_expanded = json.dumps(pyld.jsonld.expand(jsonld_uplifted, {'base': base_uri}))
graph = Graph().parse(data=jsonld_expanded, format='json-ld', base=base_uri)
graph = Graph().parse(data=json.dumps(jsonld_uplifted), format='json-ld', base=base_uri)

if jsonld_url:
if isinstance(jsonld_uplifted['@context'], list):
Expand All @@ -137,10 +135,9 @@ def validate_inner():
report.add_info('Files', f'Output JSON-LD {jsonld_fn.name} created')

elif output_filename.suffix == '.jsonld':
jsonld_expanded = json.dumps(pyld.jsonld.expand(json_doc, {'base': base_uri}))
graph = Graph().parse(data=jsonld_expanded, format='json-ld', base=base_uri)
graph = Graph().parse(data=json_doc, format='json-ld', base=base_uri)

except JsonLdError as e:
except JSONDecodeError as e:
report.add_error('JSON-LD', str(e))
return

Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ pyyaml~=6.0
Mako~=1.2.4
jsonschema==4.17.3
ogc-na>=0.3.2
rdflib~=6.3.2
rdflib @ git+https://github.com/avillar/rdflib.git@main#egg=rdflib
requests~=2.31.0
pyld~=2.0.3

pyparsing~=3.0.9

0 comments on commit 4c4dbaa

Please sign in to comment.