3 �^� � @ sl d dl mZ ddlmZ ddlmZ ddlmZmZ edddd d dg�Z G dd � d e�Z G dd� de�ZdS )� )� namedtuple� )�ContextWrapper)�DiffResultDescriptor)� Difference�WrapperZmodified_netifconZrule� added_context�removed_context�added_packet�removed_packetc @ s8 e Zd ZdZed�Zed�Zed�Zdd� Zdd� Z dS )�NetifconsDifferencez;Determine the difference in netifcons between two policies.�diff_netifconsc C s� | j jdj| �� | jdd� | jj� D �dd� | jj� D ��\| _| _}g | _ x�|D ]|\}}t |j�t |j�kr~|j}|j}nd}d}t |j�t |j�kr�|j}|j}nd}d}|s�|rT| j j t|||||�� qTW dS )z:Generate the difference in netifcons between the policies.zHGenerating netifcon differences from {0.left_policy} to {0.right_policy}c s s | ]}t |�V qd S )N)�NetifconWrapper)�.0�n� r � /usr/lib64/python3.6/netifcon.py� <genexpr>0 s z5NetifconsDifference.diff_netifcons.<locals>.<genexpr>c s s | ]}t |�V qd S )N)r )r r r r r r 1 s N)�log�info�formatZ _set_diffZleft_policyZ netifconsZright_policy�added_netifcons�removed_netifcons�modified_netifconsr �contextZpacket�append�modified_netifcon_record)�selfZmatched_netifconsZ left_netifconZright_netifconr r r r r r r r ) s( z"NetifconsDifference.diff_netifconsc C s"