/opt/alt/python38/lib/python3.8/site-packages/cerberus/__pycache__
NameSizeModeActions
errors.cpython-38.opt-1.pyc209300644editdlrm
errors.cpython-38.pyc209300644editdlrm
platform.cpython-38.opt-1.pyc7930644editdlrm
platform.cpython-38.pyc7930644editdlrm
schema.cpython-38.opt-1.pyc179680644editdlrm
schema.cpython-38.pyc179680644editdlrm
utils.cpython-38.opt-1.pyc38510644editdlrm
utils.cpython-38.pyc38510644editdlrm
validator.cpython-38.opt-1.pyc522150644editdlrm
validator.cpython-38.pyc522150644editdlrm
__init__.cpython-38.opt-1.pyc8260644editdlrm
__init__.cpython-38.pyc8260644editdlrm
Edit: /opt/alt/python38/lib/python3.8/site-packages/cerberus/__pycache__/errors.cpython-38.pyc (20930B)
U `S@sdZddlmZddlmZmZddlmZmZddlm Z ddl m Z ddl m Z mZddlmZmZed d Zedd Zed d Zd ZeddZedd ZeddZeddZeddZedd ZdZeddZeddZeddZeddZed d!Zed"d#Z ed$d%Z!ed&d'Z"ed(d)Z#ed*d+Z$ed,d-Z%ed.d-Z&ed/d0Z'ed1d0Z(ed2d3Z)ed4d Z*ed5d6Z+ed7d8Z,ed9d:Z-ed;d<Z.ed=d Z/ed>dZ0ed?dZ1ed@dAZ2Z3edBdCZ4Z5edDd!Z6edEd Z7edFdGZ8edHdIZ9edJdKZ:edLdMZ;dNZZ?GdRdSdSe@ZAGdTdUdUeZBGdVdWdWeBZCGdXdYdYeCZDGdZd[d[eCZEGd\d]d]e>ZFGd^d_d_eFZGd`daZHGdbdcdceFZIGdddedeeIZJd S)fz? This module contains the error-related constants and classes. )absolute_import) defaultdict namedtuple)copydeepcopy)wraps)pformat)PYTHON_VERSIONMutableMapping)compare_paths_lt quote_stringErrorDefinitionz code, ruleNdocument is missingrequiredZ dependenciesZexcludes!''{0}' is not a document, must be a dict"empty#Znullable$type%schema&items'Z minlength(Z maxlengthAZregexBminCmaxDallowedEFZ forbiddenGHcontains`aZcoercebZrename_handlercreadonlydZdefault_setterZ keysrulesZ valuesrulesZnoneofZoneofZanyofZallofz0schema definition for field '{0}' must be a dictzvalidation schema missingc@seZdZdZddZddZddZdd Zd d Ze d d Z e ddZ e ddZ e ddZ e ddZe ddZdS)ValidationErrorz:A simple class to store and query basic error information.cCs.||_||_||_||_||_||_||_dSN) document_path schema_pathcoderule constraintvalueinfo)selfrBrCrDrErFrGrHrJ@/opt/alt/python38/lib/python3.8/site-packages/cerberus/errors.py__init__^szValidationError.__init__cCst|t|kS)z:Assumes the errors relate to the same document and schema.)hashrIotherrJrJrK__eq__qszValidationError.__eq__cCst|jt|jAt|jAS)z>Expects that all other properties are transitively determined.)rMrBrCrDrIrJrJrK__hash__uszValidationError.__hash__cCs,|j|jkrt|j|jSt|j|jSdSrA)rBr rCrNrJrJrK__lt__ys zValidationError.__lt__c Cs>dj|jjtt||j|jt|jt|j t|j |j dS)Nz{class_name} @ {memptr} ( document_path={document_path},schema_path={schema_path},code={code},constraint={constraint},value={value},info={info} )) class_nameZmemptrrBrCrDrFrGrH) format __class____name__hexidrBrCrDr rFrGrHrQrJrJrK__repr__s zValidationError.__repr__cCs|jr|jdSdS)zX A list that contains the individual errors of a bulk validation error. rN)is_group_errorrHrQrJrJrK child_errorsszValidationError.child_errorscCs@|js dStt}|jD]"}|jt|j}|||q|S)z Dictionary with errors of an \*of-rule mapped to the index of the definition it occurred in. Returns :obj:`None` if not applicable. N)is_logic_errorrlistr\rClenappend)rIresulterrorirJrJrKdefinitions_errorss z"ValidationError.definitions_errorscCs|jr|jdSdSdS)z6Field of the contextual mapping, possibly :obj:`None`.N)rBrQrJrJrKfields zValidationError.fieldcCst|jtj@S)z(``True`` for errors of bulk validations.)boolrD ERROR_GROUPrQrJrJrKr[szValidationError.is_group_errorcCst|jtjtj@S)z[ ``True`` for validation errors against different schemas with \*of-rules. )rgrDLOGICALrhrQrJrJrKr]szValidationError.is_logic_errorcCst|jtj@S)z"``True`` for normalization errors.)rgrD NORMALIZATIONrQrJrJrKis_normalization_errorsz&ValidationError.is_normalization_errorN)rW __module__ __qualname____doc__rLrPrRrSrZpropertyr\rdrfr[r]rkrJrJrJrKr@[s$     r@c@seZdZdZddZdS) ErrorListz A list for :class:`~cerberus.errors.ValidationError` instances that can be queried with the ``in`` keyword for a particular :class:`~cerberus.errors.ErrorDefinition`. cs*t|tst|jtfdd|DS)Nc3s|]}|jkVqdSrA)rD).0xZ wanted_coderJrK sz)ErrorList.__contains__..) isinstancer TypeErrorrDany)rIZerror_definitionrJrsrK __contains__s zErrorList.__contains__N)rWrlrmrnrxrJrJrJrKrpsrpc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ e ddZe ddZddZddZdS) ErrorTreeNode) descendantserrors parent_nodepath tree_rootcCs8||_|jj|_|d|jjd|_t|_i|_dSNr)r|r~depthr}rpr{rz)rIr}r|rJrJrKrLs  zErrorTreeNode.__init__cCs"t|tr||jkS||jkSdSrA)rur r{rz)rIitemrJrJrKrxs  zErrorTreeNode.__contains__cCs |j|=dSrArz)rIkeyrJrJrK __delitem__szErrorTreeNode.__delitem__cCs t|jSrA)iterr{rQrJrJrK__iter__szErrorTreeNode.__iter__cCs>t|tr.|jD]}|j|jkr|SqdS|j|SdSrA)rur r{rDrzget)rIrrbrJrJrK __getitem__s     zErrorTreeNode.__getitem__cCs t|jSrA)r_r{rQrJrJrK__len__szErrorTreeNode.__len__cCs|SrA)__str__rQrJrJrKrZszErrorTreeNode.__repr__cCs||j|<dSrAr)rIrrGrJrJrK __setitem__szErrorTreeNode.__setitem__cCst|jdt|jS)N,)strr{rzrQrJrJrKrszErrorTreeNode.__str__cCs t|jSrA)r_r}rQrJrJrKrszErrorTreeNode.depthcCs|jjSrA)r~ tree_typerQrJrJrKrszErrorTreeNode.tree_typecCs||}||j}||jkr,t||||<||}t||jdkr||j||j|jr|j D]}|j |qhn | |dSr) _path_of_rrzryr_r{r`sortr[r\r~add)rIrbZ error_pathrnode child_errorrJrJrKrs      zErrorTreeNode.addcCst||jdS)N_path)getattrrrIrbrJrJrKrszErrorTreeNode._path_of_N)rWrlrm __slots__rLrxrrrrrZrrrorrrrrJrJrJrKrys    rycs:eZdZdZd ddZfddZddZd d ZZS) ErrorTreezw Base class for :class:`~cerberus.errors.DocumentErrorTree` and :class:`~cerberus.errors.SchemaErrorTree`. rJcCs8d|_||_d|_t|_i|_|D]}||q$dS)NrJ)r|r~r}rpr{rzrrIr{rbrJrJrKrL szErrorTree.__init__cs6||s"|j||jntt||dS)zl Add an error to the tree. :param error: :class:`~cerberus.errors.ValidationError` N)rr{r`rsuperrrrrVrJrKr)s   z ErrorTree.addcCs"||}|dk r|jStSdS)z Returns all errors for a particular path. :param path: :class:`tuple` of :term:`hashable` s. :rtype: :class:`~cerberus.errors.ErrorList` N)fetch_node_fromr{rp)rIr}rrJrJrKfetch_errors_from5s zErrorTree.fetch_errors_fromcCs&|}|D]}||}|dkrq"q|S)z Returns a node for a path. :param path: Tuple of :term:`hashable` s. :rtype: :class:`~cerberus.errors.ErrorTreeNode` or :obj:`None` NrJ)rIr}contextrrJrJrKrBs zErrorTree.fetch_node_from)rJ) rWrlrmrnrLrrr __classcell__rJrJrrKrs   rc@seZdZdZdZdS)DocumentErrorTreezv Implements a dict-like class to query errors by indexes following the structure of a validated document. ZdocumentNrWrlrmrnrrJrJrJrKrQsrc@seZdZdZdZdS)SchemaErrorTreezq Implements a dict-like class to query errors by indexes following the structure of the used schema. rNrrJrJrJrKrZsrc@sPeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ dS)BaseErrorHandlerziBase class for all error handlers. Subclasses are identified as error-handlers with an instance-test.cOsdS)z%Optionally initialize a new instance.NrJrIargskwargsrJrJrKrLgszBaseErrorHandler.__init__cCstdS)a, Returns errors in a handler-specific format. :param errors: An object containing the errors. :type errors: :term:`iterable` of :class:`~cerberus.errors.ValidationError` instances or a :class:`~cerberus.Validator` instance NNotImplementedErrorrIr{rJrJrK__call__ks zBaseErrorHandler.__call__cCstdS)z5Be a superhero and implement an iterator over errors.NrrQrJrJrKrvszBaseErrorHandler.__iter__cCstdS)z Add an error to the errors' container object of a handler. :param error: The error to add. :type error: :class:`~cerberus.errors.ValidationError` NrrrJrJrKrzszBaseErrorHandler.addcCsdS)z Optionally emits an error in the handler's format to a stream. Or light a LED, or even shut down a power plant. :param error: The error to emit. :type error: :class:`~cerberus.errors.ValidationError` NrJrrJrJrKemitszBaseErrorHandler.emitcCsdS)z Gets called when a validation ends. :param validator: The calling validator. :type validator: :class:`~cerberus.Validator` NrJrI validatorrJrJrKendszBaseErrorHandler.endcCs|D]}||qdS)z Adds all errors to the handler's container object. :param errors: The errors to add. :type errors: :term:`iterable` of :class:`~cerberus.errors.ValidationError` instances N)rrrJrJrKextendszBaseErrorHandler.extendcCsdS)z Gets called when a validation starts. :param validator: The calling validator. :type validator: :class:`~cerberus.Validator` NrJrrJrJrKstartszBaseErrorHandler.startN) rWrlrmrnrLrrrrrrrrJrJrJrKrcs     rc@seZdZddZddZdS)ToyErrorHandlercOs tddS)NzThis is not supposed to happen.) RuntimeErrorrrJrJrKrszToyErrorHandler.__call__cCsdSrArJrQrJrJrKclearszToyErrorHandler.clearN)rWrlrmrrrJrJrJrKrsrcs$tfdd}tdkr |SS)zCerberus error messages expect regular binary strings. If unicode is used in a ValidationError message can't be printed. This decorator ensures that if legacy Python is used unicode strings are encoded before passing to a function. csVdd}t|}||j|_||j|_||j|_||j|_||j|_||S)NcSst|tr|dS|S)z1Helper encoding unicode strings into binary utf-8zutf-8)ruunicodeencode)rGrJrJrK_encodes  z0encode_unicode..wrapped.._encode)rrBrCrFrGrH)objrbrfrJrKwrappeds     zencode_unicode..wrappedr)rr )rrrJrrKencode_unicodesrc%@seZdZdZdddddddd d d d d dddddddddddddddddddddd d!d"d#$ZdDd%d&Zd'd(Zd)d*Zed+d,Z e d-d.Z d/d0Z d1d2Z d3d4Zd5d6Zd7d8Zd9d:Zd;d<ZdEd>d?ZdFd@dAZdGdBdCZd$S)HBasicErrorHandlerz Models cerberus' legacy. Returns a :class:`dict`. When mangled through :class:`str` a pretty-formatted representation of that tree is returned. z{0}rzrequired fieldz unknown fieldzfield '{0}' is requiredz%depends on these values: {constraint}z&{0} must not be present with '{field}'rzempty values not allowedznull value not allowedzmust be of {constraint} typezmust be of dict typez'length of list should be {0}, it is {1}zmin length is {constraint}zmax length is {constraint}z)value does not match regex '{constraint}'zmin value is {constraint}zmax value is {constraint}zunallowed value {value}zunallowed values {0}zmissing members {0}z&field '{field}' cannot be coerced: {0}z&field '{field}' cannot be renamed: {0}zfield is read-onlyz.default value for '{field}' cannot be set: {0}z'mapping doesn't validate subschema: {0}z.one or more sequence-items don't validate: {0}z2one or more keys of a mapping don't validate: {0}z3one or more values in a mapping don't validate: {0}z one or more definitions validatez#none or more than one rule validatezno definitions validatez&one or more definitions don't validate)$rrrrrrrrrrrrrr!r"r#r$r&r(r*r+r,r-r0r1r2r4r6r7r8r9r<r=r>r?NcCs|dkr in||_dSrAtree)rIrrJrJrKrLszBasicErrorHandler.__init__cCs||||jSrA)rr pretty_treerrJrJrKrs zBasicErrorHandler.__call__cCs t|jSrA)rrrQrJrJrKrszBasicErrorHandler.__str__cCs&t|j}|D]}|||q|SrA)rr_purge_empty_dicts)rIZprettyrfrJrJrKrs zBasicErrorHandler.pretty_treecCs^t|}|||jr$||n6|jr6||n$|j|jkrZ||j | |j |dSrA) r_rewrite_error_pathr]_insert_logic_errorr[_insert_group_errorrDmessages _insert_errorrB_format_messagerfrrJrJrKr s     zBasicErrorHandler.addcCs i|_dSrArrQrJrJrKrszBasicErrorHandler.clearcCs |dSrA)rrrJrJrKr!szBasicErrorHandler.startcCs"|j|jj|j|j||jdS)N)rFrfrG)rrDrUrHrFrG)rIrfrbrJrJrKr$s  z!BasicErrorHandler._format_messagecCs|d}t|dkrT||jkrD|j|}|j|||g7<q|ig|j|<nnt|dkr||jkrvig|j|<|j|d}|r|jt|d}n|}||dd|||jdS)z Adds an error or sub-tree to :attr:tree. :param path: Path to the error. :type path: Tuple of strings and integers. :param node: An error message or a sub-tree. :type node: String or dictionary. rrrerN)r_rpoprVrrupdate)rIr}rrfsubtreenewrJrJrKr)s      zBasicErrorHandler._insert_errorcCsL|jD]@}|jr||q|jr.||q||j||j|qdSrA) r\r]rr[rrrBrrf)rIrbrrJrJrKrEs    z%BasicErrorHandler._insert_group_errorc Cst|j}||j||||jD]H}|D]>}|jrD||q.|jrV| |q.||j|||q.q&dSrA) rfrrBrrdvaluesr]rr[r)rIrbrfdefinition_errorsrrJrJrKrQs   z%BasicErrorHandler._insert_logic_errorcCs6|d}|ds|n|D]}|||qdS)Nre)rr)rIZ error_listrrrJrJrKras  z$BasicErrorHandler._purge_empty_dictsrcCs*|jr|||n|jr&|||dS)zY Recursively rewrites the error path to correctly represent logic errors N)r]_rewrite_logic_error_pathr[_rewrite_group_error_path)rIrboffsetrJrJrKrisz%BasicErrorHandler._rewrite_error_pathcCsDt|j|}|jD]*}|j|d}|j||_|||qdSrA)r_rBr\r)rIrbr child_startr relative_pathrJrJrKrrs   z+BasicErrorHandler._rewrite_group_error_pathc Csxt|j|}|jD]Z\}}|s&qd|j|f}|j|f}|D],}|j|d} || |_|||dqDqdS)Nz%s definition %sr)r_rBrdr rEr) rIrbrrrcrnodenamer}rrel_pathrJrJrKr{s  z+BasicErrorHandler._rewrite_logic_error_path)N)r)r)r)rWrlrmrnrrLrrrorrrrrrrrrrrrrrJrJrJrKrsn'     rc@seZdZejZded<dS)SchemaErrorHandlerz unknown rulerN)rWrlrmrrrrJrJrJrKrs r)Krn __future__r collectionsrrrr functoolsrpprintrZcerberus.platformr r Zcerberus.utilsr r r ZCUSTOMZDOCUMENT_MISSINGZREQUIRED_FIELDZ UNKNOWN_FIELDZDEPENDENCIES_FIELDZDEPENDENCIES_FIELD_VALUEZEXCLUDES_FIELDZDOCUMENT_FORMATZEMPTY_NOT_ALLOWEDZ NOT_NULLABLEZBAD_TYPEZBAD_TYPE_FOR_SCHEMAZ ITEMS_LENGTHZ MIN_LENGTHZ MAX_LENGTHZREGEX_MISMATCHZ MIN_VALUEZ MAX_VALUEZUNALLOWED_VALUEZUNALLOWED_VALUESZFORBIDDEN_VALUEZFORBIDDEN_VALUESZMISSING_MEMBERSrjZCOERCION_FAILEDZRENAMING_FAILEDZREADONLY_FIELDZSETTING_DEFAULT_FAILEDrhZMAPPING_SCHEMAZSEQUENCE_SCHEMAZ KEYSRULESZ KEYSCHEMAZ VALUESRULESZ VALUESCHEMAZ BAD_ITEMSriZNONEOFZONEOFZANYOFZALLOFZSCHEMA_ERROR_DEFINITION_TYPEZSCHEMA_ERROR_MISSINGobjectr@r^rpryrrrrrrrrrJrJrJrKs~                                        hI7  H?