3 �^� � @ sh d dl mZ ddlmZ ddlmZ ddlmZmZ edddd g�Z G d d� de�Z G dd � d e�ZdS )� )� namedtuple� )�ContextWrapper)�DiffResultDescriptor)� Difference�WrapperZmodified_portconZruleZ added_contextZremoved_contextc @ s8 e Zd ZdZed�Zed�Zed�Zdd� Zdd� Z dS )�PortconsDifferencez:Determine the difference in portcons between two policies.� diff_portconsc C s� | j jdj| �� | jdd� | jj� D �dd� | jj� D ��\| _| _}g | _ x<|D ]4\}}t |j�t |j�krT| j jt ||j|j�� qTW dS )z9Generate the difference in portcons between the policies.zGGenerating portcon differences from {0.left_policy} to {0.right_policy}c s s | ]}t |�V qd S )N)�PortconWrapper)�.0�n� r �/usr/lib64/python3.6/portcon.py� <genexpr>. s z3PortconsDifference.diff_portcons.<locals>.<genexpr>c s s | ]}t |�V qd S )N)r )r r r r r r / s N)�log�info�formatZ _set_diffZleft_policyZportconsZright_policy�added_portcons�removed_portcons�modified_portconsr �context�append�modified_portcon_record)�selfZmatched_portconsZleft_portconZ right_portconr r r r '