%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/dns/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/dns/__pycache__/tokenizer.cpython-312.pyc

�

5��e\����dZddlZddlZddlmZmZmZmZddlZ	ddl
Z	ddlZ	hd�ZdhZ
dZdZdZdZd	Zd
ZdZGd�d
e	j*j,�ZGd�d�ZGd�d�Zy)zTokenize DNS zone file format�N)�Any�List�Optional�Tuple>�	�
� �"�(�)�;r
������c��eZdZdZy)�UngetBufferFullzDAn attempt was made to unget a token when the unget buffer was full.N)�__name__�
__module__�__qualname__�__doc__���//usr/lib/python3/dist-packages/dns/tokenizer.pyrr(s��Nrrc
��eZdZdZ			ddedededeefd�Z	defd	�Z
defd
�Zdefd�Zdefd�Z
defd
�Zdefd�Zdefd�Zdefd�Zd�Zd�Zd�Zdd�Zdd�Zy)�Tokenz�A DNS zone file format token.

    ttype: The token type
    value: The token value
    has_escape: Does the token value contain escapes?
    N�ttype�value�
has_escape�commentc�<�||_||_||_||_y)zInitialize a token instance.N)rr r!r")�selfrr r!r"s     r�__init__zToken.__init__4s ����
���
�$�����r�returnc�(�|jtk(S�N)r�EOF�r$s r�is_eofzToken.is_eofB����z�z�S� � rc�(�|jtk(Sr()r�EOLr*s r�is_eolzToken.is_eolEr,rc�(�|jtk(Sr()r�
WHITESPACEr*s r�
is_whitespacezToken.is_whitespaceH����z�z�Z�'�'rc�(�|jtk(Sr()r�
IDENTIFIERr*s r�
is_identifierzToken.is_identifierKr3rc�(�|jtk(Sr()r�
QUOTED_STRINGr*s r�is_quoted_stringzToken.is_quoted_stringNs���z�z�]�*�*rc�(�|jtk(Sr()r�COMMENTr*s r�
is_commentzToken.is_commentQs���z�z�W�$�$rc�(�|jtk(Sr()r�	DELIMITERr*s r�is_delimiterzToken.is_delimiterTs���z�z�Y�&�&rc�R�|jtk(xs|jtk(Sr()rr.r)r*s r�
is_eol_or_eofzToken.is_eol_or_eofWs���z�z�S� �5�D�J�J�#�$5�5rc��t|t�sy|j|jk(xr|j|jk(S)NF��
isinstancerrr �r$�others  r�__eq__zToken.__eq__Zs4���%��'���z�z�U�[�[�(�F�T�Z�Z�5�;�;�-F�Frc��t|t�sy|j|jk7xs|j|jk7S)NTrCrEs  r�__ne__zToken.__ne___s4���%��'���z�z�U�[�[�(�E�D�J�J�%�+�+�,E�Erc�8�d|j|jfzS)Nz%d "%s")rr r*s r�__str__z
Token.__str__ds���D�J�J��
�
�3�3�3rc�@�|js|Sd}t|j�}d}||k�r\|j|}|dz
}|dk(�r6||k\rtjj
�|j|}|dz
}|j
�r�||k\rtjj
�|j|}|dz
}||k\rtjj
�|j|}|dz
}|j
�r|j
�stjj�t|�dzt|�dzzt|�z}|dkDrtjj�t|�}||z
}||kr��\t|j|�S)N�rr�\�d�
�)r!�lenr �dns�	exception�
UnexpectedEnd�isdigit�SyntaxError�int�chrrr�r$�	unescaped�l�i�c�c2�c3�	codepoints        r�unescapezToken.unescapegsb������K��	���
�
�O��
���!�e��
�
�1�
�A�
��F�A��D�y���6��-�-�5�5�5��J�J�q�M���Q����9�9�;��A�v�!�m�m�9�9�9����A��B���F�A��A�v�!�m�m�9�9�9����A��B���F�A��J�J�L�R�Z�Z�\�!�m�m�7�7�7� #�A����s�2�w��|� ;�c�"�g� E�I� �3��!�m�m�7�7�7��I��A���N�I�/�!�e�0�T�Z�Z��+�+rc�v�d}t|j�}d}||k�r||j|}|dz
}|dk(�rH||k\rtjj�|j|}|dz
}|j�r�||k\rtjj�|j|}|dz
}||k\rtjj�|j|}|dz
}|j�r|j�stjj�t|�dzt|�dzzt|�z}|dkDrtjj�|d|zz
}n'||j�z
}n||j�z
}||kr��|t|jt|��S)	NrrrrNrOrPrQs%c)rRr rSrTrUrVrWrX�encoderr�bytesrZs        r�unescape_to_byteszToken.unescape_to_bytes�s}��2�	���
�
�O��
���!�e��
�
�1�
�A�
��F�A��D�y���6��-�-�5�5�5��J�J�q�M���Q����9�9�;��A�v�!�m�m�9�9�9����A��B���F�A��A�v�!�m�m�9�9�9����A��B���F�A��J�J�L�R�Z�Z�\�!�m�m�7�7�7� #�A����s�2�w��|� ;�c�"�g� E�I� �3��!�m�m�7�7�7���)�!4�4�I������+�I��Q�X�X�Z�'�	�?�!�e�@�T�Z�Z��y�!1�2�2r)rMFN)r&r)rrrrrXr�boolr�strr%r+r/r2r6r9r<r?rArGrIrKrbrfrrrrr,s����� �!%�������	�
�#���!��!�!��!�(�t�(�(�t�(�+�$�+�%�D�%�'�d�'�6�t�6�G�
F�
4�,�@<3rrc��eZdZdZej
ddfdedeedee	jjfd�Zdefd�Z
deeeffd	�Zd
eddfd�Zdefd�Zd)d
ededefd�Zdeddfd�Zd�ZeZd�Zd*dedefd�Zdefd�Zd*dedefd�Zd*dedefd�Zd*dedefd�Zd+deedefd�Zdefd�Z d+deede!efd�Z"d,dedefd �Z#			d-ded!ee	jjHd"ed#ee	jjHde	jjHf
d$�Z%			d-d!ee	jjHd"ed#ee	jjHde	jjHfd%�Z&defd&�Z'defd'�Z(defd(�Z)y).�	Tokenizera�A DNS zone file format tokenizer.

    A token object is basically a (type, value) tuple.  The valid
    types are EOF, EOL, WHITESPACE, IDENTIFIER, QUOTED_STRING,
    COMMENT, and DELIMITER.

    file: The file to tokenize

    ungotten_char: The most recently ungotten character, or None.

    ungotten_token: The most recently ungotten token, or None.

    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.

    quoting: This variable is true if the tokenizer is currently
    reading a quoted string.

    eof: This variable is true if the tokenizer has encountered EOF.

    delimiters: The current delimiter dictionary.

    line_number: The current line number

    filename: A filename that will be returned by the where() method.

    idna_codec: A dns.name.IDNACodec, specifies the IDNA
    encoder/decoder.  If None, the default IDNA 2003
    encoder/decoder is used.
    N�f�filename�
idna_codecc���t|t�rtj|�}|�Td}nQt|t�r(tj|j��}|�d}n|�|tjurd}nd}||_d|_	d|_
d|_d|_d|_
t|_d|_|�J�||_|� t$j&j(|_y||_y)a�Initialize a tokenizer instance.

        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.

        filename: the name of the filename that the where() method
        will return.

        idna_codec: A dns.name.IDNACodec, specifies the IDNA
        encoder/decoder.  If None, the default IDNA 2003
        encoder/decoder is used.
        Nz<string>z<stdin>z<file>rFr)rDrh�io�StringIOre�decode�sys�stdin�file�
ungotten_char�ungotten_token�	multiline�quoting�eof�_DELIMITERS�
delimiters�line_numberrlrS�name�	IDNA_2003rm)r$rkrlrms    rr%zTokenizer.__init__�s���(�a������A��A���%��
��5�
!����A�H�H�J�'�A���%������	�	�>�(�H�'�H���	�,0���/3������������%�������#�#�#� ��
���25�(�(�2D�2D�D�O�(�D�Orr&c���|j�U|jrd}|S|jjd�}|dk(r	d|_|S|dk(r|xjdz
c_|S|j}d|_|S)zRead a character from input.NrMrTr)ruryrt�readr|�r$r^s  r�	_get_charzTokenizer._get_chars������%��x�x������I�I�N�N�1�%����7�#�D�H����$�Y��$�$��)�$����"�"�A�!%�D���rc�2�|j|jfS)z�Return the current location in the input.

        Returns a (string, int) tuple.  The first item is the filename of
        the input, the second is the current line number.
        )rlr|r*s r�wherezTokenizer.where)s���
�
�t�/�/�0�0rr^c�6�|j�t�||_y)a%Unget 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.

        c: the character to unget
        raises UngetBufferFull: there is already an ungotten char
        N)rurr�s  r�_unget_charzTokenizer._unget_char2s�����)�!�!���rc��d}	|j�}|dk7r)|dk7r$|dk7s|js|j|�|S|dz
}�D)aFConsume 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.

        Returns the number of characters skipped.
        rr	rrr)r�rwr�)r$�skippedr^s   r�skip_whitespacezTokenizer.skip_whitespaceBsS�������� �A��C�x�A��I���I�d�n�n��$�$�Q�'�"�N��q�L�G�
r�want_leading�want_commentc���|j�=|j}d|_|j�r|r|S|j�r|r|S|S|j�}|r|dkDrt	t
d�Sd}t}d}	|j�}|dk(s||jv�r�|dk(r&|jrtjj�|dk(�r�|tk7�r�|dk(r&|xjdz
c_|j���|d	k(rO|jdkrtjj�|xjdzc_|j���|d
k(rJ|jsd|_	t |_t}��
d|_	t"|_|j���.|dk(rt	t$d�S|dk(r�	|j�}|dk(s|dk(rn||z
}�!|r!|j'|�t	t(|�S|dk(r<|jrtjjd
��t	t*|��S|jr|j�d}���t	t$d|��S|}t,}n|j'|�n�|jr$|dk(rtjjd��|dk(rG||z
}d}|j�}|dk(s|dk(r&|jstjj�||z
}���|dk(r:|tk7r1|jrtjjd
��t*}t	|||�S)a�Get the next token.

        want_leading: If True, return a WHITESPACE token if the
        first character read is whitespace.  The default is False.

        want_comment: If True, return a COMMENT token if the
        first token read is a comment.  The default is False.

        Raises dns.exception.UnexpectedEnd: input ended prematurely

        Raises dns.exception.SyntaxError: input was badly formed

        Returns a Token.
        Nrr	rMFTrrrr
rr
zunbalanced parentheses)r"znewline in quoted stringrN)rvr2r<r�rr1r5r�r{rxrSrTrUr8rwrW�_QUOTING_DELIMITERSrzr.r�r;r)r>)	r$r�r��utokenr��tokenrr!r^s	         r�getz
Tokenizer.getVs�� ���*��(�(�F�"&�D���#�#�%��!�M��"�"�$��!�M��
��&�&�(���G�a�K���S�)�)������
����� �A��B�w�!�t���.���7�t�|�|��-�-�5�5�5��B�;�5�M�#9��C�x����!�+���,�,�.� ��c���>�>�Q�.�"%�-�-�";�";�;����!�+���,�,�.� ��c��#�|�|�+/�D�L�.A�D�O�$1�E�$�+0�D�L�.9�D�O� �0�0�2�$��d��$�S�$�/�/��c��� $��� 0�A� �D�y�A��G� %�!�Q�J�E�	 �
(� �,�,�Q�/�#(��%�#8�8��"�W�#�~�~�&)�m�m�&?�&?�$<�'"�!"�$)��e�#<�<�!�^�^� �0�0�2�$&�E�$�#(��d�E�#B�B�
!"�� )���$�$�Q�'�����!�t�)��m�m�/�/�0J�K�K��d��
��
��!�
��N�N�$����7�q�D�y�����-�-�5�5�5��Q�J�E�O�P�B�;�5�M�1��~�~��m�m�/�/�0H�I�I��E��U�E�:�.�.rr�c�6�|j�t�||_y)aUnget 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.

        token: the token to unget

        Raises UngetBufferFull: there is already an ungotten token
        N)rvr�r$r�s  r�ungetzTokenizer.unget�s�����*�!�!�#��rc�R�|j�}|j�rt�|S)zHReturn the next item in an iteration.

        Returns a Token.
        )r�r+�
StopIterationr�s  r�nextzTokenizer.next�s#�����
���<�<�>����rc��|Sr(rr*s r�__iter__zTokenizer.__iter__�s���r�basec�:�|j�j�}|j�stjjd��|jj�stjjd��t|j|�S)z�Read the next token and interpret it as an unsigned integer.

        Raises dns.exception.SyntaxError if not an unsigned integer.

        Returns an int.
        �expecting an identifierzexpecting an integer)	r�rbr6rSrTrWr rVrX)r$r�r�s   r�get_intzTokenizer.get_int�sq�����
�#�#�%���"�"�$��-�-�+�+�,E�F�F��{�{�"�"�$��-�-�+�+�,B�C�C��5�;�;��%�%rc�~�|j�}|dks|dkDr"tjjd|z��|S)z�Read the next token and interpret it as an 8-bit unsigned
        integer.

        Raises dns.exception.SyntaxError if not an 8-bit unsigned integer.

        Returns an int.
        rrQz#%d is not an unsigned 8-bit integer�r�rSrTrW)r$r s  r�	get_uint8zTokenizer.get_uint8�sB��������1�9�����-�-�+�+�5��=��
��rc���|j|��}|dks|dkDrI|dk(r"tjjd|z��tjjd|z��|S)z�Read the next token and interpret it as a 16-bit unsigned
        integer.

        Raises dns.exception.SyntaxError if not a 16-bit unsigned integer.

        Returns an int.
        �r�ri���z*%o is not an octal unsigned 16-bit integerz$%d is not an unsigned 16-bit integerr��r$r�r s   r�
get_uint16zTokenizer.get_uint16so�����$��'���1�9���
��q�y��m�m�/�/�@�5�H����m�m�/�/�:�U�B����rc��|j|��}|dks|dkDr"tjjd|z��|S)z�Read the next token and interpret it as a 32-bit unsigned
        integer.

        Raises dns.exception.SyntaxError if not a 32-bit unsigned integer.

        Returns an int.
        r�rl��z$%d is not an unsigned 32-bit integerr�r�s   r�
get_uint32zTokenizer.get_uint32sH�����$��'���1�9��
�*��-�-�+�+�6��>��
��rc��|j|��}|dks|dkDr"tjjd|z��|S)z�Read the next token and interpret it as a 48-bit unsigned
        integer.

        Raises dns.exception.SyntaxError if not a 48-bit unsigned integer.

        Returns an int.
        r�rl���z$%d is not an unsigned 48-bit integerr�r�s   r�
get_uint48zTokenizer.get_uint48+sH�����$��'���1�9���/��-�-�+�+�6��>��
��r�
max_lengthc�F�|j�j�}|j�s/|j�stj
j
d��|r7t|j�|kDrtj
j
d��|jS)z�Read the next token and interpret it as a string.

        Raises dns.exception.SyntaxError if not a string.
        Raises dns.exception.SyntaxError if token value length
        exceeds max_length (if specified).

        Returns a string.
        zexpecting a stringzstring too long)	r�rbr6r9rSrTrWrRr )r$r�r�s   r�
get_stringzTokenizer.get_string;sx�����
�#�#�%���#�#�%��)?�)?�)A��-�-�+�+�,@�A�A��#�e�k�k�*�Z�7��-�-�+�+�,=�>�>��{�{�rc��|j�j�}|j�stjjd��|jS)z�Read the next token, which should be an identifier.

        Raises dns.exception.SyntaxError if not an identifier.

        Returns a string.
        r�)r�rbr6rSrTrWr r�s  r�get_identifierzTokenizer.get_identifierLsD�����
�#�#�%���"�"�$��-�-�+�+�,E�F�F��{�{�r�
max_tokensc��g}	|j�}|j�r|j|�	|S|j|�t	|�|k(r	|S�W)z�Return the remaining tokens on the line, until an EOL or EOF is seen.

        max_tokens: If not None, stop after this number of tokens.

        Returns a list of tokens.
        )r�rAr��appendrR)r$r��tokensr�s    r�
get_remainingzTokenizer.get_remainingYs`������H�H�J�E��"�"�$��
�
�5�!���
�
�M�M�%� ��6�{�j�(���
�r�allow_emptyc�F�d}	|j�j�}|j�r|j|�n:|j	�st
jj�||jz
}�z|s!|st
jjd��|S)aRead the remaining tokens on the line, which should be identifiers.

        Raises dns.exception.SyntaxError if there are no remaining tokens,
        unless `allow_empty=True` is given.

        Raises dns.exception.SyntaxError if a token is seen that is not an
        identifier.

        Returns a string containing a concatenation of the remaining
        identifiers.
        rMzexpecting another identifier)	r�rbrAr�r6rSrTrWr )r$r��sr�s    r�!concatenate_remaining_identifiersz+Tokenizer.concatenate_remaining_identifiersls���
����H�H�J�'�'�)�E��"�"�$��
�
�5�!���&�&�(��m�m�/�/�/�
�����A���q��-�-�+�+�,J�K�K��r�origin�
relativize�
relativize_toc��|j�stjjd��tjj|j||j�}|j|xs||�S)z�Try to interpret the token as a DNS name.

        Raises dns.exception.SyntaxError if not a name.

        Returns a dns.name.Name.
        r�)	r6rSrTrWr}�	from_textr rm�choose_relativity)r$r�r�r�r�r}s      r�as_namezTokenizer.as_name�s^���"�"�$��-�-�+�+�,E�F�F��x�x�!�!�%�+�+�v�t���G���%�%�m�&=�v�z�J�Jrc�J�|j�}|j||||�S)z�Read the next token and interpret it as a DNS name.

        Raises dns.exception.SyntaxError if not a name.

        Returns a dns.name.Name.
        )r�r�)r$r�r�r�r�s     r�get_namezTokenizer.get_name�s$�����
���|�|�E�6�:�}�E�Erc��|j�}|j�s8tjj	d|j
|jfz��|S)znRead the next token and raise an exception if it isn't EOL or
        EOF.

        Returns a string.
        z expected EOL or EOF, got %d "%s")r�rArSrTrWrr r�s  r�get_eol_as_tokenzTokenizer.get_eol_as_token�sN�����
���"�"�$��-�-�+�+�2�e�k�k�5�;�;�5O�O��
��rc�6�|j�jSr()r�r r*s r�get_eolzTokenizer.get_eol�s���$�$�&�,�,�,rc���|j�j�}|j�stjjd��tjj|j�S)z�Read the next token and interpret it as a DNS TTL.

        Raises dns.exception.SyntaxError or dns.ttl.BadTTL if not an
        identifier or badly formed.

        Returns an int.
        r�)	r�rbr6rSrTrW�ttlr�r r�s  r�get_ttlzTokenizer.get_ttl�sS�����
�#�#�%���"�"�$��-�-�+�+�,E�F�F��w�w� � ����-�-r)FF)rPr()F)NFN)*rrrrrrrsrrrhrSr}�	IDNACodecr%r�rrXr�r�r�rgrr�r�r��__next__r�r�r�r�r�r�r�r�rr�r��Namer�r�r�r�r�rrrrjrj�s`���D���"&�37�	/)��/)��3�-�/)��S�X�X�/�/�0�	/)�b�3��"1�u�S�#�X��1��S��T�� ���(m/��m/�D�m/�U�m/�^$�5�$�T�$� 	��H��

&�C�
&��
&��3�� �s��C��*�s��C�� �s��C�� �X�c�]��c��"������
���e���&�T��c��8+/� �15�K��K�������'�K��	K�
 ����
�
�.�K�

�����
K�(+/� �15�	F�������'�F��F� ����
�
�.�	F�


�����F� �%��-��-�.��.rrj)rrorr�typingrrrr�
dns.exceptionrS�dns.name�dns.ttlrzr�r)r.r1r5r8r;r>rT�DNSExceptionrrrjrrr�<module>r�s���$$�	�
�-�-����3���e������
�
�
�
��
�
��
�	�O�c�m�m�0�0�O�W3�W3�t~.�~.r

Zerion Mini Shell 1.0