diff options
author | Harmen Stoppels <me@harmenstoppels.nl> | 2024-08-26 22:15:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-26 22:15:52 +0200 |
commit | a60d1084b1e58ce60bbeaf181658e2936b7449d3 (patch) | |
tree | 4c9091f92a7d3f43caf00e9d05a03a7cc5073cd8 /lib | |
parent | 497e19f0e351b38420da3867fabe6e3361837d04 (diff) | |
download | spack-a60d1084b1e58ce60bbeaf181658e2936b7449d3.tar.gz spack-a60d1084b1e58ce60bbeaf181658e2936b7449d3.tar.bz2 spack-a60d1084b1e58ce60bbeaf181658e2936b7449d3.tar.xz spack-a60d1084b1e58ce60bbeaf181658e2936b7449d3.zip |
jsonschema: remove optional deps (#46041)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/external/_vendoring/jsonschema/_format.py | 173 | ||||
-rw-r--r-- | lib/spack/external/patches/jsonschema.patch | 188 |
2 files changed, 188 insertions, 173 deletions
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) diff --git a/lib/spack/external/patches/jsonschema.patch b/lib/spack/external/patches/jsonschema.patch index d22d87a3d6..c753c641c1 100644 --- a/lib/spack/external/patches/jsonschema.patch +++ b/lib/spack/external/patches/jsonschema.patch @@ -13,3 +13,191 @@ index 6b630cdfbb..1791fe7fbf 100644 -__version__ = metadata.version("jsonschema") + +__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) |