kfr. dZddlmZddlmZddlZddlZddlZddlm Z ddl m Z m Z m Z mZmZddlmZmZmZmZmZmZmZmZmZmZddlmZeGd d eZiZe j Z!d@d Z"e#e$ee%dej&e'ed Z(e j)e"e(Z*dZ+dZ,Gdde%Z-dZ.d ddde.fdZ/dAdZ0e/e j1didej2dej3dej4de j5de j6dej7dej8de j9dej:d e j;d!ej<d"ej=d#e j>d$ej?d%ej@d&e jAd'ejBejCe jDe jEejFd(e jGdd)*ZHe/e j1d+idej2dej3dej4d,ejId-ejJdejKdej8dej:d e j;d!ej<d"ej=d.ejLd#e j>d$ej?d%ej@d/ejMd&e jAej7ejNejOejBejCejPejQej%ejFd0 e jRd+d1*ZSe/e j1d2idej2dej3dej4d,ejId-ejJd3ejTd4ejUdejKdej8d5ejVd6ejWdej:d ejXd!ej<d"ej=d.ejLd#ejYej?ej@ejMejZej7ejNejOejBejCejPej[ejQej%ejFd7e j\d28Z]e/e j1d9idej2dej3dej4d,ejId-ejJd3ejTd4ejUdejKdej8d5ejVd6ejWdej:d:ej^d ejXd!ej<d"ej=d.ejLejYej?ej@ejMejZej7ejOejNejBejCejPej[ejQej%ejFd;e j_d98Z`e`ZaGd<d=ebZcdBd>Zdeafd?ZedS)CzQ Creation and extension of validators, with implementations for existing drafts. )division)warnN) add_metaclass)_legacy_validators_types_utils _validators exceptions) Sequence int_types iteritems lru_cache str_typesunquote urldefragurljoinurlopenurlsplit) ErrorTreeceZdZdZdZdS) _DontDoThatz Raised when a Validators with non-default type checker is misused. Asking one for DEFAULT_TYPES doesn't make sense, since type checkers exist for the unrepresentable cases where DEFAULT_TYPES can't represent the type relationship. cdS)Nz=DEFAULT_TYPES cannot be used on Validators using TypeCheckersselfs u/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/jsonschema/validators.py__str__z_DontDoThat.__str__1sNNN)__name__ __module__ __qualname____doc__rrrrrr(s2OOOOOrrrctt|}d}i}t|D]\}}||||<|S)a Generate newer-style type checks out of JSON-type-name-to-type mappings. Arguments: types (dict): A mapping of type names to their Python types Returns: A dictionary of definitions to pass to `TypeChecker` c:tjfd}|S)Ncdt|tr tvrdSt|S)NF) isinstancebool)checkerinstancepytypess r type_checkzH_generate_legacy_type_checks..gen_type_check..type_checkLs5(D)) !w&& 5h00 0r)rflatten)r*r+s` rgen_type_checkz4_generate_legacy_type_checks..gen_type_checkIs3.)) 1 1 1 1 1 r)dictr )typesr- definitionstypenamer*s r_generate_legacy_type_checksr29s^ KKE   K&u--88' .w 7 7 H r)arraybooleanintegernullnumberobjectstring type_checkerscfd}|S)a Register the decorated validator for a ``version`` of the specification. Registered validators and their meta schemas will be considered when parsing ``$schema`` properties' URIs. Arguments: version (str): An identifier to use as the version's name Returns: collections.Callable: a class decorator to decorate the validator with the version ch|t<||j}|r |t|<|SN) validatorsID_OF META_SCHEMA meta_schemas)clsmeta_schema_idversions r _validateszvalidates.._validates}s7! 73?33  /+.L ( rr)rErFs` r validatesrGis$( rch|jttdtd|jS)NzcThe DEFAULT_TYPES attribute is deprecated. See the type checker attached to this validator instead. stacklevel)_CREATED_WITH_DEFAULT_TYPESrrDeprecationWarning_DEFAULT_TYPESrs rrNrNsE '/mm G    rc$eZdZeeZdS)!_DefaultTypesDeprecatingMetaClassN)rr r!propertyrN DEFAULT_TYPESrrrrPrPsH^,,MMMrrPcB|dus|durdS|ddS)NTFz$idgetschemas r_id_ofrYs, ~~5s ::fc " ""rc Mtddtdtdtjt n!t  dtnturdndttGfd d t}|Ht||}| d d d z|_|S) a Create a new validator class. Arguments: meta_schema (collections.Mapping): the meta schema for the new validator class validators (collections.Mapping): a mapping from names to callables, where each callable will validate the schema property with the given name. Each callable should take 4 arguments: 1. a validator instance, 2. the value of the property being validated within the instance 3. the instance 4. the schema version (str): an identifier for the version that this validator class will validate. If provided, the returned validator class will have its ``__name__`` set to include the version, and also will have `jsonschema.validators.validates` automatically called for the given version. type_checker (jsonschema.TypeChecker): a type checker, used when applying the :validator:`type` validator. If unprovided, a `jsonschema.TypeChecker` will be created with a set of default types typical of JSON Schema drafts. default_types (collections.Mapping): .. deprecated:: 3.0.0 Please use the type_checker argument instead. If set, it provides mappings of JSON types to Python types that will be converted to functions and redefined in this object's `jsonschema.TypeChecker`. id_of (collections.Callable): A function that given a schema, returns its ID. Returns: a new `jsonschema.IValidator` class Nz;Do not specify default_types when providing a type checker.TzPThe default_types argument is deprecated. Use the type_checker argument instead.rIrJr:FceZdZeZeZZeZe e Z eZ Z d fd Z edZd fd Zd dZdZdZd d ZdS) create..ValidatorrNc|rCtdtd|jt ||_|t |}||_||_||_ dS)NzaThe types argument is deprecated. Provide a type_checker to jsonschema.validators.extend instead.rIrJ)id_of) rrM TYPE_CHECKER redefine_manyr2 RefResolver from_schemaresolverformat_checkerrX)rrXr/rcrdr^s r__init__z"create..Validator.__init__s #' %)$5$C$C077%%!&2262GG$DM"0D  DKKKrc||j|D] }tj|dSr>)rA iter_errorsr SchemaError create_from)rCrXerrors r check_schemaz&create..Validator.check_schema#sPS_--99&AA @ @ ,88??? @ @rc3K||j}|durdS|dur tjd|dd||VdS |}|r|j| |d}|d|fg}nt |}|D]t\}}|j|}|"|||||pd} | D]?} | |||||dkr| j || V@u |r|j dSdS#|r|j wwxYw)NTFzFalse schema does not allow ) validatorvalidator_valuer)rX$refr) rXr ValidationErrorrc push_scoperVr VALIDATORS_set schema_path appendleft pop_scope) rr)_schemascoperefr?kvrmerrorsrjr^s rrgz%create..Validator.iter_errors(s+$E!! 008@B"$(%" E'NNE 0 ((/// .kk'**?#*C.!1JJ!*7!3!3J&$$DAq $ 3 3A 6 6I ( &YtQ'BBHbF!' $ $ &',-%-#* # <<!-88;;;#  $ $$.M++-----..5.M++----.s B#D""Ec3K|||D]>}||j|||j||V?dSr>)rgpathrurt)rr)rXr~rtrjs rdescendz!create..Validator.descendWss))(F;;  #J))$///*%00===   rc(|j|i|D]}|dSr>)rg)rargskwargsrjs rvalidatez"create..Validator.validate_s2))4:6::     rc |j||S#tj$rtj|||jwxYwr>)r_is_typer UndefinedTypeCheck UnknownTyperX)rr)types rrz!create..Validator.is_typecsZ J(004@@@0 J J J ,T8T[III Js +AcRt|||d}|duSr>)nextrg)rr)rwrjs ris_validz"create..Validator.is_validis+))(G<)NN)rr r!r.rrrAr_ staticmethodr@rQrNrRrLre classmethodrkrgrrrr)_created_with_default_types default_typesr^ meta_schema type_checkerr?sr Validatorr\sT*%% d;'' #  U## 00 m,,&A#   ! ! ! ! ! !:  @ @  @- .- .- .- .- .- .^        J J J  ! ! ! ! ! !rr rT) TypeErrorrrMr TypeCheckerr2_DEPRECATED_DEFAULT_TYPES*_TYPE_CHECKER_FOR_DEPRECATED_DEFAULT_TYPESrrPr8rGtitlereplacer)rr?rErrr^rrs`` ``` @rcreatersn@  #M '+# 9      )6}EE   2  */ 'ELL G G G*/ ' '*. '455p!p!p!p!p!p!p!p!p!p!p!p!Fp!p!65p!d&Ig&&y11 $]]__44S"== K  rct|j}||||j}n|jrt dt |j||||jS)a Create a new validator class by extending an existing one. Arguments: validator (jsonschema.IValidator): an existing validator class validators (collections.Mapping): a mapping of new validator callables to extend with, whose structure is as in `create`. .. note:: Any validator callables with the same name as an existing one will (silently) replace the old validator callable entirely, effectively overriding any validation done in the "parent" validator class. If you wish to instead extend the behavior of a parent's validator callable, delegate and call it directly in the new validator function by retrieving it using ``OldValidator.VALIDATORS["validator_name"]``. version (str): a version for the new validator class type_checker (jsonschema.TypeChecker): a type checker, used when applying the :validator:`type` validator. If unprovided, the type checker of the extended `jsonschema.IValidator` will be carried along.` Returns: a new `jsonschema.IValidator` class extending the one provided .. note:: Meta Schemas The new validator class will have its parent's meta schema. If you wish to change or extend the meta schema in the new validator class, modify ``META_SCHEMA`` directly on the returned class. Note that no implicit copying is done, so a copy should likely be made before modifying it, in order to not affect the old validator. NzCannot extend a validator created with default_types with a type_checker. Update the validator to use a type_checker when created.)rr?rErr^) r.rrupdater_rLrrrAr@)rmr?rErall_validatorss rextendrtsj).//N*%%% -  .  )   )!!o    rdraft3roadditionalItemsadditionalProperties dependenciesdisallow divisibleByenumextendsformatitemsmaxItems maxLengthmaximumminItems minLengthminimumpattern)patternProperties propertiesr uniqueItemsc.|ddSNidrTrUrWs rrE2..r)rr?rrEr^draft4allOfanyOf maxProperties minProperties) multipleOfnotoneOfrrrrequiredrrc.|ddSrrUrWs rrrrrdraft6constcontainsexclusiveMaximumexclusiveMinimum)rrrrrrrrrr propertyNamesrrr)rr?rrEdraft7if)rrrrrrrrrrrrrrrceZdZdZ ddZeefdZdZdZ e d Z e d Z e jd Ze jd Zd ZdZdZdZdS)raa Resolve JSON References. Arguments: base_uri (str): The URI of the referring document referrer: The actual referring document store (dict): A mapping from URIs to documents to cache cache_remote (bool): Whether remote refs should be cached after first resolution handlers (dict): A mapping from URI schemes to functions that should be used to retrieve them urljoin_cache (:func:`functools.lru_cache`): A cache that will be used for caching the results of joining the resolution scope to subscopes. remote_cache (:func:`functools.lru_cache`): A cache that will be used for caching the results of resolved remote URLs. Attributes: cache_remote (bool): Whether remote refs should be cached after first resolution rTNc|tdt}|td|j}||_||_t ||_|g|_tj dttD|_ |j |||j |<||_||_dS)Nic3.K|]\}}||jfVdSr>)rA).0rrms r z'RefResolver.__init__..sB$ $ I& '$ $ $ $ $ $ r)rrresolve_from_urlreferrer cache_remoter.handlers _scopes_stackrURIDictr rBstorer_urljoin_cache _remote_cache)rbase_urirrrr urljoin_cache remote_caches rrezRefResolver.__init__|s  +IdOOG44M  *9T??4+@AAL  (X &Z^$ $ !*{+    33h>  sB BB!B**)Cc ddl}n#t$rd}YnwxYwt|j}||jvr|j||}n|dvr*|r(||}n`t|5}t j| d}dddn #1swxYwY|j r ||j |<|S)a Resolve a remote ``uri``. If called directly, does not check the store first, but after retrieving the document at the specified URI it will be saved in the store if :attr:`cache_remote` is True. .. note:: If the requests_ library is present, ``jsonschema`` will use it to request the remote ``uri``, so that the correct encoding is detected and used. If it isn't, or if the scheme of the ``uri`` is not ``http`` or ``https``, UTF-8 is assumed. Arguments: uri (str): The URI to resolve Returns: The retrieved document .. _requests: https://pypi.org/project/requests/ rN)httphttpszutf-8) requests ImportErrorrschemerrVjsonrloadsreaddecoderr)rrrr resultrs rrzRefResolver.resolve_remote3sO:  OOOO   HHH #% T] " "*T]6*3//FF * * *x *\\#&&++--FF @CHHJJ$5$5g$>$>?? @ @ @ @ @ @ @ @ @ @ @ @ @ @ @   %$DJsO s  :CCC)rTrNN)rr r!r"rerrYrbrqrvrQrr contextlibcontextmanagerrrrrrrrrrraraPs:))^****<'-MMM[M"    &&&X& X(,,, 9 9 9"""H11111rrac|t|}||||g|Ri|}tj||}||dS)a Validate an instance under the given schema. >>> validate([2, 3, 4], {"maxItems": 2}) Traceback (most recent call last): ... ValidationError: [2, 3, 4] is too long :func:`validate` will first verify that the provided schema is itself valid, since not doing so can lead to less obvious error messages and fail in less obvious or consistent ways. If you know you have a valid schema already, especially if you intend to validate multiple instances with the same schema, you likely would prefer using the `IValidator.validate` method directly on a specific validator (e.g. ``Draft7Validator.validate``). Arguments: instance: The instance to validate schema: The schema to validate with cls (IValidator): The class that will be used to validate the instance. If the ``cls`` argument is not provided, two things will happen in accordance with the specification. First, if the schema has a :validator:`$schema` property containing a known meta-schema [#]_ then the proper validator will be used. The specification recommends that all schemas contain :validator:`$schema` properties for this reason. If no :validator:`$schema` property is found, the default validator class is the latest released draft. Any other provided positional and keyword arguments will be passed on when instantiating the ``cls``. Raises: `jsonschema.exceptions.ValidationError` if the instance is invalid `jsonschema.exceptions.SchemaError` if the schema itself is invalid .. rubric:: Footnotes .. [#] known by a validator registered with `jsonschema.validators.validates` N) validator_forrkr best_matchrg)r)rXrCrrrmrjs rrrgs{p {F##VF,T,,,V,,I  !)"7"7"A"A B BE  rc|dus|dusd|vr|S|dtvrtdtdt|dtS)a Retrieve the validator class appropriate for validating the given schema. Uses the :validator:`$schema` property that should be present in the given schema to look up the appropriate validator class. Arguments: schema (collections.Mapping or bool): the schema to look at default: the default to return if the appropriate validator class cannot be determined. If unprovided, the default is to return the latest supported draft. TFz$schemazThe metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.rIrJ)rBrrMrV_LATEST_VERSION)rXdefaults rrrsu*~~5Jf,D,D j-- *        F:. @ @@r)rrr>)fr" __future__rwarningsrrr numberssixr jsonschemarrrr r jsonschema.compatr r r rrrrrrrjsonschema.exceptionsrrrr?rrBr2listr'rNumberr.rrrrGrNrPrYrr load_schemaryrrdependencies_draft3disallow_draft3rrextends_draft3ritems_draft3_draft4rrmaximum_draft3_draft4rrminimum_draft3_draft4rrproperties_draft3 type_draft3rdraft3_type_checkerDraft3Validatorrrrrrnot_rrrdraft4_type_checkerDraft4Validatorrrrrrrrrdraft6_type_checkerDraft6Validatorif_draft7_type_checkerDraft7Validatorrr8rarrrrrr3s*                            ,+++++  O O O O O) O O O v~ F T$ZZ~.@V-?../HII...* :   --------###   RRRRjFFFFR&""8,,K7 !A +?  '7   .  ! &5 ;% $8 [) k+ &< [) k+ &