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    
idna / lib / python2.7 / site-packages / nova / api / validation / validators.pyc
Size: Mime:
ó
±EYc@sõdZddlZddlZddlZddlmZddlZddlmZddlm	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZejjd	ƒd
„ƒZejjdƒd„ƒZejjd
ƒd„ƒZejjdƒd„ƒZejjdƒd„ƒZejjdejƒd„ƒZejjdejƒd„ƒZejjdejƒd„ƒZejjdejƒd„ƒZd„Zdejfd„ƒYZdefd„ƒYZ dS( sA
Internal implementation of request Body validating middleware.

iÿÿÿÿN(t
exceptions(t	timeutils(t	uuidutils(tparameter_types(t	exception(t_s	date-timecCs.ytj|ƒWntk
r%tSXtSdS(N(Rt
parse_isotimet
ValueErrortFalsetTrue(tinstance((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pyt_validate_datetime_format#s

tbase64cCsey5t|tjƒr'|jdƒ}ntj|ƒWn)tjjk
rOtSt	k
r`tSXt
S(Nsutf-8(t
isinstancetsixt	text_typetencodeRtdecodestringtbinasciitErrorRt	TypeErrorR	(R
((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pyt_validate_base64_format-s
tcidrcCsSytj|ƒWntjk
r(tSXd|kr9tStjd|ƒrOtStS(Nt/s\s(tnetaddrt	IPNetworktAddrFormatErrorRtretsearchR	(R((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pyt_validate_cidr_format=stuuidcCs
tj|ƒS(N(Rtis_uuid_like(R
((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pyt_validate_uuid_formatJsturicCstj|dtdtƒS(Ntrequire_schemetrequire_authority(trfc3986tis_valid_uriR	(R
((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/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_regexRRtregexR	RRtInvalidNameR((R
R*((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pyt+_validate_name_with_leading_trailing_spacesUs	
tnamecCsStj}ytj|j|ƒr%tSWntk
r9nXtjd|j	ƒ‚dS(NR((
Rtvalid_name_regexRRR*R	RRR+R((R
R*((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pyt_validate_namecs	
t&cell_name_with_leading_trailing_spacescCsStj}ytj|j|ƒr%tSWntk
r9nXtjd|j	ƒ‚dS(NR((
Rt-valid_cell_name_leading_trailing_spaces_regexRRR*R	RRR+R((R
R*((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pyt0_validate_cell_name_with_leading_trailing_spacesps	
t	cell_namecCsStj}ytj|j|ƒr%tSWntk
r9nXtjd|j	ƒ‚dS(NR((
Rtvalid_cell_name_regexRRR*R	RRR+R((R
R*((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/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((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pys	<genexpr>½s(
tis_typetgettjointsetRRtaddtlentjsonschema_exctValidationError(
t	validatortadditional_properties_valueR
tschemaR7tpatternstextra_propertiestpropterrortverb((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/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(tcheckerstNoneREtFormatError(	tselfR
tformattfunctraisestresultRQtetmsg((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pytcheckÌs	
(t__name__t
__module__t__doc__R\(((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pyRPÄst_SchemaValidatorcBsMeZdZdZejZed„Z	d„Z
d„Zd„Zd„Z
RS(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 nova api commonly.

    cCsgi|jd6|jd6}|r-t|d<ntjj|j|ƒ}tƒ}||d|ƒ|_dS(NtminimumtmaximumtadditionalPropertiestformat_checker(	t_validate_minimumt_validate_maximumROt
jsonschemat
validatorstextendt
validator_orgRPRG(RURItrelax_additional_propertiesRht
validator_clsRd((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pyt__init__ôs


		cOsõy|jj||ŽWn×tjk
r½}t|jtjƒrS|jjƒ}nUt	|j
ƒdkrŸtdƒi|j
jƒd6|j
d6|jd6}n	|j}tjd|ƒ‚n4tk
rð}tj|ƒ}tjd|ƒ‚nXdS(NisIInvalid input for field/attribute %(path)s. Value: %(value)s. %(message)stpathtvaluetmessagetdetail(RGtvalidateRgRFR
RQRR+tformat_messageRDRnRtpopR
RpRRR(RUtargstkwargstexRq((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pyRrs		cCsYyt|ƒ}WnBttfk
rTyt|ƒ}WqUttfk
rPdSXnX|S(N(tintRRtfloatRS(RUR
Ro((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pyt_number_from_strs	cCs<|j|ƒ}|dkrdS|jjd||||ƒS(NRa(RzRSRjt
VALIDATORS(RURGRaR
RI((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pyRe#s
cCs<|j|ƒ}|dkrdS|jjd||||ƒS(NRb(RzRSRjR{(RURGRbR
RI((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pyRf*s
N(R]R^R_RSRGRgtDraft4ValidatorRjRRmRrRzReRf(((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pyR`çs				
	(!R_RRRgRRERt
oslo_utilsRRR$Rtnova.api.validationRtnovaRt	nova.i18nRRPt
cls_checksRRRR R&R+R,R/R2R5ROR6R`(((sS/home/tvault/.virtenv/lib/python2.7/site-packages/nova/api/validation/validators.pyt<module>s4


!

!
	9#