Skip to content

Commit

Permalink
update pyld and rearrange import order to work around pyld import pro…
Browse files Browse the repository at this point in the history
…blems (#46)

update pyld and rearrange import order
  • Loading branch information
kimdhamilton committed Oct 23, 2017
1 parent ab4a330 commit dbf287d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 27 deletions.
26 changes: 6 additions & 20 deletions cert_schema/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
SECURITY_CONTEXT_URL = 'https://w3id.org/security/v1'
OPEN_BADGES_V2_CONTEXT = 'https://openbadgespec.org/v2/context.json'
OPEN_BADGES_V2_CANONICAL_CONTEXT = 'https://w3id.org/openbadges/v2'
BLOCKCERTS_V2_ALPHA_CONTEXT = 'https://w3id.org/blockcerts/schema/2.0-alpha/context.json'
BLOCKCERTS_V2_ALPHA_SCHEMA = 'https://w3id.org/blockcerts/schema/2.0-alpha/schema.json'
BLOCKCERTS_V2_CONTEXT = 'https://w3id.org/blockcerts/schema/2.0/context.json'
BLOCKCERTS_V2_SCHEMA = 'https://w3id.org/blockcerts/schema/2.0/schema.json'
BLOCKCERTS_V2_CANONICAL_CONTEXT = 'https://w3id.org/blockcerts/v2'
BLOCKCERTS_VOCAB = 'https://w3id.org/blockcerts/v2#'

from cert_schema.jsonld_helpers import jsonld_document_loader, normalize_jsonld
from cert_schema.schema_validator import validate_unsigned_v1_2, validate_v1_2, validate_v2

class BlockcertValidationError(Exception):
pass


class InvalidUrlError(Exception):
pass

from cert_schema.jsonld_helpers import BLOCKCERTS_V2_ALPHA_CONTEXT, BLOCKCERTS_V2_ALPHA_SCHEMA, BLOCKCERTS_V2_CONTEXT,\
BLOCKCERTS_V2_SCHEMA, BLOCKCERTS_V2_CANONICAL_CONTEXT, BLOCKCERTS_VOCAB, JSONLD_OPTIONS, \
OPEN_BADGES_V2_CANONICAL_CONTEXT, OPEN_BADGES_V2_CONTEXT, SECURITY_CONTEXT_URL

from cert_schema.jsonld_helpers import JSONLD_OPTIONS
from cert_schema.jsonld_helpers import jsonld_document_loader
from cert_schema.jsonld_helpers import normalize_jsonld
from cert_schema.schema_validator import validate_unsigned_v1_2, validate_v1_2, validate_v2
from cert_schema.errors import *
6 changes: 6 additions & 0 deletions cert_schema/errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class BlockcertValidationError(Exception):
pass


class InvalidUrlError(Exception):
pass
19 changes: 15 additions & 4 deletions cert_schema/jsonld_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,35 @@
from copy import deepcopy

import requests
from pyld import jsonld
from pyld.jsonld import JsonLdProcessor
import validators

from cert_schema.errors import *

try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen

from pyld import jsonld
from pyld.jsonld import JsonLdProcessor

from cert_schema import *
SECURITY_CONTEXT_URL = 'https://w3id.org/security/v1'
OPEN_BADGES_V2_CONTEXT = 'https://openbadgespec.org/v2/context.json'
OPEN_BADGES_V2_CANONICAL_CONTEXT = 'https://w3id.org/openbadges/v2'
BLOCKCERTS_V2_ALPHA_CONTEXT = 'https://w3id.org/blockcerts/schema/2.0-alpha/context.json'
BLOCKCERTS_V2_ALPHA_SCHEMA = 'https://w3id.org/blockcerts/schema/2.0-alpha/schema.json'
BLOCKCERTS_V2_CONTEXT = 'https://w3id.org/blockcerts/schema/2.0/context.json'
BLOCKCERTS_V2_SCHEMA = 'https://w3id.org/blockcerts/schema/2.0/schema.json'
BLOCKCERTS_V2_CANONICAL_CONTEXT = 'https://w3id.org/blockcerts/v2'
BLOCKCERTS_VOCAB = 'https://w3id.org/blockcerts/v2#'
JSONLD_OPTIONS = {'algorithm': 'URDNA2015', 'format': 'application/nquads'}


# Nonstandard contexts
BLOCKCERTS_V2_ALPHA_CONTEXT_2 = 'https://www.blockcerts.org/schema/2.0-alpha/context.json'
BLOCKCERTS_V2_CONTEXT_2 = 'https://www.blockcerts.org/schema/2.0/context.json'

FALLBACK_VOCAB = 'http://fallback.org/'
JSONLD_OPTIONS = {'algorithm': 'URDNA2015', 'format': 'application/nquads'}
FALLBACK_CONTEXT = {'@vocab': FALLBACK_VOCAB}

BASE_DIR = os.path.abspath(os.path.dirname(__file__))
Expand Down
2 changes: 1 addition & 1 deletion cert_schema/schema_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import jsonschema
import os

from cert_schema import BlockcertValidationError
from cert_schema.errors import BlockcertValidationError

V2_SCHEMA_LOCAL_PATH = '2.0/schema.json'

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
jsonschema>=2.6.0
pyld>=0.7.3
requests>=2.18.4
pyld>=0.8.0
tox>=2.7.0
validators>=0.12.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name='cert-schema',
version='2.1.2',
version='2.1.3',
description='Blockchain certificates JSON-LD context and JSON schemas',
author='info@blockcerts.org',
url='https://github.com/blockchain-certificates/cert-schema',
Expand Down

0 comments on commit dbf287d

Please sign in to comment.