Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
dmapi / usr / lib / python2.7 / dist-packages / dmapi / api / validation / validators.pyc
Size: Mime:
ó
¸ÈÛcc@sRdZddlZddlZddlZddlmZddlZddlmZddlm	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZejjd	ƒd
„ƒZejjdƒd„ƒZejjd
ƒd„ƒZejjdƒd„ƒZejjdƒd„ƒZejjdƒd„ƒZejjdejƒd„ƒZejjdejƒd„ƒZejjdejƒd„ƒZejjdejƒd„ƒZejjdejƒd„ƒZejjdejƒd „ƒZ d!„Z!d"ejfd#„ƒYZd$e"fd%„ƒYZ#dS(&sA
Internal implementation of request Body validating middleware.

iÿÿÿÿN(t
exceptions(t	timeutils(t	uuidutils(tparameter_types(t	exception(t_tregexcCsK|st|tjƒrtSytj|ƒWntjk
rFtSXtS(N(t
isinstancetsixt	text_typetFalsetretcompileterrortTrue(tinstance((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyt_validate_regex_formatss	date-timecCs.ytj|ƒWntk
r%tSXtSdS(N(Rt
parse_isotimet
ValueErrorR
R(R((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyt_validate_datetime_format#s

tbase64cCsey5t|tjƒr'|jdƒ}ntj|ƒWn)tjjk
rOtSt	k
r`tSXt
S(Nsutf-8(RRR	tencodeRtdecodestringtbinasciitErrorR
t	TypeErrorR(R((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyt_validate_base64_format-s
tcidrcCsSytj|ƒWntjk
r(tSXd|kr9tStjd|ƒrOtStS(Nt/s\s(tnetaddrt	IPNetworktAddrFormatErrorR
RtsearchR(R((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyt_validate_cidr_format=stuuidcCs
tj|ƒS(N(Rtis_uuid_like(R((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyt_validate_uuid_formatJsturicCstj|dtdtƒS(Ntrequire_schemetrequire_authority(trfc3986tis_valid_uriR(R((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyt
_validate_uriOst!name_with_leading_trailing_spacescCsStj}ytj|j|ƒr%tSWntk
r9nXtjd|j	ƒ‚dS(Ntreason(
Rt(valid_name_leading_trailing_spaces_regexRR RRRRtInvalidNameR,(RR((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyt+_validate_name_with_leading_trailing_spacesUs	
tnamecCsStj}ytj|j|ƒr%tSWntk
r9nXtjd|j	ƒ‚dS(NR,(
Rtvalid_name_regexRR RRRRR.R,(RR((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyt_validate_namecs	
t$az_name_with_leading_trailing_spacescCsStj}ytj|j|ƒr%tSWntk
r9nXtjd|j	ƒ‚dS(NR,(
Rt+valid_az_name_leading_trailing_spaces_regexRR RRRRR.R,(RR((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyt._validate_az_name_with_leading_trailing_spacesps	
taz_namecCsStj}ytj|j|ƒr%tSWntk
r9nXtjd|j	ƒ‚dS(NR,(
Rtvalid_az_name_regexRR RRRRR.R,(RR((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyt_validate_az_name~s	
t&cell_name_with_leading_trailing_spacescCsStj}ytj|j|ƒr%tSWntk
r9nXtjd|j	ƒ‚dS(NR,(
Rt-valid_cell_name_leading_trailing_spaces_regexRR RRRRR.R,(RR((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyt0_validate_cell_name_with_leading_trailing_spaces‹s	
t	cell_namecCsStj}ytj|j|ƒr%tSWntk
r9nXtjd|j	ƒ‚dS(NR,(
Rtvalid_cell_name_regexRR RRRRR.R,(RR((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyt_validate_cell_name™s	
c
cs,|j|dƒs|rdS|jdiƒ}dj|jdiƒƒ}tƒ}xU|D]M}||krZ|r—tj||ƒs¤|j|ƒq¤q§|j|ƒqZqZW|sµdS|rd}t|ƒdkrÜd}	nd	}	tj	|d
jd„|Dƒƒ|	fƒVnx|D]
}||=qWdS(sThis validator function is used for legacy v2 compatible mode in v2.1.
    This will skip all the additional properties checking but keep check the
    'patternProperties'. 'patternProperties' is used for metadata API.

    If there are not any properties on the instance that are not specified in
    the schema, this will return without any effect. If there are any such
    extra properties, they will be handled as follows:

    - if the validator passed to the method is not of type "object", this
      method will return without any effect.
    - if the 'additional_properties_value' parameter is True, this method will
      return without any effect.
    - if the schema has an additionalProperties value of True, the extra
      properties on the instance will not be touched.
    - if the schema has an additionalProperties value of False and there
      aren't patternProperties specified, the extra properties will be stripped
      from the instance.
    - if the schema has an additionalProperties value of False and there
      are patternProperties specified, the extra properties will not be
      touched and raise validation error if pattern doesn't match.
    tobjectNt
propertiest|tpatternPropertiess8Additional properties are not allowed (%s %s unexpected)itwastweres, css|]}t|ƒVqdS(N(trepr(t.0textra((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pys	<genexpr>Øs(
tis_typetgettjointsetRR taddtlentjsonschema_exctValidationError(
t	validatortadditional_properties_valueRtschemaR@tpatternstextra_propertiestpropR
tverb((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyt$_soft_validate_additional_properties¦s0	
	
t
FormatCheckercBseZdZd„ZRS(sA FormatChecker can output the message from cause exception

       We need understandable validation errors messages for users. When a
       custom checker has an exception, the FormatChecker will output a
       readable message provided by the checker.
    c	Cs||jkrdS|j|\}}d\}}y||ƒ}Wn|k
r]}|}nX|sŒd||f}tj|d|ƒ‚ndS(s>Check whether the instance conforms to the given format.

        :argument instance: the instance to check
        :type: any primitive type (str, number, bool)
        :argument str format: the format that instance should conform to
        :raises: :exc:`FormatError` if instance does not conform to format
        Ns%r is not a %rtcause(NN(tcheckerstNoneRNtFormatError(	tselfRtformattfunctraisestresultRYtetmsg((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pytcheckçs	
(t__name__t
__module__t__doc__Rd(((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyRXßst_SchemaValidatorcBsPeZdZdZejZee	d„Z
d„Zd„Zd„Z
d„ZRS(s\A validator class

    This class is changed from Draft4Validator to validate minimum/maximum
    value of a string number(e.g. '10'). This changes can be removed when
    we tighten up the API definition and the XML conversion.
    Also FormatCheckers are added for checking data formats which would be
    passed through dmapi api commonly.

    cCsp||_i|jd6|jd6}|r6t|d<ntjj|j|ƒ}tƒ}||d|ƒ|_	dS(NtminimumtmaximumtadditionalPropertiestformat_checker(
tis_bodyt_validate_minimumt_validate_maximumRWt
jsonschemat
validatorstextendt
validator_orgRXRP(R]RRtrelax_additional_propertiesRmRqt
validator_clsRl((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyt__init__s	


		cOs5y|jj||ŽWntjk
rý}t|jtjƒrS|jjƒ}n•t	|j
ƒdkrß|jr¨tdƒi|j
j
ƒd6|jd6|jd6}qètdƒi|j
jƒd6|jd6|jd6}n	|j}tjd|ƒ‚n4tk
r0}tj|ƒ}tjd|ƒ‚nXdS(NisIInvalid input for field/attribute %(path)s. Value: %(value)s. %(message)stpathtvaluetmessagesJInvalid input for query parameters %(path)s. Value: %(value)s. %(message)stdetail(RPtvalidateRpRORRYRR.tformat_messageRMRwRmRtpopRRytpopleftRRR	(R]targstkwargstexRz((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyR{s,		
		
	cCsYyt|ƒ}WnBttfk
rTyt|ƒ}WqUttfk
rPdSXnX|S(N(tintRRtfloatR[(R]RRx((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyt_number_from_strEs	cCs<|j|ƒ}|dkrdS|jjd||||ƒS(NRi(R„R[Rst
VALIDATORS(R]RPRiRRR((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyRnOs
cCs<|j|ƒ}|dkrdS|jjd||||ƒS(NRj(R„R[RsR…(R]RPRjRRR((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyRoVs
N(ReRfRgR[RPRptDraft4ValidatorRsR
RRvR{R„RnRo(((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyRhs			&	
	($RgRRRpRRNRt
oslo_utilsRRR(Rtdmapi.api.validationRtdmapiRt
dmapi.i18nRRXt
cls_checksRRRR!R$R*R.R/R2R5R8R;R>RWR?Rh(((sC/usr/lib/python2.7/dist-packages/dmapi/api/validation/validators.pyt<module>s<


!

!

!
	9#