Y2 ]]X V d dl mZmZmZmZ d dlmZmZ ddlm Z G d de Z dS ) )IPv4AddressIPv4NetworkIPv6AddressIPv6Network)ListUnion )TreeCacheInterfacec e Zd ZdZd Zd Zd Zdeee e eef fdZ deee e eef fdZd Zd S ) TreeCacheCollectorz] Facade for multiple caches. :param collected_caches: pool of TreeCacheInterface c || _ d S )N)_collected_caches)selfcollected_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 containsr ipcaches r r zTreeCacheCollector.contains sQ + E^^B'''''''' tt 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//////// tt ur ipsc K t }| j D ]5}| | d{V D ]}| | 6t | S )z)Returns ips those are presented in cache.N)setr filter_containedaddlist)r r set_r r s r r z#TreeCacheCollector.filter_contained$ st uu+ E!22377777777 Dzzr 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 55b99999999 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&