
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
3
^!                 @   sh   d dl mZ ddlmZ ddlmZ ddlmZmZ edddd	gZ	G d
d deZ
G dd deZdS )    )
namedtuple   )ContextWrapper)DiffResultDescriptor)
DifferenceWrapperZmodified_ibendportconZruleZadded_contextZremoved_contextc               @   s8   e Zd ZdZedZedZedZdd Zdd Z	dS )IbendportconsDifferencez?Determine the difference in ibendportcons between two policies.diff_ibendportconsc             C   s   | j jdj|  | jdd | jj D dd | jj D \| _| _}g | _	x<|D ]4\}}t
|jt
|jkrT| j	jt||j|j qTW dS )z>Generate the difference in ibendportcons between the policies.zLGenerating ibendportcon differences from {0.left_policy} to {0.right_policy}c             s   s   | ]}t |V  qd S )N)IbendportconWrapper).0n r   $/usr/lib64/python3.6/ibendportcon.py	<genexpr>0   s    z=IbendportconsDifference.diff_ibendportcons.<locals>.<genexpr>c             s   s   | ]}t |V  qd S )N)r
   )r   r   r   r   r   r   1   s    N)loginfoformatZ	_set_diffZleft_policyZibendportconsZright_policyadded_ibendportconsremoved_ibendportconsmodified_ibendportconsr   contextappendmodified_ibendportcon_record)selfZmatched_ibendportconsZ	left_ibepZ
right_ibepr   r   r   r	   '   s     z*IbendportconsDifference.diff_ibendportconsc             C   s"   | j jd d| _d| _d| _dS )z%Reset diff results on policy changes.z"Resetting ibendportcon differencesN)r   debugr   r   r   )r   r   r   r   _reset_diffA   s    z#IbendportconsDifference._reset_diffN)
__name__
__module____qualname____doc__r   r   r   r   r	   r   r   r   r   r   r      s   r   c               @   s4   e Zd ZdZdZdd Zdd Zdd	 Zd
d ZdS )r
   z/Wrap ibendportcon statements for diff purposes.nameportc             C   s$   || _ |j| _|j| _t|| _d S )N)originr    r!   hashkey)r   Zoconr   r   r   __init__O   s    zIbendportconWrapper.__init__c             C   s   | j S )N)r$   )r   r   r   r   __hash__U   s    zIbendportconWrapper.__hash__c             C   s   | j |j k S )N)r"   )r   otherr   r   r   __lt__X   s    zIbendportconWrapper.__lt__c             C   s   | j |j ko| j|jkS )N)r    r!   )r   r'   r   r   r   __eq__[   s    zIbendportconWrapper.__eq__N)r    r!   )	r   r   r   r   	__slots__r%   r&   r(   r)   r   r   r   r   r
   I   s   r
   N)collectionsr   r   r   Zdescriptorsr   
differencer   r   r   r   r
   r   r   r   r   <module>   s   *