a qéqeH ã@s|ddlmZddlmZmZddlmZddlmZddl m Z m Z Gdd „d eƒZ Gd d „d e ƒZ Gd d „d e eƒZdS)é)Ú NamedTupleé)ÚContextÚPortconé)ÚContextWrapper)ÚDiffResultDescriptor)Ú DifferenceÚWrapperc@s*eZdZUdZeed<eed<eed<dS)ÚModifiedPortconz*Difference details for a modified portcon.ZruleZ added_contextZremoved_contextN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rÚ__annotations__r©rrú:/usr/lib64/python3.9/site-packages/setools/diff/portcon.pyr s r c@sDeZdZdZedƒZedƒZedƒZddœdd„Zddœdd„Z dS) ÚPortconsDifferencez:Determine the difference in portcons between two policies.Ú diff_portconsN)ÚreturncCsŒ|j d |¡¡| dd„|j ¡Dƒdd„|j ¡Dƒ¡\|_|_}g|_ |D]4\}}t |j ƒt |j ƒkrR|j   t ||j |j ƒ¡qRdS)z9Generate the difference in portcons between the policies.zGGenerating portcon differences from {0.left_policy} to {0.right_policy}css|]}t|ƒVqdS©N©ÚPortconWrapper©Ú.0ÚnrrrÚ &óz3PortconsDifference.diff_portcons..css|]}t|ƒVqdSrrrrrrr'rN)ÚlogÚinfoÚformatZ _set_diffZ left_policyZportconsZ right_policyÚadded_portconsÚremoved_portconsÚmodified_portconsrÚcontextÚappendr )ÚselfZmatched_portconsZ left_portconZ right_portconrrrrs ÿþ  þz PortconsDifference.diff_portconscCs"|j d¡d|_d|_d|_dS)z%Reset diff results on policy changes.zResetting portcon differencesN)rÚdebugr!r"r#©r&rrrÚ _reset_diff6s zPortconsDifference._reset_diff) r r rrrr!r"r#rr)rrrrrs rc@s<eZdZdZdZeddœdd„Zdd„Zd d „Zd d „Z dS) rz*Wrap portcon statements for diff purposes.©ÚprotocolÚlowÚhighN)ÚoconrcCs*||_|j|_|j\|_|_t|ƒ|_dSr)Úoriginr+Zportsr,r-ÚhashÚkey)r&r.rrrÚ__init__DszPortconWrapper.__init__cCs|jSr)r1r(rrrÚ__hash__JszPortconWrapper.__hash__cCs |j|jkSr)r/©r&ÚotherrrrÚ__lt__MszPortconWrapper.__lt__cCs$|j|jko"|j|jko"|j|jkSrr*r4rrrÚ__eq__Ps   ÿ þzPortconWrapper.__eq__) r r rrÚ __slots__rr2r3r6r7rrrrr>s rN)ÚtypingrZ policyreprrr$rZ descriptorsrÚ differencer r r rrrrrrÚs    '