FHSc@sdZddlZddlZddlZddlZddlZied6ed6ed6ed6ed6ed6ed 6Zied 6Z d Z d Z d Z d Z dZdZdZdejjfdYZdefdYZdefdYZdS(sTokenize DNS master file formatiNt s s t;t(t)t"iiiiiiitUngetBufferFullcBseZdZRS(sRRaised when an attempt is made to unget a token when the unget buffer is full.(t__name__t __module__t__doc__(((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyR,stTokencBseZdZdedZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZRS(sA DNS master file format token. @ivar ttype: The token type @type ttype: int @ivar value: The token value @type value: string @ivar has_escape: Does the token value contain escapes? @type has_escape: bool tcCs||_||_||_dS(sInitialize a token instance. @param ttype: The token type @type ttype: int @param value: The token value @type value: string @param has_escape: Does the token value contain escapes? @type has_escape: bool N(tttypetvaluet has_escape(tselfR R R ((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt__init__<s  cCs |jtkS(N(R tEOF(R((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pytis_eofJscCs |jtkS(N(R tEOL(R((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pytis_eolMscCs |jtkS(N(R t WHITESPACE(R((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt is_whitespacePscCs |jtkS(N(R t IDENTIFIER(R((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt is_identifierSscCs |jtkS(N(R t QUOTED_STRING(R((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pytis_quoted_stringVscCs |jtkS(N(R tCOMMENT(R((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt is_commentYscCs |jtkS(N(R t DELIMITER(R((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt is_delimiter\scCs|jtkp|jtkS(N(R RR(R((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt is_eol_or_eof_scCs5t|tstS|j|jko4|j|jkS(N(t isinstanceR tFalseR R (Rtother((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt__eq__bscCs5t|tstS|j|jkp4|j|jkS(N(RR tTrueR R (RR!((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt__ne__hscCsd|j|jfS(Ns%d "%s"(R R (R((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt__str__nscCsu|js |Sd}t|j}d}x:||krd|j|}|d7}|dkrW||krutjjn|j|}|d7}|jrW||krtjjn|j|}|d7}||krtjjn|j|}|d7}|jo|js#tjjntt |dt |dt |}qWn||7}q+Wt |j |S(NR iis\idi ( R tlenR tdnst exceptiont UnexpectedEndtisdigitt SyntaxErrortchrtintR R (Rt unescapedtltitctc2tc3((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pytunescapeqs6              4cCsdS(Ni((R((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt__len__scCst|j|jfS(N(titerR R (R((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt__iter__scCs0|dkr|jS|dkr&|jStdS(Nii(R R t IndexError(RR0((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt __getitem__s   (RRRR RRRRRRRRRR"R$R%R4R5R7R9(((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyR 1s"               t TokenizercBseZdZejddZdZdZdZ dZ e e dZ dZ dZd Zd Zd Zd Zd ZddZddZddZdZdZRS(sA DNS master file format tokenizer. A token is a (type, value) tuple, where I{type} is an int, and I{value} is a string. The valid types are EOF, EOL, WHITESPACE, IDENTIFIER, QUOTED_STRING, COMMENT, and DELIMITER. @ivar file: The file to tokenize @type file: file @ivar ungotten_char: The most recently ungotten character, or None. @type ungotten_char: string @ivar ungotten_token: The most recently ungotten token, or None. @type ungotten_token: (int, string) token tuple @ivar multiline: The current multiline level. This value is increased by one every time a '(' delimiter is read, and decreased by one every time a ')' delimiter is read. @type multiline: int @ivar quoting: This variable is true if the tokenizer is currently reading a quoted string. @type quoting: bool @ivar eof: This variable is true if the tokenizer has encountered EOF. @type eof: bool @ivar delimiters: The current delimiter dictionary. @type delimiters: dict @ivar line_number: The current line number @type line_number: int @ivar filename: A filename that will be returned by the L{where} method. @type filename: string cCst|tr6tj|}|dkrcd}qcn-|dkrc|tjkrZd}qcd}n||_d|_d|_ d|_ t |_ t |_ t|_d|_||_dS(sInitialize a tokenizer instance. @param f: The file to tokenize. The default is sys.stdin. This parameter may also be a string, in which case the tokenizer will take its input from the contents of the string. @type f: file or string @param filename: the name of the filename that the L{where} method will return. @type filename: string sssiiN(Rtstrt cStringIOtStringIOtNonetsyststdintfilet ungotten_chartungotten_tokent multilineR tquotingteoft _DELIMITERSt delimiterst line_numbertfilename(RtfRJ((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyRs"              cCs|jdkrl|jr!d}q~|jjd}|dkrKt|_q~|dkr~|jd7_q~n|j}d|_|S(s<Read a character from input. @rtype: string R is N(RBR>RFRAtreadR#RI(RR1((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt _get_chars       cCs|j|jfS(sReturn the current location in the input. @rtype: (string, int) tuple. The first item is the filename of the input, the second is the current line number. (RJRI(R((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pytwherescCs%|jdk rtn||_dS(sEUnget a character. The unget buffer for characters is only one character large; it is an error to try to unget a character when the unget buffer is not empty. @param c: the character to unget @type c: string @raises UngetBufferFull: there is already an ungotten char N(RBR>R(RR1((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt _unget_chars  cCsod}xbtrj|j}|dkr]|dkr]|dksI|j r]|j||Sn|d7}q WdS(s(Consume input until a non-whitespace character is encountered. The non-whitespace character is then ungotten, and the number of whitespace characters consumed is returned. If the tokenizer is in multiline mode, then newlines are whitespace. @rtype: int iRs s iN(R#RMRDRO(RtskippedR1((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pytskip_whitespaces    c Cs|jdk rZ|j}d|_|jr:|rW|SqZ|jrS|rW|SqZ|Sn|j}|r|dkrttdSd}t}t}xt rA|j }|dks||j kr|dkr|j rt jjn|dkr|tkr|dkr.|jd7_|jqq|dkrw|jdksXt jjn|jd8_|jqq|dkr|j st |_ t|_ t}qqt|_ t|_ |jqq|dkrttdS|d krx6|j }|dks|dkrPn||7}qW|rJ|j|tt|S|dkr~|jrtt jjd nttS|jr|jd}qqttdSq|}t}n |j|Png|j r|d kr|j }|dkr t jjn|jr|j }|dkr<t jjn|j } |dkrct jjn|jox| jst jjntt|d t|d t| }qq4|dkr4t jjdq4nR|d kr4||7}t }|j }|dks"|dkr4t jjq4n||7}qW|dkr|tkr|jrxt jjd nt}nt|||S(sGet the next token. @param want_leading: If True, return a WHITESPACE token if the first character read is whitespace. The default is False. @type want_leading: bool @param want_comment: If True, return a COMMENT token if the first token read is a comment. The default is False. @type want_comment: bool @rtype: Token object @raises dns.exception.UnexpectedEnd: input ended prematurely @raises dns.exception.SyntaxError: input was badly formed iRR RiRRs Rsunbalanced parenthesess\idi snewline in quoted stringN(RCR>RRRQR RRR R#RMRHRER'R(R)RRDR+t_QUOTING_DELIMITERSRGRRORRRR*R,R-( Rt want_leadingt want_commentttokenRPR R R1R2R3((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pytgets                                         4      cCs%|jdk rtn||_dS(s@Unget a token. The unget buffer for tokens is only one token large; it is an error to try to unget a token when the unget buffer is not empty. @param token: the token to unget @type token: Token object @raises UngetBufferFull: there is already an ungotten token N(RCR>R(RRU((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pytungets  cCs%|j}|jr!tn|S(sLReturn the next item in an iteration. @rtype: (int, string) (RVRt StopIteration(RRU((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pytnexts   cCs|S(N((R((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyR7scCsd|jj}|js3tjjdn|jjsWtjjdnt|jS(s|Read the next token and interpret it as an integer. @raises dns.exception.SyntaxError: @rtype: int sexpecting an identifiersexpecting an integer( RVR4RR'R(R+R R*R-(RRU((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pytget_ints  cCsA|j}|dks$|dkr=tjjd|n|S(sRead the next token and interpret it as an 8-bit unsigned integer. @raises dns.exception.SyntaxError: @rtype: int iis#%d is not an unsigned 8-bit integer(RZR'R(R+(RR ((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt get_uint8s cCsA|j}|dks$|dkr=tjjd|n|S(sRead the next token and interpret it as a 16-bit unsigned integer. @raises dns.exception.SyntaxError: @rtype: int iis$%d is not an unsigned 16-bit integer(RZR'R(R+(RR ((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt get_uint16s cCs|jj}|js3tjjdn|jjsWtjjdnt|j}|dks~|dkrtjjd|n|S(sRead the next token and interpret it as a 32-bit unsigned integer. @raises dns.exception.SyntaxError: @rtype: int sexpecting an identifiersexpecting an integerils$%d is not an unsigned 32-bit integer( RVR4RR'R(R+R R*tlong(RRUR ((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt get_uint32s cCsF|jj}|jp'|js?tjjdn|jS(s}Read the next token and interpret it as a string. @raises dns.exception.SyntaxError: @rtype: string sexpecting a string(RVR4RRR'R(R+R (RtoriginRU((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyt get_stringscCs:|jj}|js3tjjdn|jS(sRead the next token and raise an exception if it is not an identifier. @raises dns.exception.SyntaxError: @rtype: string sexpecting an identifier(RVR4RR'R(R+R (RR_RU((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pytget_identifiers cCsC|j}|js-tjjdntjj|j|S(sRead the next token and interpret it as a DNS name. @raises dns.exception.SyntaxError: @rtype: dns.name.Name objectsexpecting an identifier(RVRR'R(R+tnamet from_textR (RR_RU((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pytget_names  cCsD|j}|js=tjjd|j|jfn|jS(sRead the next token and raise an exception if it isn't EOL or EOF. @raises dns.exception.SyntaxError: @rtype: string s expected EOL or EOF, got %d "%s"(RVRR'R(R+R R (RRU((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pytget_eols  %cCsF|jj}|js3tjjdntjj|jS(Nsexpecting an identifier( RVR4RR'R(R+tttlRcR (RRU((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pytget_ttls N(RRRR?R@R>RRMRNRORQR RVRWRYR7RZR[R\R^R`RaRdReRg(((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyR:s&   z     (RR<R?t dns.exceptionR'tdns.nametdns.ttlR#RGRRRRRRRRRR(t DNSExceptionRtobjectR R:(((s3/usr/lib64/python2.7/site-packages/dns/tokenizer.pyts0       m