Skip to content

Commit

Permalink
Merge branch 'main' into prerelease-1-2
Browse files Browse the repository at this point in the history
  • Loading branch information
cmungall committed Mar 2, 2022
2 parents 8db13ab + a8b4dd1 commit c0c9ac2
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 197 deletions.
10 changes: 7 additions & 3 deletions linkml_runtime/utils/metamodelcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from typing import Union, Optional, Tuple
from urllib.parse import urlparse

from ShExJSG.ShExJ import IRIREF, PN_PREFIX
from rdflib import Literal, BNode, URIRef
from rdflib.namespace import is_ncname
from rdflib.term import Identifier as rdflib_Identifier
Expand Down Expand Up @@ -137,9 +136,13 @@ def __init__(self, v: str) -> None:
raise ValueError(f"{v}: is not a valid URI")
super().__init__(v)

# this is more inclusive than the W3C specification
#uri_re = re.compile("^[A-Za-z]\\S*$")
uri_re = re.compile("^\\S+$")

@classmethod
def is_valid(cls, v: str) -> bool:
return v is not None and not URIorCURIE.is_curie(v) and isinstance(v, IRIREF)
return v is not None and not URIorCURIE.is_curie(v) and cls.uri_re.match(v)


class Curie(URIorCURIE):
Expand Down Expand Up @@ -172,7 +175,8 @@ def ns_ln(cls, v: str) -> Optional[Tuple[str, str]]:
@classmethod
def is_valid(cls, v: str) -> bool:
pnln = cls.ns_ln(v)
return pnln is not None and (not pnln[0] or isinstance(pnln[0], PN_PREFIX))
#return pnln is not None and (not pnln[0] or isinstance(pnln[0], PN_PREFIX))
return pnln is not None

# This code was extracted from the termorcurie package of the rdfa
def as_uri(self, nsm: Namespaces) -> Optional[URIRef]:
Expand Down
Loading

0 comments on commit c0c9ac2

Please sign in to comment.