a qéqe/ ã@s¢UddlmZddlmZmZddlmZmZddlm Z ddl m Z m Z ddlm Z eeƒZe eed <Gd d „d eƒZee ed œd d„ZGdd„de ƒZdS)é)Ú defaultdict)Ú NamedTupleÚSeté)ÚTypeÚ TypeAttributeé)ÚDiffResultDescriptor)Ú DifferenceÚ SymbolWrapper)Ú SymbolCacheÚ_typeattr_cachec@s6eZdZUdZeeed<eeed<eeed<dS)ÚModifiedTypeAttributez1Difference details for a modified type attribute.Ú added_typesÚ removed_typesÚ matched_typesN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrÚ__annotations__©rrú;/usr/lib64/python3.9/site-packages/setools/diff/typeattr.pyrs   r)ÚattrÚreturncCsBzt|j|WSty<t|ƒ}|t|j|<|YS0dS)z† Wrap type attributes from the specified policy. This caches results to prevent duplicate wrapper objects in memory. N)r ZpolicyÚKeyErrorr )rÚarrrÚtypeattr_wrapper_factorys  rc@sDeZdZdZedƒZedƒZedƒZddœdd„Zddœdd„Z dS) ÚTypeAttributesDifferencezADetermine the difference in type attributes between two policies.Údiff_type_attributesN)rcCsª|j d |¡¡| dd„|j ¡Dƒdd„|j ¡Dƒ¡\|_|_}t ƒ|_ |D]P\}}| dd„|  ¡Dƒdd„|  ¡Dƒ¡\}}}|s’|rTt |||ƒ|j |<qTdS)z@Generate the difference in type attributes between the policies.zNGenerating type attribute differences from {0.left_policy} to {0.right_policy}css|]}t|ƒVqdS©N©r ©Ú.0ÚrrrrÚ ;óz@TypeAttributesDifference.diff_type_attributes..css|]}t|ƒVqdSr r!r"rrrr%<r&css|]}t|ƒVqdSr r!©r#Útrrrr%Dr&css|]}t|ƒVqdSr r!r'rrrr%Er&N) ÚlogÚinfoÚformatZ _set_diffZ left_policyZtypeattributesZ right_policyÚadded_type_attributesÚremoved_type_attributesÚdictÚmodified_type_attributesÚexpandr)ÚselfZmatched_attributesZleft_attributeZright_attributerrrrrrr2s(ÿÿþÿ  þ ÿz-TypeAttributesDifference.diff_type_attributescCs"|j d¡d|_d|_d|_dS)z%Reset diff results on policy changes.z$Resetting type attribute differencesN)r)Údebugr,r-r/)r1rrrÚ _reset_diffNs z$TypeAttributesDifference._reset_diff) rrrrr r,r-r/rr3rrrrr*s rN)Ú collectionsrÚtypingrrZ policyreprrZ descriptorsr Ú differencer r r r.r rrrrrrrrÚs