%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/netaddr/ip/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/netaddr/ip/__pycache__/iana.cpython-312.pyc

�

���^�6��@�dZddlZddlmZmZddlmZmZddl	m
Z
mZmZm
Z
ddlmZmZmZiiiid�ZGd�d	ej&�ZGd
�de�ZGd�d
e�ZGd�de�ZGd�de�ZGd�de�ZGd�de�Zd�Zdd�Zd�Zd�Ze�y)a
Routines for accessing data published by IANA (Internet Assigned Numbers
Authority).

More details can be found at the following URLs :-

    - IANA Home Page - http://www.iana.org/
    - IEEE Protocols Information Home Page - http://www.iana.org/protocols/
�N)�make_parser�handler)�	Publisher�
Subscriber)�	IPAddress�	IPNetwork�IPRange�cidr_abbrev_to_verbose)�_dict_items�	_callable�_importlib_resources)�IPv4�IPv6�IPv6_unicast�	multicastc�&�eZdZdd�Zd�Zd�Zd�Zy)�SaxRecordParserNc�f�d|_d|_d|_d|_d|_d|_||_y)NrF)�_level�
_is_active�_record�
_tag_level�_tag_payload�_tag_feeding�	_callback)�self�callbacks  �1/usr/lib/python3/dist-packages/netaddr/ip/iana.py�__init__zSaxRecordParser.__init__3s5�������������� ��� ���!���c��|xjdz
c_|jdur=|dk(r7d|_|j|_i|_d|vr|d|jd<yyy|j|jdzk(rR|dk(r<d|vrHd|vrC|jj	|dg�}|j|d�yg|_d|_yyyd|_y)	N�F�recordT�date�xref�type�data)rrrr�
setdefault�appendrr)r�name�attrs�ls    r�startElementzSaxRecordParser.startElement<s������q����?�?�e�#��x��"&���"&�+�+���!����U�?�+0��=�D�L�L��(�#�	 ��[�[�D�O�O�a�/�
/��v�~��U�?�v������/�/��f�
�r�B�A��H�H�U�6�]�+�$&��!�$(��!�(7�?�!&�D�r c��|jdur�|dk(r_|j|jk(rFd|_d|_t|j�r|j	|j
�d|_nW|j|jdzk(r;|dk7r6dj
|j�|j
|<d|_d|_|xjdzc_y)NTr#Fr"r%�)	rrrrrr�joinrr)rr*s  r�
endElementzSaxRecordParser.endElementQs����?�?�d�"��x��D�O�O�t�{�{�$B�"'���"&����T�^�^�,��N�N�4�<�<�0�#���������!� 3�3��6�>�)+����1B�1B�)C�D�L�L��&�(,�D�%�(-�D�%����q��r c�X�|jdur|jj|�yy)NT)rrr))r�contents  r�
characterszSaxRecordParser.charactersas)������$����$�$�W�-�%r �N)�__name__�
__module__�__qualname__rr-r1r4�r rrr2s��"�&�*� .r rc�4��eZdZdZ�fd�Zd�Zd�Zd�Z�xZS)�XMLRecordParserzP
    A configurable Parser that understands how to parse XML based records.
    c����tt|��t�|_|jjt
|j��||_|jj|�y)z`
        Constructor.

        fh - a valid, open file handle to XML based record data.
        N)�superr;rr�	xmlparser�setContentHandlerr�consume_record�fh�__dict__�update�rrA�kwargs�	__class__s   �rrzXMLRecordParser.__init__ksQ���	�o�t�-�/�$�������(�(���9L�9L�)M�N�����
�
���V�$r c��|S)a
        This is the callback method invoked for every record. It is usually
        over-ridden by base classes to provide specific record-based logic.

        Any record can be vetoed (not passed to registered Subscriber objects)
        by simply returning None.
        r9)r�recs  r�process_recordzXMLRecordParser.process_recordzs	���
r c�N�|j|�}|�|j|�yyr5)rI�notify�rrHr#s   rr@zXMLRecordParser.consume_record�s)���$�$�S�)�����K�K���r c�N�|jj|j�y)z
        Parse and normalises records, notifying registered subscribers with
        record data as it is encountered.
        N)r>�parserA)rs rrNzXMLRecordParser.parse�s��
	
�����T�W�W�%r )	r6r7r8�__doc__rrIr@rN�
__classcell__�rFs@rr;r;fs����
%�� �
&r r;c�(��eZdZdZ�fd�Zd�Z�xZS)�
IPv4Parserz�
    A XMLRecordParser that understands how to parse and retrieve data records
    from the IANA IPv4 address space file.

    It can be found online here :-

        - http://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xml
    c�,��tt|�|�y)z�
        Constructor.

        fh - a valid, open file handle to an IANA IPv4 address space file.

        kwargs - additional parser options.
        N)r=rSrrDs   �rrzIPv4Parser.__init__�����	�j�$�(��,r c��i}dD].}t|j|d��j�||<�0d|dvr3|djd�\}}dt	|�t	|�fz|d<|dj�|d<|S)�l
        Callback method invoked for every record.

        See base class method for more details.
        )�prefix�designationr$�whois�statusr/�/rXz%d/%dr[)�str�get�strip�split�int�
capitalize)rrHr#�key�octetrXs      rrIzIPv4Parser.process_record�s�����G�	8�C��c�g�g�c�2�.�/�5�5�7�F�3�K�	8��&��"�"�$�X�.�4�4�S�9�O�U�F�&�#�e�*�c�&�k�)B�B�F�8��!�(�+�6�6�8��x���
r �r6r7r8rOrrIrPrQs@rrSrS�s����-�r rSc�(��eZdZdZ�fd�Zd�Z�xZS)�
IPv6Parserz�
    A XMLRecordParser that understands how to parse and retrieve data records
    from the IANA IPv6 address space file.

    It can be found online here :-

        - http://www.iana.org/assignments/ipv6-address-space/ipv6-address-space.xml
    c�,��tt|�|�y�z�
        Constructor.

        fh - a valid, open file handle to an IANA IPv6 address space file.

        kwargs - additional parser options.
        N)r=rgrrDs   �rrzIPv6Parser.__init__�rUr c��t|jdd��j�t|jdd��j�t|jddg�d�j�d�}|S)rWrXr/�description�rfc���)rX�
allocation�	reference�r]r^r_rLs   rrIzIPv6Parser.process_record�so���#�'�'�(�B�/�0�6�6�8��c�g�g�m�R�8�9�?�?�A��S�W�W�U�R�D�1�"�5�6�<�<�>�

���
r rerQs@rrgrg�s����-�r rgc�(��eZdZdZ�fd�Zd�Z�xZS)�IPv6UnicastParsera!
    A XMLRecordParser that understands how to parse and retrieve data records
    from the IANA IPv6 unicast address assignments file.

    It can be found online here :-

        - http://www.iana.org/assignments/ipv6-unicast-address-assignments/ipv6-unicast-address-assignments.xml
    c�,��tt|�|�yri)r=rrrrDs   �rrzIPv6UnicastParser.__init__�s���	���/��3r c
��t|jdd��j�t|jdd��j�t|jdd��j�t|jdd��j�t|jdd��j�d�}|S)rWr[r/rkrXr$rZ)r[rkrXr$rZrprLs   rrIz IPv6UnicastParser.process_record�s����#�'�'�(�B�/�0�6�6�8��s�w�w�}�b�9�:�@�@�B��#�'�'�(�B�/�0�6�6�8�������+�,�2�2�4������"�-�.�4�4�6�
���
r rerQs@rrrrr�s����4�r rrc�.��eZdZdZ�fd�Zd�Zd�Z�xZS)�MulticastParserz�
    A XMLRecordParser that knows how to process the IANA IPv4 multicast address
    allocation file.

    It can be found online here :-

        - http://www.iana.org/assignments/multicast-addresses/multicast-addresses.xml
    c�,��tt|�|�y)z�
        Constructor.

        fh - a valid, open file handle to an IANA IPv4 multicast address
             allocation file.

        kwargs - additional parser options.
        N)r=rvrrDs   �rrzMulticastParser.__init__s���	�o�t�-�b�1r c�6�d|vr�|jd�\}}|j�jd�}|j�jd�}dj|D�cgc]}tt	|����c}��ddj|D�cgc]}tt	|����c}���S|j�jd�}dj|D�cgc]}tt	|����c}�Scc}wcc}wcc}w)zX
        Removes variations from address entries found in this particular file.
        �-�.)r`r_r0r]ra)r�addr�a1�a2�o1�o2�is       r�normalise_addrzMulticastParser.normalise_addrs����$�;��z�z�#��H�R������!�!�#�&�B�����!�!�#�&�B�!�h�h�R�'@���C��F��'@�A�!�h�h�R�'@���C��F��'@�A�C�
C�����#�#�C�(�B��8�8�"�5�Q�S��Q��[�5�6�6��	(A��'@��6s�&D�D�*Dc��d|vr;|jt|d��t|jdd��d�}|Sy)rWr{rkr/)�address�descrN)r�r]r^rLs   rrIzMulticastParser.process_record+sH���S�=��.�.�s�3�v�;�/?�@��S�W�W�]�B�7�8��F��M�r )r6r7r8rOrr�rIrPrQs@rrvrvs����	2�7�r rvc��eZdZdZd�Zd�Zy)�DictUpdaterzc
    Concrete Subscriber that inserts records received from a Publisher into a
    dictionary.
    c�.�||_||_||_y)z�
        Constructor.

        dct - lookup dict or dict like object to insert records into.

        topic - high-level category name of data to be processed.

        unique_key - key name in data dict that uniquely identifies it.
        N)�dct�topic�
unique_key)rr�r�r�s    rrzDictUpdater.__init__@s�������
�$��r c�*�||j}|jdk(r$tt|��}||j|<y|jdk(r$tt|��}||j|<y|jdk(rt|�}||j|<y|jdk(red}d|vrD|jd�\}}t
||�}|j�}t|�dk(r|d}nt|�}||j|<yy)	z�
        Callback function used by Publisher to notify this Subscriber about
        an update. Stores topic based information into dictionary passed to
        constructor.
        rrrrNryr"r)
r�r�rr
r�r`r	�cidrs�lenr)rr'�data_id�cidr�iprange�first�lastr�s        rrCzDictUpdater.updateNs����t���'���:�:����3�G�<�=�D�!�D�H�H�T�N�
�Z�Z�6�
!��3�G�<�=�D�!�D�H�H�T�N�
�Z�Z�>�
)��W�%�D�!�D�H�H�T�N�
�Z�Z�;�
&��G��g�~� '�
�
�c� 2�
���!�%��.���
�
����u�:��?�#�A�h�G�#�G�,�� $�D�H�H�W��'r N)r6r7r8rOrrCr9r rr�r�:s���
%�%r r�c��ttjtd��}|j	ttddd��|j�ttjtd��}|j	ttddd��|j�ttjtd��}|j	ttddd��|j�ttjtd��}|j	ttd	d	d
��|j�y)zd
    Parse and load internal IANA data lookups with the latest information from
    data files.
    zipv4-address-space.xmlrrXzipv6-address-space.xmlrz$ipv6-unicast-address-assignments.xmlrzmulticast-addresses.xmlrr�N)rSr
�open_binary�__package__�attachr��	IANA_INFOrNrgrrrv)�ipv4�ipv6�ipv6ua�mcasts    r�	load_infor�ms���
�*�6�6�{�D\�]�^�D��K�K��I�f�-�v�x�@�A��J�J�L��*�6�6�{�D\�]�^�D��K�K��I�f�-�v�x�@�A��J�J�L�
��(�(��6\�]��F��M�M�+�i��7���R�S�
�L�L�N��0�<�<�[�Jc�d�e�E�	�L�L��Y�{�3�[�)�L�M�	�K�K�Mr c�h�|�tj}tt�D]�}|j	dt|�zdz�|j	|dz�|j	dt|�zdz�t|}t|�D]!}||}|j	d|z|zdz��#��y)z7
    Pretty prints IANA information to filehandle.
    Nry�
z%-45r)�_sys�stdout�sortedr��writer�)rA�category�iprangesr��detailss     r�pprint_infor��s���
�z�
�[�[���9�%�;��
����s�8�}�$�t�+�,�
����D��!�
����s�8�}�$�t�+�,��X�&���h�'�	;�G��w�'�G��H�H�W��(�7�2�T�9�:�	;�;r c�b�t|d�r||vSt|d�r||k(Std|�d���)Nr��valuez!Unsupported IP range or address: �!)�hasattr�	Exception)�ip�ip_ranges  r�_within_boundsr��s8���x��!��X�~��	��7�	#��X�~��
�h�H�
I�Ir c���i}|jdk(r�ttd�D]8\}}t||�s�|j	dg�|dj|��:|j
�rMttd�D]8\}}t||�s�|j	dg�|dj|��:|S|jdk(r�ttd�D]8\}}t||�s�|j	dg�|dj|��:ttd�D]8\}}t||�s�|j	dg�|dj|��:|S)z7Returns informational data specific to this IP address.�rr�	Multicast�rr)�versionrr�r�r(r)�is_multicast)�ip_addr�infor�r#r�s     r�queryr��s]��
�D����!��'�	�&�(9�:�	,�L�D�&��g�t�,������+��V��#�#�F�+�	,�
���!�#.�y��/E�#F�
5����!�'�7�3��O�O�K��4���%�,�,�V�4�
5� �K�
���A�	�'�	�&�(9�:�	,�L�D�&��g�t�,������+��V��#�#�F�+�	,�
(�	�.�(A�B�	4�L�D�&��g�t�,������3��^�$�+�+�F�3�	4�
�Kr r5)rO�sysr��xml.saxrr�netaddr.corerr�
netaddr.iprrr	r
�netaddr.compatrrr
r��ContentHandlerrr;rSrgrrrvr�r�r�r�r�r9r r�<module>r�s���,��(�.�L�L�G�G�
����	
�	�1.�g�,�,�1.�h(&�i�(&�V&��&�R'��'�T!��!�H/�o�/�d0%�*�0%�f�0;�"	J��<
�r 

Zerion Mini Shell 1.0