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_genfs�ruleZ added_contextZremoved_contextc @ s8 e Zd ZdZed�Zed�Zed�Zdd� Zdd� Z dS )�GenfsconsDifferencez@Determine the difference in genfscon rules between two policies.�diff_genfsconsc 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 )z?Generate the difference in genfscon rules between the policies.zHGenerating genfscon differences from {0.left_policy} to {0.right_policy}c s s | ]}t |�V qd S )N)�GenfsconWrapper)�.0�fs� r � /usr/lib64/python3.6/genfscon.py� <genexpr>/ s z5GenfsconsDifference.diff_genfscons.<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_policyZ genfsconsZright_policy�added_genfscons�removed_genfscons�modified_genfsconsr �context�append�modified_genfs_record)�selfZmatchedZ left_ruleZ right_ruler r r r '