a qéqe¶ ã@s UddlmZddlmZddlmZmZddlmZddl m Z m Z ddlm Z ee ƒZe eed <Gd d „d eƒZeee ed œd d„ZGdd„de ƒZdS)é)Ú defaultdict)Ú NamedTupleé)Ú SELinuxPolicyÚBooleané)ÚDiffResultDescriptor)Ú DifferenceÚ SymbolWrapper)Ú SymbolCacheÚ _bool_cachec@s"eZdZUdZeed<eed<dS)ÚModifiedBooleanz*Difference details for a modified Boolean.Z added_stateZ removed_stateN)Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚboolÚ__annotations__©rrú7/usr/lib64/python3.9/site-packages/setools/diff/bool.pyr s r )ÚpolicyÚbooleanÚreturncCs>zt||WSty8t|ƒ}|t||<|YS0dS)z Wrap booleans from the specified policy. This caches results to prevent duplicate wrapper objects in memory. N)r ÚKeyErrorr )rrÚbrrrÚboolean_wrappers   rc@sDeZdZdZedƒZedƒZedƒZddœdd„Zddœdd„Z dS) ÚBooleansDifferencezADetermine the difference in type attributes between two policies.Ú diff_booleansN)rcCs‚|j d |¡¡| dd„|j ¡Dƒdd„|j ¡Dƒ¡\|_|_}t ƒ|_ |D](\}}|j |j krTt |j |j ƒ|j |<qTdS)z@Generate the difference in type attributes between the policies.zGGenerating Boolean differences from {0.left_policy} to {0.right_policy}css|]}t|ƒVqdS©N©r ©Ú.0rrrrÚ :óz3BooleansDifference.diff_booleans..css|]}t|ƒVqdSrrr rrrr";r#N) ÚlogÚinfoÚformatZ _set_diffZ left_policyZboolsZ right_policyÚadded_booleansÚremoved_booleansÚdictÚmodified_booleansÚstater )ÚselfZmatched_booleansZ left_booleanZ right_booleanrrrr2s ÿþÿ   ÿz BooleansDifference.diff_booleanscCs"|j d¡d|_d|_d|_dS)z%Reset diff results on policy changes.zResetting Boolean differencesN)r$Údebugr'r(r*)r,rrrÚ _reset_diffIs zBooleansDifference._reset_diff) rrrrrr'r(r*rr.rrrrr*s rN)Ú collectionsrÚtypingrZ policyreprrZ descriptorsrÚ differencer r r r)r rr rrrrrrÚs