AlkantarClanX12

Your IP : 18.116.49.243


Current Path : /lib64/python2.7/site-packages/dns/
Upload File :
Current File : //lib64/python2.7/site-packages/dns/name.pyc

�
�آSc@s/dZddlZddlZddlZddlZejdkrTddlZnddlZ	ddl
Z	dZdZdZ
dZdZd	e	jjfd
��YZde	jjfd��YZd
e	jjfd��YZde	jjfd��YZde	jjfd��YZde	jjfd��YZde	jjfd��YZde	jjfd��YZde	jjfd��YZied6ed6ed6ed6ed6ed 6ed!6ed"6Zed#�Z d$�Z!d%e"fd&��YZ#e#d'g�Z$e#g�Z%e$d(�Z&e$d)�Z'd*�Z(dS(+s�DNS Names.

@var root: The DNS root name.
@type root: dns.name.Name object
@var empty: The empty DNS name.
@type empty: dns.name.Name object
i����Niiiiiit
EmptyLabelcBseZdZRS(sRaised if a label is empty.(t__name__t
__module__t__doc__(((s./usr/lib64/python2.7/site-packages/dns/name.pyR)st	BadEscapecBseZdZRS(s;Raised if an escaped code in a text format name is invalid.(RRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyR-st
BadPointercBseZdZRS(sCRaised if a compression pointer points forward instead of backward.(RRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyR1stBadLabelTypecBseZdZRS(s:Raised if the label type of a wire format name is unknown.(RRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyR5stNeedAbsoluteNameOrOrigincBseZdZRS(s~Raised if an attempt is made to convert a non-absolute name to
    wire when there is also a non-absolute (or missing) origin.(RRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyR9stNameTooLongcBseZdZRS(s&Raised if a name is > 255 octets long.(RRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyR>stLabelTooLongcBseZdZRS(s&Raised if a label is > 63 octets long.(RRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyR	BstAbsoluteConcatenationcBseZdZRS(sbRaised if an attempt is made to append anything other than the
    empty name to an absolute name.(RRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyR
FstNoParentcBseZdZRS(sVRaised if an attempt is made to get the parent of the root name
    or the empty name.(RRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyRKst"t(t)t.t;s\t@t$cCs�d}x�|D]�}|tkr0|d|7}q
t|�dkrat|�dkra||7}q
|r�t|�dkr�||7}q
|dt|�7}q
W|S(s�Escape the characters in label which need it.
    @param unicode_mode: escapify only special and whitespace (<= 0x20)
    characters
    @returns: the escaped string
    @rtype: stringts\i is\%03d(t_escapedtord(tlabeltunicode_modettexttc((s./usr/lib64/python2.7/site-packages/dns/name.pyt	_escapify[s
$

cCs�t|�}d}d}d}xh|D]`}t|�}||d7}|dkrZt�n|dkr{|dkr{|}n|d7}q%W|dkr�t�n|dkr�||dkr�t�ndS(siCheck for empty labels in the middle of a label sequence,
    labels that are too long, and for too many labels.
    @raises NameTooLong: the name as a whole is too long
    @raises LabelTooLong: an individual label is too long
    @raises EmptyLabel: a label is empty (i.e. the root label) and appears
    in a position other than the end of the label sequenceii����ii?Ri�N(tlenR	RR(tlabelstlttotaltitjRtll((s./usr/lib64/python2.7/site-packages/dns/name.pyt_validate_labelsns 
			tNamecBsaeZdZdgZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zed�Zed�Zd$d�Zd$d$d$d�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d �Z$d!�Z%d$e&d"�Z'd#�Z(RS(%s�A DNS name.

    The dns.name.Name class represents a DNS name as a tuple of labels.
    Instances of the class are immutable.

    @ivar labels: The tuple of labels in the name. Each label is a string of
    up to 63 octets.RcCs0tt|�jdt|��t|j�dS(s�Initialize a domain name from a list of labels.
        @param labels: the labels
        @type labels: any iterable whose values are strings
        RN(tsuperR#t__setattr__ttupleR"R(tselfR((s./usr/lib64/python2.7/site-packages/dns/name.pyt__init__�scCstd��dS(Ns+object doesn't support attribute assignment(t	TypeError(R'tnametvalue((s./usr/lib64/python2.7/site-packages/dns/name.pyR%�scCs
t|j�S(N(R#R(R'((s./usr/lib64/python2.7/site-packages/dns/name.pyt__copy__�scCsttj|j|��S(N(R#tcopytdeepcopyR(R'tmemo((s./usr/lib64/python2.7/site-packages/dns/name.pyt__deepcopy__�scCs&t|j�dko%|jddkS(sXIs the most significant label of this name the root label?
        @rtype: bool
        ii����R(RR(R'((s./usr/lib64/python2.7/site-packages/dns/name.pytis_absolute�scCs&t|j�dko%|jddkS(s\Is this name wild?  (I.e. Is the least significant label '*'?)
        @rtype: bool
        it*(RR(R'((s./usr/lib64/python2.7/site-packages/dns/name.pytis_wild�scCsZd}x@|jD]5}x,|D]$}||d>t|j��7}qWqWt|tj�S(sHReturn a case-insensitive hash of the name.
        @rtype: int
        li(RRtlowertinttsystmaxint(R'thRR((s./usr/lib64/python2.7/site-packages/dns/name.pyt__hash__�s

&c
Cs�|j�}|j�}||krG|r7tddfStddfSnt|j�}t|j�}||}|dkr�|}n|}d}d}	t}
x�|dkrd|d8}|d8}|d8}|j|j�}|j|j�}||kr#d}|	dkrt}
n|
||	fS||krWd}|	dkrJt}
n|
||	fS|	d7}	q�W|}|dkr�t}
n|dkr�t}
nt}
|
||	fS(s�Compare two names, returning a 3-tuple (relation, order, nlabels).

        I{relation} describes the relation ship beween the names,
        and is one of: dns.name.NAMERELN_NONE,
        dns.name.NAMERELN_SUPERDOMAIN, dns.name.NAMERELN_SUBDOMAIN,
        dns.name.NAMERELN_EQUAL, or dns.name.NAMERELN_COMMONANCESTOR

        I{order} is < 0 if self < other, > 0 if self > other, and ==
        0 if self == other.  A relative name is always less than an
        absolute name.  If both names have the same relativity, then
        the DNSSEC order relation is used to order them.

        I{nlabels} is the number of significant labels that the two names
        have in common.
        iii����(	R1t
NAMERELN_NONERRR4tNAMERELN_COMMONANCESTORtNAMERELN_SUPERDOMAINtNAMERELN_SUBDOMAINtNAMERELN_EQUAL(
R'tothertsabstoabstl1tl2tldiffRtordertnlabelstnamerelntlabel1tlabel2((s./usr/lib64/python2.7/site-packages/dns/name.pytfullcompare�sN

	


	
	
		cCs8|j|�\}}}|tks0|tkr4tStS(soIs self a subdomain of other?

        The notion of subdomain includes equality.
        @rtype: bool
        (RJR=R>tTruetFalse(R'R?tnrtotnl((s./usr/lib64/python2.7/site-packages/dns/name.pytis_subdomain�scCs8|j|�\}}}|tks0|tkr4tStS(sqIs self a superdomain of other?

        The notion of subdomain includes equality.
        @rtype: bool
        (RJR<R>RKRL(R'R?RMRNRO((s./usr/lib64/python2.7/site-packages/dns/name.pytis_superdomainscCs&tg|jD]}|j�^q
�S(s�Return a name which is equal to the current name, but is in
        DNSSEC canonical form.
        @rtype: dns.name.Name object
        (R#RR4(R'tx((s./usr/lib64/python2.7/site-packages/dns/name.pytcanonicalizescCs.t|t�r&|j|�ddkStSdS(Nii(t
isinstanceR#RJRL(R'R?((s./usr/lib64/python2.7/site-packages/dns/name.pyt__eq__scCs.t|t�r&|j|�ddkStSdS(Nii(RTR#RJRK(R'R?((s./usr/lib64/python2.7/site-packages/dns/name.pyt__ne__ scCs.t|t�r&|j|�ddkStSdS(Nii(RTR#RJtNotImplemented(R'R?((s./usr/lib64/python2.7/site-packages/dns/name.pyt__lt__&scCs.t|t�r&|j|�ddkStSdS(Nii(RTR#RJRW(R'R?((s./usr/lib64/python2.7/site-packages/dns/name.pyt__le__,scCs.t|t�r&|j|�ddkStSdS(Nii(RTR#RJRW(R'R?((s./usr/lib64/python2.7/site-packages/dns/name.pyt__ge__2scCs.t|t�r&|j|�ddkStSdS(Nii(RTR#RJRW(R'R?((s./usr/lib64/python2.7/site-packages/dns/name.pyt__gt__8scCsd|j�dS(Ns
<DNS name t>(t__str__(R'((s./usr/lib64/python2.7/site-packages/dns/name.pyt__repr__>scCs
|jt�S(N(tto_textRL(R'((s./usr/lib64/python2.7/site-packages/dns/name.pyR]AscCs�t|j�dkrdSt|j�dkrE|jddkrEdS|rg|j�rg|jd }n	|j}djtt|��}|S(s�Convert name to text format.
        @param omit_final_dot: If True, don't emit the final dot (denoting the
        root label) for absolute names.  The default is False.
        @rtype: string
        iRiRRi����(RRR1tjointmapR(R'tomit_final_dotRts((s./usr/lib64/python2.7/site-packages/dns/name.pyR_Ds(	cCs�t|j�dkrdSt|j�dkrE|jddkrEdS|rg|j�rg|jd }n	|j}djg|D]!}ttjj|�t�^q}�}|S(sConvert name to Unicode text format.

        IDN ACE lables are converted to Unicode.

        @param omit_final_dot: If True, don't emit the final dot (denoting the
        root label) for absolute names.  The default is False.
        @rtype: string
        iu@iRu.i����(	RRR1R`Rt	encodingstidnat	ToUnicodeRK(R'RbRRRRc((s./usr/lib64/python2.7/site-packages/dns/name.pyt
to_unicodeVs
(	7cCs�|j�sV|dks%|j�r.t�nt|j�}|jt|j��n	|j}g|D](}dtt|��|j�f^qf}dj	|�S(sConvert name to a format suitable for digesting in hashes.

        The name is canonicalized and converted to uncompressed wire format.

        @param origin: If the name is relative and origin is not None, then
        origin will be appended to it.
        @type origin: dns.name.Name object
        @raises NeedAbsoluteNameOrOrigin: All names in wire format are
        absolute.  If self is a relative name, then an origin must be supplied;
        if it is missing, then this exception is raised
        @rtype: string
        s%s%sRN(
R1tNoneRtlistRtextendtchrRR4R`(R'toriginRRRtdlabels((s./usr/lib64/python2.7/site-packages/dns/name.pyt
to_digestableks		5c
Cs�|dkr!tj�}t}nt}|j�s}|dksL|j�rUt�nt|j�}|j	t|j��n	|j}d}x|D]�}t
||�}|d7}|dk	r�|j|�}	nd}	|	dk	rd|	}
tj
d|
�}|j|�Pq�|dk	rVt|�dkrV|j�}	|	dkrV|	||<qVnt|�}|jt|��|dkr�|j|�q�q�W|r�|j�SdS(s�Convert name to wire format, possibly compressing it.

        @param file: the file where the name is emitted (typically
        a cStringIO file).  If None, a string containing the wire name
        will be returned.
        @type file: file or None
        @param compress: The compression table.  If None (the default) names
        will not be compressed.
        @type compress: dict
        @param origin: If the name is relative and origin is not None, then
        origin will be appended to it.
        @type origin: dns.name.Name object
        @raises NeedAbsoluteNameOrOrigin: All names in wire format are
        absolute.  If self is a relative name, then an origin must be supplied;
        if it is missing, then this exception is raised
        iii�s!Hi�?N(Rht	cStringIOtStringIORKRLR1RRiRRjR#tgettstructtpacktwriteRttellRktgetvalue(
R'tfiletcompressRltwant_returnRRRtntposR+RcR((s./usr/lib64/python2.7/site-packages/dns/name.pytto_wire�s@			



cCs
t|j�S(s@The length of the name (in labels).
        @rtype: int
        (RR(R'((s./usr/lib64/python2.7/site-packages/dns/name.pyt__len__�scCs|j|S(N(R(R'tindex((s./usr/lib64/python2.7/site-packages/dns/name.pyt__getitem__�scCs|j||!S(N(R(R'tstarttstop((s./usr/lib64/python2.7/site-packages/dns/name.pyt__getslice__�scCs
|j|�S(N(tconcatenate(R'R?((s./usr/lib64/python2.7/site-packages/dns/name.pyt__add__�scCs
|j|�S(N(t
relativize(R'R?((s./usr/lib64/python2.7/site-packages/dns/name.pyt__sub__�scCs�t|j�}|dkr+|tjjfS||krGtjj|fS|dks_||krntd��nt|| �t||�fS(s(Split a name into a prefix and suffix at depth.

        @param depth: the number of labels in the suffix
        @type depth: int
        @raises ValueError: the depth was not >= 0 and <= the length of the
        name.
        @returns: the tuple (prefix, suffix)
        @rtype: tuple
        is0depth must be >= 0 and <= the length of the name(RRtdnsR*temptyt
ValueErrorR#(R'tdepthR((s./usr/lib64/python2.7/site-packages/dns/name.pytsplit�scCsV|j�r't|�dkr't�nt|j�}|jt|j��t|�S(s�Return a new name which is the concatenation of self and other.
        @rtype: dns.name.Name object
        @raises AbsoluteConcatenation: self is absolute and other is
        not the empty name
        i(R1RR
RiRRjR#(R'R?R((s./usr/lib64/python2.7/site-packages/dns/name.pyR��s
	cCs8|dk	r0|j|�r0t|t|� �S|SdS(s�If self is a subdomain of origin, return a new name which is self
        relative to origin.  Otherwise return self.
        @rtype: dns.name.Name object
        N(RhRPR#R(R'Rl((s./usr/lib64/python2.7/site-packages/dns/name.pyR��scCs!|j�s|j|�S|SdS(s�If self is a relative name, return a new name which is the
        concatenation of self and origin.  Otherwise return self.
        @rtype: dns.name.Name object
        N(R1R�(R'Rl((s./usr/lib64/python2.7/site-packages/dns/name.pytderelativize�s
cCs1|r)|r|j|�S|j|�Sn|SdS(sReturn a name with the relativity desired by the caller.  If
        origin is None, then self is returned.  Otherwise, if
        relativize is true the name is relativized, and if relativize is
        false the name is derelativized.
        @rtype: dns.name.Name object
        N(R�R�(R'RlR�((s./usr/lib64/python2.7/site-packages/dns/name.pytchoose_relativitys

cCs2|tks|tkr!t�nt|jd�S(s�Return the parent of the name.
        @rtype: dns.name.Name object
        @raises NoParent: the name is either the root name or the empty name,
        and thus has no parent.
        i(trootR�RR#R(R'((s./usr/lib64/python2.7/site-packages/dns/name.pytparents	N()RRRt	__slots__R(R%R,R0R1R3R9RJRPRQRSRURVRXRYRZR[R^R]RLR_RgRhRnR|R}RR�R�R�R�R�R�R�RKR�R�(((s./usr/lib64/python2.7/site-packages/dns/name.pyR#�sH										=											8							
		RcCs�t|t�std��n|dkp6t|t�sHtd��ng}d}t}d}d}|dkr{d}n|r;|dkr�tdg�SxQ|D]I}|rR|dkr�|j�r�t|�}|d7}qO||7}t}q�|j�st�n|d	9}|t|�7}|d7}|d
kr�t}|t	|�7}q�q�|dks�|dks�|dks�|d
kr�t
|�dkr�t�n|jt
jj|��d}q�|dkr�t}d}d}q�||7}q�W|r�t�nt
|�dkr+|jt
jj|��q;|jd�nt
|�dks]|ddkr�|dk	r�|jt|j��nt|�S(sxConvert unicode text into a Name object.

    Lables are encoded in IDN ACE form.

    @rtype: dns.name.Name object
    s0input to from_unicode() must be a unicode stringsorigin must be a Name or Noneuiu@u.Rii
iu。u.u。u\i����N(RTtunicodeR�RhR#RLtisdigitR5RRkRRtappendRdRetToASCIIRKRjRiR(RRlRRtescapingtedigitsRR((s./usr/lib64/python2.7/site-packages/dns/name.pytfrom_unicode"sb	



		

				.cCs{t|t�sIt|t�r:tjdkr:t||�Std��n|d
kpat|t�sstd��ng}d}t	}d}d}|dkr�d}n|r*|dkr�tdg�Sx!|D]}|r}|dkr|j
�r	t|�}|d7}qz||7}t	}q�|j
�s1t�n|d	9}|t|�7}|d7}|d
kr�t	}|t
|�7}q�q�|dkr�t|�dkr�t�n|j|�d}q�|dkr�t}d}d}q�||7}q�W|r�t�nt|�dkr|j|�q*|jd�nt|�dksL|ddkrq|d
k	rq|jt|j��nt|�S(sFConvert text into a Name object.
    @rtype: dns.name.Name object
    is%input to from_text() must be a stringsorigin must be a Name or NoneRiRRii
is\i����N(RTtstrR�R6t
hexversionR�R�RhR#RLR�R5RRkRRR�RKRjRiR(RRlRRR�R�RR((s./usr/lib64/python2.7/site-packages/dns/name.pyt	from_text`sd
	



		

	
			.cCs�t|t�std��ntjj|�}g}|}d}t||�}|d7}d}x|dkrf|dkr�|j||||!j��||7}|dkr0||7}q0no|dkr*|d@dt||�}|dkr|d7}n||krt	�n|}|d7}nt
�t||�}|d7}|dkre|d7}qeqeW|jd�t|�|fS(	s^Convert possibly compressed wire format into a Name.
    @param message: the entire DNS message
    @type message: string
    @param current: the offset of the beginning of the name from the start
    of the message
    @type current: int
    @raises dns.name.BadPointer: a compression pointer did not point backwards
    in the message
    @raises dns.name.BadLabelType: an invalid label type was encountered.
    @returns: a tuple consisting of the name that was read and the number
    of bytes of the wire format message which were consumed reading it
    @rtype: (dns.name.Name object, int) tuple
    s*input to from_wire() must be a byte stringiii@i�i?iR(RTR�R�R�twiredatat
maybe_wrapRR�tunwrapRRR#(tmessagetcurrentRtbiggest_pointerthopstcounttcused((s./usr/lib64/python2.7/site-packages/dns/name.pyt	from_wire�s<


	


()RRoRrR6R-R�tencodings.idnaRdt
dns.exceptionR�tdns.wiredataR:R<R=R>R;t	exceptiontSyntaxErrorRRt	FormErrorRRtDNSExceptionRRR	R
RRKRRLRR"tobjectR#R�R�R�R�R�(((s./usr/lib64/python2.7/site-packages/dns/name.pyt<module>sP
	��>=