%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__/glob.cpython-312.pyc

�

ӊ�^�(��v�dZddlmZmZddlmZmZmZmZddl	m
Z
d�Zd�Zd�Z
d�Zd	�Zd
�ZGd�de�Zy
)zb
Routines and classes for supporting and expressing IP address ranges using a
glob style syntax.

�)�AddrFormatError�AddrConversionError)�IPRange�	IPAddress�	IPNetwork�iprange_to_cidrs)�_is_strc���t|�syd}d}|jd�}t|�dk7ry|D]�}d|vr^|ryd}|ry	|jd�D�cgc]
}t|���c}\}}||k\ryd|cxkrdksyyd|cxkrd	kr�`yy|d
k(rd}�m|dury|dury	dt|�cxkrd	ksyy��ycc}w#t$rYywxYw#t$rYywxYw)z�
    :param ipglob: An IP address range in a glob-style format.

    :return: ``True`` if IP range glob is valid, ``False`` otherwise.
    F�.��-Tr����*)r	�split�len�int�
ValueError)�ipglob�seen_hyphen�
seen_asterisk�octets�octet�i�octet1�octet2s        �1/usr/lib/python3/dist-packages/netaddr/ip/glob.py�
valid_globrs8���6�?���K��M�
�\�\�#�
�F�
�6�{�a�������%�<����K���
�49�K�K��4D�#E�q�C��F�#E� ���������%�#�%��&����%�#�%��&��
�c�\� �M��d�"����$��
��C��J�-�#�-� �.� �.�5�<��+$F���
��
��$�
��
�s<�C�C	�*C�-C�C�	C�	C�C�	C+�*C+c���t|�std|�d���g}g}|jd�D]�}d|vr:|jd�}|j|d�|j|d��A|dk(r#|jd�|jd	��i|j|�|j|���t	dj|��t	dj|��fS)
z�
    A function that accepts a glob-style IP range and returns the component
    lower and upper bound IP address.

    :param ipglob: an IP address range in a glob-style format.

    :return: a tuple contain lower and upper bound IP objects.
    � not a recognised IP glob range: �!rr
rrr�0�255)rrr�appendr�join�r�start_tokens�
end_tokensr�tokenss     r�glob_to_iptupler+Fs����f���v�O�P�P��L��J����c�"�
%���%�<��[�[��%�F�����q�	�*����f�Q�i�(�
�c�\�����$����e�$�����&����e�$�
%��S�X�X�l�+�,�i�����8L�.M�M�M�c���t|�std|�d���g}g}|jd�D]�}d|vr:|jd�}|j|d�|j|d��A|dk(r#|jd�|jd	��i|j|�|j|���t	dj|�dj|��S)
z�
    A function that accepts a glob-style IP range and returns the equivalent
    IP range.

    :param ipglob: an IP address range in a glob-style format.

    :return: an IPRange object.
    r!r"rr
rrrr#r$)rrrr%rr&r's     r�glob_to_ipranger.ds����f���v�O�P�P��L��J����c�"�
%���%�<��[�[��%�F�����q�	�*����f�Q�i�(�
�c�\�����$����e�$�����&����e�$�
%��3�8�8�L�)�3�8�8�J�+?�@�@r,c�r�t|�}t|�}|jdk7r|jdk7rtd��d�}g}	|||�}t|�std��|j	|�|S#t$r5t||�D]"}||d|d�}|j	|��$Y|SwxYw)a
    A function that accepts an arbitrary start and end IP address or subnet
    and returns one or more glob-style IP ranges.

    :param start: the start IP address or subnet.

    :param end: the end IP address or subnet.

    :return: a list containing one or more IP globs.
    rz!IP glob ranges only support IPv4!c�.�t|�jd�D�cgc]
}t|���}}t|�jd�D�cgc]
}t|���}}g}d}d}td�D]�}||||k(r|j	t||���,||dk(r||dk(r|j	d�d}�P|s,|s|j	||�d||���d}�std	��td
��dj
|�Scc}wcc}w)NrFrrrrTr
z,only 1 hyphenated octet per IP glob allowed!z3asterisks are not allowed before hyphenated octets!)�strrr�ranger%rr&)	�lb�ub�_�t1�t2r*rrrs	         r�_iprange_to_globz*iprange_to_globs.<locals>._iprange_to_glob�s��!�"�g�m�m�C�0�
1��c�!�f�
1��
1�!�"�g�m�m�C�0�
1��c�!�f�
1��
1������
��q��	O�A��!�u��1��~��
�
�c�"�Q�%�j�)��Q�%�1�*�2�a�5�C�<��
�
�c�"� $�
�%�&��
�
��A���1��&>�?�&*��1�J�L�L�.�M�O�O�%	O�*�x�x�����;2��
1s�D
�
Dzinvalid ip glob createdr���)r�versionrrr%r)�start�endr8�globsr�cidrs      r�iprange_to_globsr?�s���
�e��E�
�C�.�C��}�}���c�k�k�Q�.�!�"E�F�F� �B
�E�!�!�%��-���&�!�&�&?�@�@�
���V���L���!�%�U�C�0�	!�D�%�d�1�g�t�B�x�8�F��L�L�� �	!��L�!�s�0A8�8:B6�5B6c�$�tt|��S)z�
    A function that accepts a glob-style IP range and returns a list of one
    or more IP CIDRs that exactly matches it.

    :param ipglob: an IP address range in a glob-style format.

    :return: a list of one or more IP objects.
    )rr+)rs r�
glob_to_cidrsrA�s���_�V�4�5�5r,c�x�t|�}t|d|d�}t|�dk7rtd��|dS)z�
    A function that accepts an IP subnet in a glob-style format and returns
    a list of CIDR subnets that exactly matches the specified glob.

    :param cidr: an IP object CIDR subnet.

    :return: a list of one or more IP addresses and subnets.
    rr9rzbad CIDR to IP glob conversion!)rr?rr)r>�ipr=s   r�cidr_to_globrD�sC��
�4��B��R��U�B�r�F�+�E�
�5�z�Q��"�"C�D�D���8�Or,c�h��eZdZdZdZ�fd�Z�fd�Z�fd�Zd�Zd�Z	e
ee	dd	�Zd
�Zd�Z
�xZS)�IPGloba�
    Represents an IP address range using a glob-style syntax ``x.x.x-y.*``

    Individual octets can be represented using the following shortcuts :

        1. ``*`` - the asterisk octet (represents values ``0`` through ``255``)
        2. ``x-y`` - the hyphenated octet (represents values ``x`` through ``y``)

    A few basic rules also apply :

        1. ``x`` must always be less than ``y``, therefore :

        - ``x`` can only be ``0`` through ``254``
        - ``y`` can only be ``1`` through ``255``

        2. only one hyphenated octet per IP glob is allowed
        3. only asterisks are permitted after a hyphenated octet

    Examples:

    +------------------+------------------------------+
    | IP glob          | Description                  |
    +==================+==============================+
    | ``192.0.2.1``    | a single address             |
    +------------------+------------------------------+
    | ``192.0.2.0-31`` | 32 addresses                 |
    +------------------+------------------------------+
    | ``192.0.2.*``    | 256 addresses                |
    +------------------+------------------------------+
    | ``192.0.2-3.*``  | 512 addresses                |
    +------------------+------------------------------+
    | ``192.0-1.*.*``  | 131,072 addresses            |
    +------------------+------------------------------+
    | ``*.*.*.*``      | the whole IPv4 address space |
    +------------------+------------------------------+

    .. note ::     IP glob ranges are not directly equivalent to CIDR blocks.     They can represent address ranges that do not fall on strict bit mask     boundaries. They are suitable for use in configuration files, being     more obvious and readable than their CIDR counterparts, especially for     admins and end users with little or no networking knowledge or     experience. All CIDR addresses can always be represented as IP globs     but the reverse is not always true.
    ��_globc���t|�\}}tt|�||�t	|j
|j�d|_y�Nr)r+�superrF�__init__r?�_start�_end�glob)�selfrr;r<�	__class__s    �rrLzIPGlob.__init__s=���&�v�.����
�f�d�$�U�C�0�$�T�[�[�$�)�)�<�Q�?��	r,c�(��tt|��S)z-:return: Pickled state of an `IPGlob` object.)rKrF�__getstate__)rPrQs �rrSzIPGlob.__getstate__s����V�T�/�1�1r,c�|��tt|�|�t|j|j
�d|_y)z>:param state: data used to unpickle a pickled `IPGlob` object.rN)rKrF�__setstate__r?rMrNrO)rP�staterQs  �rrUzIPGlob.__setstate__#s-���
�f�d�(��/�$�T�[�[�$�)�)�<�Q�?��	r,c��|jS)NrG�rPs r�	_get_globzIPGlob._get_glob(s���z�z�r,c��t|�\|_|_t|j|j�d|_yrJ)r+rMrNr?rH)rPrs  r�	_set_globzIPGlob._set_glob+s0��#2�6�#:� ���d�i�%�d�k�k�4�9�9�=�a�@��
r,Nz-an arbitrary IP address range in glob format.c� �d|jzS)z3:return: IP glob in common representational format.z%s)rOrXs r�__str__zIPGlob.__str__2s���d�i�i��r,c�N�|jj�d|j�d�S)z8:return: Python statement to create an equivalent objectz('z'))rQ�__name__rOrXs r�__repr__zIPGlob.__repr__6s��!�^�^�4�4�d�i�i�@�@r,)r_�
__module__�__qualname__�__doc__�	__slots__rLrSrUrYr[�propertyrOr]r`�
__classcell__)rQs@rrFrF�sL���,�Z�I�@�
2�@�
�A��I�y�$�7�9�D� �Ar,rFN)rc�netaddr.corerr�
netaddr.iprrrr�netaddr.compatr	rr+r.r?rArDrF�r,r�<module>rksK���
>�F�F�"�3�lN�<A�<G�T	6��$NA�W�NAr,

Zerion Mini Shell 1.0