509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
í«„^h  ã               @   st   d dl mZ ddlmZ ddlmZ ddlmZmZ ddl	m
Z
 edd	d
dgƒZG dd„ deƒZG dd„ deƒZdS )é    )Ú
namedtupleé   )ÚBoundsRuletypeé   )ÚDiffResultDescriptor)Ú
DifferenceÚWrapper)Útype_wrapper_factoryZmodified_boundÚruleZadded_boundZremoved_boundc               @   sH   e Zd ZdZedƒZedƒZedƒZdZdZ	dd„ Z
dd„ Zdd	„ ZdS )
ÚBoundsDifferencez9Determine the difference in *bounds between two policies.Údiff_typeboundsNc             C   s¬   | j jdj| ƒƒ | jdks&| jdkr.| jƒ  | jdd„ | jD ƒdd„ | jD ƒdd„ d�\| _| _}g | _	x<|D ]4\}}t
|jƒt
|jƒkrp| j	jt||j|jƒƒ qpW dS )	z@Generate the difference in typebound rules between the policies.zJGenerating typebounds differences from {0.left_policy} to {0.right_policy}Nc             s   s   | ]}t |ƒV  qd S )N)ÚBoundsWrapper)Ú.0Úc© r   ú/usr/lib64/python3.6/bounds.pyú	<genexpr>5   s    z3BoundsDifference.diff_typebounds.<locals>.<genexpr>c             s   s   | ]}t |ƒV  qd S )N)r   )r   r   r   r   r   r   6   s    c             S   s
   t | jƒS )N)ÚstrÚchild)Úbr   r   r   Ú<lambda>7   s    z2BoundsDifference.diff_typebounds.<locals>.<lambda>)Úkey)ÚlogÚinfoÚformatÚ_left_typeboundsÚ_right_typeboundsÚ_create_typebound_listsZ	_set_diffÚadded_typeboundsÚremoved_typeboundsÚmodified_typeboundsr	   ÚparentÚappendÚmodified_bounds_record)ÚselfZmatched_typeboundsZ
left_boundZright_boundr   r   r   r   +   s    
z BoundsDifference.diff_typeboundsc             C   s”   g | _ x@| jjƒ D ]2}|jtjkr0| j j|ƒ q| jjdj	|jƒƒ qW g | _
x@| jjƒ D ]2}|jtjkrx| j
j|ƒ qZ| jjdj	|jƒƒ qZW dS )z$Create rule lists for both policies.z/Unknown rule type: {0} (This is an SETools bug)N)r   Zleft_policyZboundsÚruletyper   Z
typeboundsr"   r   Úerrorr   r   Zright_policy)r$   r
   r   r   r   r   C   s    

z(BoundsDifference._create_typebound_listsc             C   s(   | j jdƒ d| _d| _d| _d| _dS )z%Reset diff results on policy changes.z!Resetting all *bounds differencesN)r   Údebugr   r   r   r   )r$   r   r   r   Ú_reset_diffU   s
    zBoundsDifference._reset_diff)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   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 *bounds for diff purposes.r%   r!   r   c             C   s4   || _ |j| _t|jƒ| _t|jƒ| _t|ƒ| _d S )N)Úoriginr%   r	   r!   r   Úhashr   )r$   r
   r   r   r   Ú__init__f   s
    zBoundsWrapper.__init__c             C   s   | j S )N)r   )r$   r   r   r   Ú__hash__m   s    zBoundsWrapper.__hash__c             C   s   | j |j k S )N)r   )r$   Úotherr   r   r   Ú__lt__p   s    zBoundsWrapper.__lt__c             C   s   | j |j ko| j|jkS )N)r%   r   )r$   r1   r   r   r   Ú__eq__s   s    zBoundsWrapper.__eq__N)r%   r!   r   )	r)   r*   r+   r,   Ú	__slots__r/   r0   r2   r3   r   r   r   r   r   `   s   r   N)Úcollectionsr   Z	policyrepr   Zdescriptorsr   Ú
differencer   r   Útypesr	   r#   r   r   r   r   r   r   Ú<module>   s   A