509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
í«„^B)  ã               @   sæ   d dl mZmZ ddlmZ ddlmZmZmZ eddddgƒZ	ed	dddgƒZ
ed
ddddgƒZeeƒZeeƒZdd„ Zdd„ ZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZdS ) é    )ÚdefaultdictÚ
namedtupleé   )ÚDiffResultDescriptor)Ú
DifferenceÚSymbolWrapperÚWrapperZmodified_categoryÚadded_aliasesÚremoved_aliasesÚmatched_aliasesZmodified_sensitivityZmodified_levelÚlevelÚadded_categoriesÚremoved_categoriesÚmatched_categoriesc             C   s>   yt | j |  S  tk
r8   t| ƒ}|t | j | < |S X dS )z
    Wrap category from the specified policy.

    This caches results to prevent duplicate wrapper
    objects in memory.
    N)Ú_cats_cacheÚpolicyÚKeyErrorr   )ÚcategoryÚc© r   ú/usr/lib64/python3.6/mls.pyÚcategory_wrapper_factory+   s    r   c             C   s>   yt | j |  S  tk
r8   t| ƒ}|t | j | < |S X dS )z‚
    Wrap sensitivity from the specified policy.

    This caches results to prevent duplicate wrapper
    objects in memory.
    N)Ú_sens_cacher   r   r   )Úsensitivityr   r   r   r   Úsensitivity_wrapper_factory:   s    r   c               @   s8   e Zd ZdZedƒZedƒZedƒZdd„ Zdd„ Z	dS )ÚCategoriesDifferencez<Determine the difference in categories between two policies.Údiff_categoriesc             C   sž   | j jdj| ƒƒ | jdd„ | jjƒ D ƒdd„ | jjƒ D ƒƒ\| _| _}t	ƒ | _
xH|D ]@\}}| j|jƒ |jƒ dd�\}}}|s„|rVt|||ƒ| j
|< qVW dS )z;Generate the difference in categories between the policies.zHGenerating category differences from {0.left_policy} to {0.right_policy}c             s   s   | ]}t |ƒV  qd S )N)r   )Ú.0r   r   r   r   ú	<genexpr>X   s    z7CategoriesDifference.diff_categories.<locals>.<genexpr>c             s   s   | ]}t |ƒV  qd S )N)r   )r   r   r   r   r   r   Y   s    F)ÚunwrapN)ÚlogÚinfoÚformatÚ	_set_diffÚleft_policyÚ
categoriesÚright_policyr   r   ÚdictÚmodified_categoriesÚaliasesÚmodified_cat_record)Úselfr   Zleft_categoryZright_categoryr	   r
   r   r   r   r   r   Q   s     z$CategoriesDifference.diff_categoriesc             C   s"   | j jdƒ d| _d| _d| _dS )z%Reset diff results on policy changes.zResetting category differencesN)r    Údebugr   r   r(   )r+   r   r   r   Ú_reset_diffk   s    z CategoriesDifference._reset_diffN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r(   r   r-   r   r   r   r   r   I   s   r   c               @   s8   e Zd ZdZedƒZedƒZedƒZdd„ Zdd„ Z	dS )ÚSensitivitiesDifferencez?Determine the difference in sensitivities between two policies.Údiff_sensitivitiesc             C   sž   | j jdj| ƒƒ | jdd„ | jjƒ D ƒdd„ | jjƒ D ƒƒ\| _| _}t	ƒ | _
xH|D ]@\}}| j|jƒ |jƒ dd�\}}}|s„|rVt|||ƒ| j
|< qVW dS )z>Generate the difference in sensitivities between the policies.zKGenerating sensitivity differences from {0.left_policy} to {0.right_policy}c             s   s   | ]}t |ƒV  qd S )N)r   )r   Úsr   r   r   r   „   s    z=SensitivitiesDifference.diff_sensitivities.<locals>.<genexpr>c             s   s   | ]}t |ƒV  qd S )N)r   )r   r4   r   r   r   r   …   s    F)r   N)r    r!   r"   r#   r$   Zsensitivitiesr&   Úadded_sensitivitiesÚremoved_sensitivitiesr'   Úmodified_sensitivitiesr)   Úmodified_sens_record)r+   Zmatched_sensitivitiesZ	left_sensZ
right_sensr	   r
   r   r   r   r   r3   {   s     z*SensitivitiesDifference.diff_sensitivitiesc             C   s"   | j jdƒ d| _d| _d| _dS )z%Reset diff results on policy changes.z!Resetting sensitivity differencesN)r    r,   r5   r6   r7   )r+   r   r   r   r-   —   s    z#SensitivitiesDifference._reset_diffN)
r.   r/   r0   r1   r   r5   r6   r7   r3   r-   r   r   r   r   r2   s   s   r2   c               @   s8   e Zd ZdZedƒZedƒZedƒZdd„ Zdd„ Z	dS )ÚLevelDeclsDifferencez8Determine the difference in levels between two policies.Údiff_levelsc             C   s°   | j jdj| ƒƒ | jdd„ | jjƒ D ƒdd„ | jjƒ D ƒƒ\| _| _}g | _	x\|D ]T\}}| jdd„ |j
ƒ D ƒdd„ |j
ƒ D ƒƒ\}}}|s’|rT| j	jt||||ƒƒ qTW dS )z7Generate the difference in levels between the policies.zJGenerating level decl differences from {0.left_policy} to {0.right_policy}c             s   s   | ]}t |ƒV  qd S )N)ÚLevelDeclWrapper)r   r4   r   r   r   r   °   s    z3LevelDeclsDifference.diff_levels.<locals>.<genexpr>c             s   s   | ]}t |ƒV  qd S )N)r;   )r   r4   r   r   r   r   ±   s    c             s   s   | ]}t |ƒV  qd S )N)r   )r   r   r   r   r   r   ¹   s    c             s   s   | ]}t |ƒV  qd S )N)r   )r   r   r   r   r   r   º   s    N)r    r!   r"   r#   r$   Zlevelsr&   Úadded_levelsÚremoved_levelsÚmodified_levelsr%   ÚappendÚmodified_level_record)r+   Zmatched_levelsZ
left_levelZright_levelr   r   r   r   r   r   r:   §   s     z LevelDeclsDifference.diff_levelsc             C   s"   | j jdƒ d| _d| _d| _dS )z%Reset diff results on policy changes.z!Resetting sensitivity differencesN)r    r,   r<   r=   r>   )r+   r   r   r   r-   Ã   s    z LevelDeclsDifference._reset_diffN)
r.   r/   r0   r1   r   r<   r=   r>   r:   r-   r   r   r   r   r9   Ÿ   s   r9   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 level declarations to allow comparisons.r   c             C   s    || _ t|jƒ| _t|ƒ| _d S )N)Úoriginr   r   ÚhashÚkey)r+   r   r   r   r   Ú__init__Ñ   s    zLevelDeclWrapper.__init__c             C   s   | j S )N)rC   )r+   r   r   r   Ú__hash__Ö   s    zLevelDeclWrapper.__hash__c             C   s   | j |j kS )N)r   )r+   Úotherr   r   r   Ú__eq__Ù   s    zLevelDeclWrapper.__eq__c             C   s   | j |j k S )N)r   )r+   rF   r   r   r   Ú__lt__Þ   s    zLevelDeclWrapper.__lt__N)	r.   r/   r0   r1   Ú	__slots__rD   rE   rG   rH   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 )ÚLevelWrapperz!Wrap levels to allow comparisons.r   r%   c             C   s.   || _ t|jƒ| _tdd„ |jƒ D ƒƒ| _d S )Nc             s   s   | ]}t |ƒV  qd S )N)r   )r   r   r   r   r   r   ë   s    z(LevelWrapper.__init__.<locals>.<genexpr>)rA   r   r   Úsetr%   )r+   r   r   r   r   rD   è   s    zLevelWrapper.__init__c             C   s
   t | jƒS )N)rB   rA   )r+   r   r   r   rE   í   s    zLevelWrapper.__hash__c             C   s2   y| j |j ko| j|jkS  tk
r,   dS X d S )NF)r   r%   ÚAttributeError)r+   rF   r   r   r   rG   ð   s
    zLevelWrapper.__eq__c             C   s2   y| j |j k o| j|jk S  tk
r,   dS X d S )NF)r   r%   rL   )r+   rF   r   r   r   rH   ù   s
    zLevelWrapper.__lt__N)r   r%   )	r.   r/   r0   r1   rI   rD   rE   rG   rH   r   r   r   r   rJ   â   s   	rJ   c               @   s4   e Zd ZdZdZdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚRangeWrapperzÝ
    Wrap ranges to allow comparisons.

    This only compares the low and high levels of the range.
    It does not detect additions/removals/modifications
    to levels between the low and high levels of the range.
    ÚlowÚhighc             C   s"   || _ t|jƒ| _t|jƒ| _d S )N)rA   rJ   rN   rO   )r+   Zrange_r   r   r   rD     s    zRangeWrapper.__init__c             C   s
   t | jƒS )N)rB   rA   )r+   r   r   r   rE     s    zRangeWrapper.__hash__c             C   s2   y| j |j ko| j|jkS  tk
r,   dS X d S )NF)rN   rO   rL   )r+   rF   r   r   r   rG     s
    zRangeWrapper.__eq__c             C   s2   y| j |j k o| j|jk S  tk
r,   dS X d S )NF)rN   rO   rL   )r+   rF   r   r   r   rH      s
    zRangeWrapper.__lt__N)rN   rO   )	r.   r/   r0   r1   rI   rD   rE   rG   rH   r   r   r   r   rM     s   	rM   N)Úcollectionsr   r   Zdescriptorsr   Ú
differencer   r   r   r*   r8   r@   r'   r   r   r   r   r   r2   r9   r;   rJ   rM   r   r   r   r   Ú<module>   s,   *,,!