
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
3
^                 @   sl   d dl mZ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
eeZd
d ZG dd deZdS )    )defaultdict
namedtuple   )DiffResultDescriptor)
DifferenceSymbolWrapper)type_wrapper_factoryZmodified_roleadded_typesremoved_typesmatched_typesc             C   s>   yt | j |  S  tk
r8   t| }|t | j | < |S X dS )z|
    Wrap roles from the specified policy.

    This caches results to prevent duplicate wrapper
    objects in memory.
    N)_roles_cacheZpolicyKeyErrorr   )Zroler r   /usr/lib64/python3.6/roles.pyrole_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 )RolesDifferencez7Determine the difference in roles between two policies.
diff_rolesc             C   s   | j jdj|  | jdd | jj D dd | jj D \| _| _}t	 | _
xX|D ]P\}}| jdd |j D dd |j D \}}}|s|rVt|||| j
|< qVW dS )z6Generate the difference in roles between the policies.zDGenerating role differences from {0.left_policy} to {0.right_policy}c             s   s   | ]}t |V  qd S )N)r   ).0r   r   r   r   	<genexpr>@   s    z-RolesDifference.diff_roles.<locals>.<genexpr>c             s   s   | ]}t |V  qd S )N)r   )r   r   r   r   r   r   A   s    c             s   s   | ]}t |V  qd S )N)r   )r   tr   r   r   r   J   s    c             s   s   | ]}t |V  qd S )N)r   )r   r   r   r   r   r   K   s    N)loginfoformatZ	_set_diffZleft_policyZrolesZright_policyadded_rolesremoved_rolesdictmodified_rolestypesmodified_roles_record)selfZmatched_rolesZ	left_roleZ
right_roler	   r
   r   r   r   r   r   9   s     zRolesDifference.diff_rolesc             C   s"   | j jd d| _d| _d| _dS )z%Reset diff results on policy changes.zResetting role differencesN)r   debugr   r   r   )r    r   r   r   _reset_diffU   s    zRolesDifference._reset_diffN)
__name__
__module____qualname____doc__r   r   r   r   r   r"   r   r   r   r   r   1   s   r   N)collectionsr   r   Zdescriptorsr   
differencer   r   r   r   r   r   r   r   r   r   r   r   r   <module>   s   