%PDF- %PDF-
Mini Shell

Mini Shell

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

�

ӊ�^7��p�dZddlZddlmZmZd�Ze�Zd�Zd�Z	d�Z
dd�Zdd	�Zdd
�Z
d�Zd�Zd
�Zy)z)
Shared logic for various address types.
�N)�_range�_is_strc��g}tddd�}td�D]?}ddgz}|D]}d|dz||<|dz}�|jdj|���A|S)	z�
    :return: A 256 element list containing 8-bit binary digit strings. The
        list index value is equivalent to its bit string value.
    ������N�01��)r�range�append�join)�lookup�
bits_per_byte�num�bits�is     �;/usr/lib/python3/dist-packages/netaddr/strategy/__init__.py�
bytes_to_bitsrs{��
�F��1�b�"�%�M��S�z�%���D�6�z���	�A��3��7�m�D��G��A�I�C�	�	�
�
�b�g�g�d�m�$�%��M�c�z�t|d�syt|�|k7ryd|zdz
}|D]}d|cxkr|kr�yyy)a6
    :param words: A sequence of unsigned integer word values.

    :param word_size: Width (in bits) of each unsigned integer word value.

    :param num_words: Number of unsigned integer words expected.

    :return: ``True`` if word sequence is valid for this address type,
        ``False`` otherwise.
    �__iter__F�rrT)�hasattr�len)�words�	word_size�	num_words�max_wordrs     r�valid_wordsr!!sZ���5�*�%��
�5�z�Y����I�~��!�H�
����A�!��!��"���rc��d||zzdz
}d|cxkr|ksntdt|�z��d|zdz
}g}t|�D]&}||z}|jt	|��||z}�(tt
|��S)aJ
    :param int_val: Unsigned integer to be divided into words of equal size.

    :param word_size: Width (in bits) of each unsigned integer word value.

    :param num_words: Number of unsigned integer words expected.

    :return: A tuple contain unsigned integer word values split according
        to provided arguments.
    rrrzinteger out of bounds: %r!)�
IndexError�hexr
r�int�tuple�reversed)�int_valrr�max_intr r�_�words        r�int_to_wordsr,;s����I�	�)�*�Q�.�G���"�7�"��5��G��D�E�E��I�~��!�H��E�
�9�
�����!��
���S��Y���I����
��%��!�!rc��t|||�std|�d���d}tt|��D]\}}|}|||zz}||z}�|S)a5
    :param words: A sequence of unsigned integer word values.

    :param word_size: Width (in bits) of each unsigned integer word value.

    :param num_words: Number of unsigned integer words expected.

    :return: An unsigned integer that is equivalent to value represented
        by word sequence.
    zinvalid integer word sequence: �!r)r!�
ValueError�	enumerater')rrrr(rrr+s       r�words_to_intr1Vsb���u�i��3���H�I�I��G��H�U�O�,�!���3����y�1�}�$���D�.��!�
�Nrc���t|�sy|dk7r|j|d�}t|�|k7ryd|zdz
}	dt|d�cxkr|kryy	y#t$rYywxYw)al
    :param bits: A network address in a delimited binary string format.

    :param width: Maximum width (in bits) of a network address (excluding
        delimiters).

    :param word_sep: (optional) character or string used to delimit word
        groups (default: '', no separator).

    :return: ``True`` if network address is valid, ``False`` otherwise.
    FrrrrT)r�replacerr%r/)r�width�word_sepr)s    r�
valid_bitsr6ms����4�=���2�~��|�|�H�b�)��
�4�y�E����5�j�1�n�G�
���D�!��'��'��(�
�(�
���
���
�s�A�A�	A"�!A"c��t|||�std|�d���|dk7r|j|d�}t|d�S)a�
    :param bits: A network address in a delimited binary string format.

    :param width: Maximum width (in bits) of a network address (excluding
        delimiters).

    :param word_sep: (optional) character or string used to delimit word
        groups (default: '', no separator).

    :return: An unsigned integer that is equivalent to value represented
        by network address in readable binary form.
    z invalid readable binary string: r.rr)r6r/r3r%)rr4r5s   r�bits_to_intr8�sA���d�E�8�,��$�H�I�I��2�~��|�|�H�b�)���t�Q�<�rc�b�g}t|||�D]n}g}|r#|jt|dz�|dz}|r�#|j�dj	|�xsd|z}d|z|z|d}|j|��p|dk7rt|�st
d|�d���|j	|�S)a�
    :param int_val: An unsigned integer.

    :param word_size: Width (in bits) of each unsigned integer word value.

    :param num_words: Number of unsigned integer words expected.

    :param word_sep: (optional) character or string used to delimit word
        groups (default: '', no separator).

    :return: A network address in a delimited binary string format that is
        equivalent in value to unsigned integer.
    �r	r�0Nz word separator is not a string: r.)r,r�
BYTES_TO_BITS�reverserrr/)r(rrr5�	bit_wordsr+r�bit_strs        r�int_to_bitsr@�s����I��W�i��;�������K�K�
�d�S�j�1�2��Q�J�D��	
�����'�'�$�-�2�3��?���i��'�)�I�:�;�7���������2�~��x� ��h�P�Q�Q��=�=��#�#rc���t|�sy|jd�sy|jdd�}t|�|kDryd|zdz
}	dt	|d�cxkr|kryy	y#t
$rYywxYw)a
    :param bin_val: A network address in Python's binary representation format
        ('0bxxx').

    :param width: Maximum width (in bits) of a network address (excluding
        delimiters).

    :return: ``True`` if network address is valid, ``False`` otherwise.
    F�0brrrrT)r�
startswithr3rr%r/)�bin_valr4r)s   r�	valid_binrE�s����7������d�#���o�o�d�B�'�G�
�7�|�e����5�j�1�n�G�
���G�Q��*�7�*��+�
�+�
���
���
�s�	A#�A#�#	A/�.A/c	�P�g}	t|�}t|dd	�|kDrtd
|�d���|S#t$rk|}|dkDr(|dz}|jt|�|dz}|dkDr�(|j	�dtjdddj|��z}Y��wxYw)z�
    :param int_val: An unsigned integer.

    :param width: Maximum allowed width (in bits) of a unsigned integer.

    :return: Equivalent string value in Python's binary representation format
        ('0bxxx').
    rr:r	rBz
^[0]+([01]+)$z\1rrNzbinary string out of bounds: r.)
�bin�	NameErrorrr<r=�_re�subrrr#)r(r4�
bin_tokensrDrr+s      r�
int_to_binrL�s����J�O��g�,���7�1�2�;��%���w�H�I�I��N���	O����!�e��t�8�D����m�D�1�2�
�!�G�A��!�e�
	��������!1�5�"�'�'�*�:M�N�N��	O�s�1�7B%�)9B%�$B%c�p�t||�std|�d���t|jdd�d�S)a9
    :param bin_val: A string containing an unsigned integer in Python's binary
        representation format ('0bxxx').

    :param width: Maximum allowed width (in bits) of a unsigned integer.

    :return: An unsigned integer that is equivalent to value represented
        by Python binary string format.
    z"not a valid Python binary string: r.rBrr)rEr/r%r3)rDr4s  r�
bin_to_intrNs4���W�e�$��G�M�N�N��w���t�R�(�!�,�,r)r)�__doc__�rerI�netaddr.compatrrrr<r!r,r1r6r8r@rErLrN�rr�<module>rSsP����*�
� ��
��4"�6�.�@�,$�D�@�>
-r

Zerion Mini Shell 1.0