a qqe@sUddlmZddlmZmZmZddlmZmZm Z ddl m Z ddl m Z mZddlmZdd lmZeeZeeed <Gd d d eZeeed ddZe eeeeefd ddZGddde ZdS)) defaultdict) NamedTupleSetUnion)Type TypeAttribute TypeOrAttr)DiffResultDescriptor) Difference SymbolWrapper)typeattr_wrapper_factory) SymbolCache _types_cachec@sjeZdZUdZeeed<eeed<eeed<eed<eed<eeed<eeed<eeed <d S) ModifiedTypez'Difference details for a modified type.Zadded_attributesZremoved_attributesZmatched_attributesZmodified_permissiveZ permissive added_aliasesremoved_aliasesmatched_aliasesN) __name__ __module__ __qualname____doc__rr__annotations__boolstrrr8/usr/lib64/python3.9/site-packages/setools/diff/types.pyrs      r)type_returncCsBzt|j|WSty<t|}|t|j|<|YS0dS)z| Wrap types from the specified policy. This caches results to prevent duplicate wrapper objects in memory. N)rZpolicyKeyErrorr )rtrrrtype_wrapper_factory!s  r"cCst|trt|St|SdS)z Wrap types or attributes from the specified policy. This caches results to prevent duplicate wrapper objects in memory. N) isinstancerr"r)rrrrtype_or_attr_wrapper_factory0s r$c@sDeZdZdZedZedZedZddddZddddZ dS) TypesDifferencez7Determine the difference in types between two policies. diff_typesN)rc Cs|jd||dd|jDdd|jD\|_|_}t |_ |D]\}}|dd| Ddd| D\}}}|j| | dd\}}} |j } |j } | | k} |s|s|s|s| rTt|||| | ||| |j |<qTd S) z6Generate the difference in types between the policies.zDGenerating type differences from {0.left_policy} to {0.right_policy}css|]}t|VqdSNr .0r!rrr Nz-TypesDifference.diff_types..css|]}t|VqdSr'r(r)rrrr+Or,css|]}t|VqdSr'r(r*arrrr+Yr,css|]}t|VqdSr'r(r-rrrr+Zr,F)unwrapN)loginfoformatZ _set_diffZ left_policytypesZ right_policy added_types removed_typesdictmodified_typesZ attributesaliasesZ ispermissiver) selfZ matched_typesZ left_typeZ right_typeZ added_attrZ removed_attrZ matched_attrrrrZleft_permissiveZright_permissiveZmod_permissiverrrr&Gs<    zTypesDifference.diff_typescCs"|jdd|_d|_d|_dS)z%Reset diff results on policy changes.zResetting type differencesN)r0debugr4r5r7)r9rrr _reset_diffqs zTypesDifference._reset_diff) rrrrr r4r5r7r&r;rrrrr%?s *r%N) collectionsrtypingrrrZ policyreprrr Z descriptorsr differencer r Ztypeattrrrr6rrrr"r$r%rrrrs