%PDF- %PDF-
Direktori : /usr/lib/python3/dist-packages/netaddr/contrib/__pycache__/ |
Current File : //usr/lib/python3/dist-packages/netaddr/contrib/__pycache__/subnet_splitter.cpython-312.pyc |
� �^� � �. � d dl mZmZmZ G d� de� Zy)� )� IPNetwork�cidr_exclude� cidr_mergec �* � e Zd ZdZd� Zdd�Zd� Zd� Zy)�SubnetSplitterz� A handy utility class that takes a single (large) subnet and allows smaller subnet within its range to be extracted by CIDR prefix. Any leaving address space is available for subsequent extractions until all space is exhausted. c �8 � t t |� g� | _ y)z� Constructor. :param base_cidr: an IPv4 or IPv6 address with a CIDR prefix. (see IPNetwork.__init__ for full details). N)�setr �_subnets)�self� base_cidrs �A/usr/lib/python3/dist-packages/netaddr/contrib/subnet_splitter.py�__init__zSubnetSplitter.__init__ s � � �Y�y�1�2�3�� � Nc � � | j � D ]t }t |j ||�� � }|s�"| j |� | j j t t |t |� d � � � | _ |c S g S )z;Extract 1 or more subnets of size specified by CIDR prefix.)�countr ) �available_subnets�list�subnet� remove_subnetr �unionr r r )r �prefixr �cidr�subnetss r �extract_subnetzSubnetSplitter.extract_subnet s� � ��*�*�,� �D��4�;�;�v�U�;�;�<�G������t�$� �M�M�/�/�� ��z�'�':�1�'=�>���D�M� �N� � � r c �4 � t | j d� d�� S )z2Returns a list of the currently available subnets.c � � | j S �N)� prefixlen)�xs r �<lambda>z2SubnetSplitter.available_subnets.<locals>.<lambda>* s � �1�;�;� r T)�key�reverse)�sortedr )r s r r z SubnetSplitter.available_subnets( s � ��d�m�m�)>��M�Mr c �: � | j j |� y)z:Remove a specified IPNetwork from available address space.N)r �remove)r � ip_networks r r zSubnetSplitter.remove_subnet, s � �� � ���Z�(r r )�__name__� __module__�__qualname__�__doc__r r r r � r r r r s � ��4� �N�)r r N)� netaddr.ipr r r �objectr r+ r r �<module>r. s �� ;� :�%)�V� %)r