jsonschema: remove optional deps (#46041)
This commit is contained in:
parent
497e19f0e3
commit
a60d1084b1
173
lib/spack/external/_vendoring/jsonschema/_format.py
vendored
173
lib/spack/external/_vendoring/jsonschema/_format.py
vendored
@ -231,96 +231,6 @@ def is_host_name(instance):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
# The built-in `idna` codec only implements RFC 3890, so we go elsewhere.
|
|
||||||
import idna
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
@_checks_drafts(draft7="idn-hostname", raises=idna.IDNAError)
|
|
||||||
def is_idn_host_name(instance):
|
|
||||||
if not isinstance(instance, str_types):
|
|
||||||
return True
|
|
||||||
idna.encode(instance)
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
import rfc3987
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
from rfc3986_validator import validate_rfc3986
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
@_checks_drafts(name="uri")
|
|
||||||
def is_uri(instance):
|
|
||||||
if not isinstance(instance, str_types):
|
|
||||||
return True
|
|
||||||
return validate_rfc3986(instance, rule="URI")
|
|
||||||
|
|
||||||
@_checks_drafts(
|
|
||||||
draft6="uri-reference",
|
|
||||||
draft7="uri-reference",
|
|
||||||
raises=ValueError,
|
|
||||||
)
|
|
||||||
def is_uri_reference(instance):
|
|
||||||
if not isinstance(instance, str_types):
|
|
||||||
return True
|
|
||||||
return validate_rfc3986(instance, rule="URI_reference")
|
|
||||||
|
|
||||||
else:
|
|
||||||
@_checks_drafts(draft7="iri", raises=ValueError)
|
|
||||||
def is_iri(instance):
|
|
||||||
if not isinstance(instance, str_types):
|
|
||||||
return True
|
|
||||||
return rfc3987.parse(instance, rule="IRI")
|
|
||||||
|
|
||||||
@_checks_drafts(draft7="iri-reference", raises=ValueError)
|
|
||||||
def is_iri_reference(instance):
|
|
||||||
if not isinstance(instance, str_types):
|
|
||||||
return True
|
|
||||||
return rfc3987.parse(instance, rule="IRI_reference")
|
|
||||||
|
|
||||||
@_checks_drafts(name="uri", raises=ValueError)
|
|
||||||
def is_uri(instance):
|
|
||||||
if not isinstance(instance, str_types):
|
|
||||||
return True
|
|
||||||
return rfc3987.parse(instance, rule="URI")
|
|
||||||
|
|
||||||
@_checks_drafts(
|
|
||||||
draft6="uri-reference",
|
|
||||||
draft7="uri-reference",
|
|
||||||
raises=ValueError,
|
|
||||||
)
|
|
||||||
def is_uri_reference(instance):
|
|
||||||
if not isinstance(instance, str_types):
|
|
||||||
return True
|
|
||||||
return rfc3987.parse(instance, rule="URI_reference")
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
from strict_rfc3339 import validate_rfc3339
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
from rfc3339_validator import validate_rfc3339
|
|
||||||
except ImportError:
|
|
||||||
validate_rfc3339 = None
|
|
||||||
|
|
||||||
if validate_rfc3339:
|
|
||||||
@_checks_drafts(name="date-time")
|
|
||||||
def is_datetime(instance):
|
|
||||||
if not isinstance(instance, str_types):
|
|
||||||
return True
|
|
||||||
return validate_rfc3339(instance)
|
|
||||||
|
|
||||||
@_checks_drafts(draft7="time")
|
|
||||||
def is_time(instance):
|
|
||||||
if not isinstance(instance, str_types):
|
|
||||||
return True
|
|
||||||
return is_datetime("1970-01-01T" + instance)
|
|
||||||
|
|
||||||
|
|
||||||
@_checks_drafts(name="regex", raises=re.error)
|
@_checks_drafts(name="regex", raises=re.error)
|
||||||
def is_regex(instance):
|
def is_regex(instance):
|
||||||
if not isinstance(instance, str_types):
|
if not isinstance(instance, str_types):
|
||||||
@ -340,86 +250,3 @@ def is_draft3_time(instance):
|
|||||||
if not isinstance(instance, str_types):
|
if not isinstance(instance, str_types):
|
||||||
return True
|
return True
|
||||||
return datetime.datetime.strptime(instance, "%H:%M:%S")
|
return datetime.datetime.strptime(instance, "%H:%M:%S")
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
import webcolors
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
def is_css_color_code(instance):
|
|
||||||
return webcolors.normalize_hex(instance)
|
|
||||||
|
|
||||||
@_checks_drafts(draft3="color", raises=(ValueError, TypeError))
|
|
||||||
def is_css21_color(instance):
|
|
||||||
if (
|
|
||||||
not isinstance(instance, str_types) or
|
|
||||||
instance.lower() in webcolors.css21_names_to_hex
|
|
||||||
):
|
|
||||||
return True
|
|
||||||
return is_css_color_code(instance)
|
|
||||||
|
|
||||||
def is_css3_color(instance):
|
|
||||||
if instance.lower() in webcolors.css3_names_to_hex:
|
|
||||||
return True
|
|
||||||
return is_css_color_code(instance)
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
import jsonpointer
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
@_checks_drafts(
|
|
||||||
draft6="json-pointer",
|
|
||||||
draft7="json-pointer",
|
|
||||||
raises=jsonpointer.JsonPointerException,
|
|
||||||
)
|
|
||||||
def is_json_pointer(instance):
|
|
||||||
if not isinstance(instance, str_types):
|
|
||||||
return True
|
|
||||||
return jsonpointer.JsonPointer(instance)
|
|
||||||
|
|
||||||
# TODO: I don't want to maintain this, so it
|
|
||||||
# needs to go either into jsonpointer (pending
|
|
||||||
# https://github.com/stefankoegl/python-json-pointer/issues/34) or
|
|
||||||
# into a new external library.
|
|
||||||
@_checks_drafts(
|
|
||||||
draft7="relative-json-pointer",
|
|
||||||
raises=jsonpointer.JsonPointerException,
|
|
||||||
)
|
|
||||||
def is_relative_json_pointer(instance):
|
|
||||||
# Definition taken from:
|
|
||||||
# https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01#section-3
|
|
||||||
if not isinstance(instance, str_types):
|
|
||||||
return True
|
|
||||||
non_negative_integer, rest = [], ""
|
|
||||||
for i, character in enumerate(instance):
|
|
||||||
if character.isdigit():
|
|
||||||
non_negative_integer.append(character)
|
|
||||||
continue
|
|
||||||
|
|
||||||
if not non_negative_integer:
|
|
||||||
return False
|
|
||||||
|
|
||||||
rest = instance[i:]
|
|
||||||
break
|
|
||||||
return (rest == "#") or jsonpointer.JsonPointer(rest)
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
import uritemplate.exceptions
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
@_checks_drafts(
|
|
||||||
draft6="uri-template",
|
|
||||||
draft7="uri-template",
|
|
||||||
raises=uritemplate.exceptions.InvalidTemplate,
|
|
||||||
)
|
|
||||||
def is_uri_template(
|
|
||||||
instance,
|
|
||||||
template_validator=uritemplate.Validator().force_balanced_braces(),
|
|
||||||
):
|
|
||||||
template = uritemplate.URITemplate(instance)
|
|
||||||
return template_validator.validate(template)
|
|
||||||
|
188
lib/spack/external/patches/jsonschema.patch
vendored
188
lib/spack/external/patches/jsonschema.patch
vendored
@ -13,3 +13,191 @@ index 6b630cdfbb..1791fe7fbf 100644
|
|||||||
-__version__ = metadata.version("jsonschema")
|
-__version__ = metadata.version("jsonschema")
|
||||||
+
|
+
|
||||||
+__version__ = "3.2.0"
|
+__version__ = "3.2.0"
|
||||||
|
diff --git a/lib/spack/external/_vendoring/jsonschema/_format.py b/lib/spack/external/_vendoring/jsonschema/_format.py
|
||||||
|
index 281a7cfcff..29061e3661 100644
|
||||||
|
--- a/lib/spack/external/_vendoring/jsonschema/_format.py
|
||||||
|
+++ b/lib/spack/external/_vendoring/jsonschema/_format.py
|
||||||
|
@@ -231,96 +231,6 @@ def is_host_name(instance):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
-try:
|
||||||
|
- # The built-in `idna` codec only implements RFC 3890, so we go elsewhere.
|
||||||
|
- import idna
|
||||||
|
-except ImportError:
|
||||||
|
- pass
|
||||||
|
-else:
|
||||||
|
- @_checks_drafts(draft7="idn-hostname", raises=idna.IDNAError)
|
||||||
|
- def is_idn_host_name(instance):
|
||||||
|
- if not isinstance(instance, str_types):
|
||||||
|
- return True
|
||||||
|
- idna.encode(instance)
|
||||||
|
- return True
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-try:
|
||||||
|
- import rfc3987
|
||||||
|
-except ImportError:
|
||||||
|
- try:
|
||||||
|
- from rfc3986_validator import validate_rfc3986
|
||||||
|
- except ImportError:
|
||||||
|
- pass
|
||||||
|
- else:
|
||||||
|
- @_checks_drafts(name="uri")
|
||||||
|
- def is_uri(instance):
|
||||||
|
- if not isinstance(instance, str_types):
|
||||||
|
- return True
|
||||||
|
- return validate_rfc3986(instance, rule="URI")
|
||||||
|
-
|
||||||
|
- @_checks_drafts(
|
||||||
|
- draft6="uri-reference",
|
||||||
|
- draft7="uri-reference",
|
||||||
|
- raises=ValueError,
|
||||||
|
- )
|
||||||
|
- def is_uri_reference(instance):
|
||||||
|
- if not isinstance(instance, str_types):
|
||||||
|
- return True
|
||||||
|
- return validate_rfc3986(instance, rule="URI_reference")
|
||||||
|
-
|
||||||
|
-else:
|
||||||
|
- @_checks_drafts(draft7="iri", raises=ValueError)
|
||||||
|
- def is_iri(instance):
|
||||||
|
- if not isinstance(instance, str_types):
|
||||||
|
- return True
|
||||||
|
- return rfc3987.parse(instance, rule="IRI")
|
||||||
|
-
|
||||||
|
- @_checks_drafts(draft7="iri-reference", raises=ValueError)
|
||||||
|
- def is_iri_reference(instance):
|
||||||
|
- if not isinstance(instance, str_types):
|
||||||
|
- return True
|
||||||
|
- return rfc3987.parse(instance, rule="IRI_reference")
|
||||||
|
-
|
||||||
|
- @_checks_drafts(name="uri", raises=ValueError)
|
||||||
|
- def is_uri(instance):
|
||||||
|
- if not isinstance(instance, str_types):
|
||||||
|
- return True
|
||||||
|
- return rfc3987.parse(instance, rule="URI")
|
||||||
|
-
|
||||||
|
- @_checks_drafts(
|
||||||
|
- draft6="uri-reference",
|
||||||
|
- draft7="uri-reference",
|
||||||
|
- raises=ValueError,
|
||||||
|
- )
|
||||||
|
- def is_uri_reference(instance):
|
||||||
|
- if not isinstance(instance, str_types):
|
||||||
|
- return True
|
||||||
|
- return rfc3987.parse(instance, rule="URI_reference")
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-try:
|
||||||
|
- from strict_rfc3339 import validate_rfc3339
|
||||||
|
-except ImportError:
|
||||||
|
- try:
|
||||||
|
- from rfc3339_validator import validate_rfc3339
|
||||||
|
- except ImportError:
|
||||||
|
- validate_rfc3339 = None
|
||||||
|
-
|
||||||
|
-if validate_rfc3339:
|
||||||
|
- @_checks_drafts(name="date-time")
|
||||||
|
- def is_datetime(instance):
|
||||||
|
- if not isinstance(instance, str_types):
|
||||||
|
- return True
|
||||||
|
- return validate_rfc3339(instance)
|
||||||
|
-
|
||||||
|
- @_checks_drafts(draft7="time")
|
||||||
|
- def is_time(instance):
|
||||||
|
- if not isinstance(instance, str_types):
|
||||||
|
- return True
|
||||||
|
- return is_datetime("1970-01-01T" + instance)
|
||||||
|
-
|
||||||
|
-
|
||||||
|
@_checks_drafts(name="regex", raises=re.error)
|
||||||
|
def is_regex(instance):
|
||||||
|
if not isinstance(instance, str_types):
|
||||||
|
@@ -340,86 +250,3 @@ def is_draft3_time(instance):
|
||||||
|
if not isinstance(instance, str_types):
|
||||||
|
return True
|
||||||
|
return datetime.datetime.strptime(instance, "%H:%M:%S")
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-try:
|
||||||
|
- import webcolors
|
||||||
|
-except ImportError:
|
||||||
|
- pass
|
||||||
|
-else:
|
||||||
|
- def is_css_color_code(instance):
|
||||||
|
- return webcolors.normalize_hex(instance)
|
||||||
|
-
|
||||||
|
- @_checks_drafts(draft3="color", raises=(ValueError, TypeError))
|
||||||
|
- def is_css21_color(instance):
|
||||||
|
- if (
|
||||||
|
- not isinstance(instance, str_types) or
|
||||||
|
- instance.lower() in webcolors.css21_names_to_hex
|
||||||
|
- ):
|
||||||
|
- return True
|
||||||
|
- return is_css_color_code(instance)
|
||||||
|
-
|
||||||
|
- def is_css3_color(instance):
|
||||||
|
- if instance.lower() in webcolors.css3_names_to_hex:
|
||||||
|
- return True
|
||||||
|
- return is_css_color_code(instance)
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-try:
|
||||||
|
- import jsonpointer
|
||||||
|
-except ImportError:
|
||||||
|
- pass
|
||||||
|
-else:
|
||||||
|
- @_checks_drafts(
|
||||||
|
- draft6="json-pointer",
|
||||||
|
- draft7="json-pointer",
|
||||||
|
- raises=jsonpointer.JsonPointerException,
|
||||||
|
- )
|
||||||
|
- def is_json_pointer(instance):
|
||||||
|
- if not isinstance(instance, str_types):
|
||||||
|
- return True
|
||||||
|
- return jsonpointer.JsonPointer(instance)
|
||||||
|
-
|
||||||
|
- # TODO: I don't want to maintain this, so it
|
||||||
|
- # needs to go either into jsonpointer (pending
|
||||||
|
- # https://github.com/stefankoegl/python-json-pointer/issues/34) or
|
||||||
|
- # into a new external library.
|
||||||
|
- @_checks_drafts(
|
||||||
|
- draft7="relative-json-pointer",
|
||||||
|
- raises=jsonpointer.JsonPointerException,
|
||||||
|
- )
|
||||||
|
- def is_relative_json_pointer(instance):
|
||||||
|
- # Definition taken from:
|
||||||
|
- # https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01#section-3
|
||||||
|
- if not isinstance(instance, str_types):
|
||||||
|
- return True
|
||||||
|
- non_negative_integer, rest = [], ""
|
||||||
|
- for i, character in enumerate(instance):
|
||||||
|
- if character.isdigit():
|
||||||
|
- non_negative_integer.append(character)
|
||||||
|
- continue
|
||||||
|
-
|
||||||
|
- if not non_negative_integer:
|
||||||
|
- return False
|
||||||
|
-
|
||||||
|
- rest = instance[i:]
|
||||||
|
- break
|
||||||
|
- return (rest == "#") or jsonpointer.JsonPointer(rest)
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-try:
|
||||||
|
- import uritemplate.exceptions
|
||||||
|
-except ImportError:
|
||||||
|
- pass
|
||||||
|
-else:
|
||||||
|
- @_checks_drafts(
|
||||||
|
- draft6="uri-template",
|
||||||
|
- draft7="uri-template",
|
||||||
|
- raises=uritemplate.exceptions.InvalidTemplate,
|
||||||
|
- )
|
||||||
|
- def is_uri_template(
|
||||||
|
- instance,
|
||||||
|
- template_validator=uritemplate.Validator().force_balanced_braces(),
|
||||||
|
- ):
|
||||||
|
- template = uritemplate.URITemplate(instance)
|
||||||
|
- return template_validator.validate(template)
|
||||||
|
Loading…
Reference in New Issue
Block a user