Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/landscape/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/landscape/schema.pyc

ó
ÍÿŠTc@s(dZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZd	efd
„ƒYZdefd„ƒYZd
efd„ƒYZ	defd„ƒYZ
defd„ƒYZdefd„ƒYZdefd„ƒYZ
defd„ƒYZde
fd„ƒYZdS(s"A schema system. Yes. Another one!tInvalidErrorcBseZdZRS(s&Raised when invalid input is received.(t__name__t
__module__t__doc__(((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyRstConstantcBs eZdZd„Zd„ZRS(s1Something that must be equal to a constant value.cCs
||_dS(N(tvalue(tselfR((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyt__init__scCs/||jkr+td||jfƒ‚n|S(Ns%r != %r(RR(RR((s4/usr/lib/python2.7/dist-packages/landscape/schema.pytcoerces(RRRRR(((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR	s	tAnycBs eZdZd„Zd„ZRS(ssSomething which must apply to any of a number of different schemas.

    @param schemas: Other schema objects.
    cGs
||_dS(N(tschemas(RR
((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyRscCsVx6|jD]+}y|j|ƒSWq
tk
r4q
Xq
Wtd||jfƒ‚dS(sˆ
        The result of the first schema which doesn't raise
        L{InvalidError} from its C{coerce} method will be returned.
        s!%r did not match any schema in %sN(R
RR(RRtschema((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyRs
(RRRRR(((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR	s	tBoolcBseZdZd„ZRS(s!Something that must be a C{bool}.cCs)t|tƒs%td|fƒ‚n|S(Ns%r is not a bool(t
isinstancetboolR(RR((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR,s(RRRR(((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR*stIntcBseZdZd„ZRS(s,Something that must be an C{int} or C{long}.cCs/t|ttfƒs+td|fƒ‚n|S(Ns%r isn't an int or long(R
tinttlongR(RR((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR4s(RRRR(((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR2stFloatcBseZdZd„ZRS(s7Something that must be an C{int}, C{long}, or C{float}.cCs2t|tttfƒs.td|fƒ‚n|S(Ns%r isn't a float(R
RRtfloatR(RR((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR<s(RRRR(((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR:stBytescBseZdZd„ZRS(sA binary string.cCs)t|tƒs%td|fƒ‚n|S(Ns%r isn't a str(R
tstrR(RR((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyRDs(RRRR(((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyRBstUnicodecBs#eZdZdd„Zd„ZRS(s³Something that must be a C{unicode}.

    If the value is a C{str}, it will automatically be decoded.

    @param encoding: The encoding to automatically decode C{str}s with.
    sutf-8cCs
||_dS(N(tencoding(RR((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyRRscCsƒt|tƒrZy|j|jƒ}WqZtk
rV}td|t|ƒfƒ‚qZXnt|tƒstd|fƒ‚n|S(Ns%r can't be decoded: %ss%r isn't a unicode(R
RtdecodeRtUnicodeDecodeErrorRtunicode(RRte((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyRUs#(RRRRR(((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyRJstListcBs eZdZd„Zd„ZRS(snSomething which must be a C{list}.

    @param schema: The schema that all values of the list must match.
    cCs
||_dS(N(R(RR((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyRescCsžt|tƒs%td|fƒ‚nt|ƒ}xft|ƒD]X\}}y|jj|ƒ||<Wq>tk
r•}td||j|fƒ‚q>Xq>W|S(Ns%r is not a lists%r could not coerce with %s: %s(R
tlistRt	enumerateRR(RRtnew_listtitsubvalueR((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyRhs(RRRRR(((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR`s	tTuplecBs eZdZd„Zd„ZRS(s¤Something which must be a fixed-length tuple.

    @param schema: A sequence of schemas, which will be applied to
        each value in the tuple respectively.
    cGs
||_dS(N(R(RR((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR}scCs´t|tƒs%td|fƒ‚nt|ƒt|jƒkrktdt|jƒt|ƒ|fƒ‚ng}x6t|j|ƒD]"\}}|j|j|ƒƒq„Wt|ƒS(Ns%r is not a tuplesNeed %s items, got %s in %r(R
ttupleRtlenRtziptappendR(RRt	new_valueR((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR€s%(RRRRR(((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR"vs	tKeyDictcBs#eZdZdd„Zd„ZRS(séSomething which must be a C{dict} with defined keys.

    The keys must be constant and the values must match a per-key schema.

    @param schema: A dict mapping keys to schemas that the values of those
        keys must match.
    cCs1|dkrg}nt|ƒ|_||_dS(N(tNonetsettoptionalR(RRR+((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR”s	c	Cs"i}t|tƒs+td|fƒ‚nxœ|jƒD]Ž\}}||jkrotd||jfƒ‚ny|j|j|ƒ||<Wq8tk
rÅ}td|||j||fƒ‚q8Xq8Wt|jƒƒ}t|jjƒƒ|j}||}|rtd|fƒ‚n|S(Ns%r is not a dict.s%r is not a valid key as per %rs7Value of %r key of dict %r could not coerce with %s: %ssMissing keys %s(	R
tdictRt	iteritemsRRR*tkeysR+(	RRtnew_dicttktvRtnew_keyst
required_keystmissing((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyRšs&%
N(RRRR)RR(((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR(ŒstDictcBs eZdZd„Zd„ZRS(s°Something which must be a C{dict} with arbitrary keys.

    @param key_schema: The schema that keys must match.
    @param value_schema: The schema that values must match.
    cCs||_||_dS(N(t
key_schematvalue_schema(RR6R7((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR·s	cCsnt|tƒs%td|fƒ‚ni}x<|jƒD].\}}|jj|ƒ||jj|ƒ<q8W|S(Ns%r is not a dict.(R
R,RtitemsR7RR6(RRR/R0R1((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR»s&(RRRRR(((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR5°s	tMessagecBs&eZdZddd„Zd„ZRS(s

    Like L{KeyDict}, but with three predefined keys: C{type}, C{api},
    and C{timestamp}. Of these, C{api} and C{timestamp} are optional.


    @param type: The type of the message. The C{type} key will need to
        match this as a constant.
    @param schema: A dict of additional schema in a format L{KeyDict}
        will accept.
    @param optional: An optional list of keys that should be optional.
    @param api: The server API version needed to send this message,
        if C{None} any version is fine.
    cCs™||_||_tƒ|d<ttƒtdƒƒ|d<t|ƒ|d<|dk	rm|jddgƒnddg}tt	|ƒj
|d|ƒdS(Nt	timestamptapittypeR+(R<R;RR	RRR)textendtsuperR9R(RR<RR+R;((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyRÒs		
cCsLx3|jƒD]%}||jkr
|j|ƒq
q
Wtt|ƒj|ƒS(N(R.RtpopR>R9R(RRR0((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyRÞsN(RRRR)RR(((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyR9Äs
N(Rt	ExceptionRtobjectRR	RRRRRRR"R(R5R9(((s4/usr/lib/python2.7/dist-packages/landscape/schema.pyt<module>s$