Edit File: adapters.cpython-311.pyc
� �gh� � �V � d dl mZmZmZmZ d dlmZmZ ddlm Z G d� de � � Z dS )� )�IPv4Address�IPv4Network�IPv6Address�IPv6Network)�List�Union� )�TreeCacheInterfacec � � e Zd ZdZd� Zd� Zd� Zdeee e eef fd�Z deee e eef fd�Zd� Zd S ) �TreeCacheCollectorz] Facade for multiple caches. :param collected_caches: pool of TreeCacheInterface c � � || _ d S )N)�_collected_caches)�self�collected_cachess �T/opt/imunify360/venv/lib/python3.11/site-packages/im360/utils/tree_cache/adapters.py�__init__zTreeCacheCollector.__init__ s � �!1����� c � �Z K � | j D ] }|� |� � � d{V ��r dS �!dS )zICheck if the cache contains specified ip. :type ip: str NTF)r �contains�r �ip�caches r r zTreeCacheCollector.contains sQ � � � � �+� � �E��^�^�B�'�'�'�'�'�'�'�'� ��t�t� ��ur c � �Z K � | j D ] }|� |� � � d{V ��r dS �!dS )zdCheck if the cache contains exactly specified ip, not parent subnet. :type ip: str NTF)r �contains_exactlyr s r r z#TreeCacheCollector.contains_exactly sS � � � � �+� � �E��+�+�B�/�/�/�/�/�/�/�/� ��t�t� ��ur �ipsc � � K � t � � }| j D ]5}|� |� � � d{V ��D ]}|� |� � ��6t |� � S )z)Returns ips those are presented in cache.N)�setr �filter_contained�add�list)r r �set_r r s r r z#TreeCacheCollector.filter_contained$ st � � � � �u�u���+� � �E�!�2�2�3�7�7�7�7�7�7�7�7� � ���������� ��D�z�z�r c � �^ K � |}| j D ] }|r|� |� � � d{V ��}� |S )z-Returns ips those are NOT presented in cache.N)r �filter_not_contained)r r �rvr s r r# z'TreeCacheCollector.filter_not_contained/ sV � � � � ���+� � �E�� � �5�5�b�9�9�9�9�9�9�9�9����� r c �B � | j D ]}|� � � �dS )zr Each of collected_caches will be re-init from so-called SourceInterface on the next call N)r �reset)r �treecache_interfaces r r&