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_nodeconZruleZ added_contextZremoved_contextc @ s8 e Zd ZdZed�Zed�Zed�Zdd� Zdd� Z dS )�NodeconsDifferencez:Determine the difference in nodecons between two policies.� diff_nodeconsc 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 nodecons between the policies.zGGenerating nodecon differences from {0.left_policy} to {0.right_policy}c s s | ]}t |�V qd S )N)�NodeconWrapper)�.0�n� r �/usr/lib64/python3.6/nodecon.py� <genexpr>/ s z3NodeconsDifference.diff_nodecons.<locals>.<genexpr>c s s | ]}t |�V qd S )N)r )r r r r r r 0 s N)�log�info�formatZ _set_diffZleft_policyZnodeconsZright_policy�added_nodecons�removed_nodecons�modified_nodeconsr �context�append�modified_nodecon_record)�selfZmatched_nodeconsZleft_nodeconZ right_nodeconr r r r ( s z NodeconsDifference.diff_nodeconsc C s"