a qéqe7 ã@s€ddlmZmZddlmZmZddlmZddlm Z ddl m Z m Z Gdd „d eƒZ Gd d „d e ƒZGd d „d e eƒZdS)é)Ú NamedTupleÚOptionalé)ÚContextÚNetifconé)ÚContextWrapper)ÚDiffResultDescriptor)Ú DifferenceÚWrapperc@sJeZdZUdZeed<eeed<eeed<eeed<eeed<dS)ÚModifiedNetifconz+Difference details for a modified netifcon.ZruleÚ added_contextÚremoved_contextÚ added_packetÚremoved_packetN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rÚ__annotations__rr©rrú;/usr/lib64/python3.9/site-packages/setools/diff/netifcon.pyr s    r c@sDeZdZdZedƒZedƒZedƒZddœdd„Zddœdd„Z dS) ÚNetifconsDifferencez;Determine the difference in netifcons between two policies.Údiff_netifconsN)Úreturnc CsÔ|j d |¡¡| dd„|j ¡Dƒdd„|j ¡Dƒ¡\|_|_}g|_ |D]|\}}t |j ƒt |j ƒkr||j }|j }nd}d}t |j ƒt |j ƒkr¦|j }|j }nd}d}|s¶|rR|j   t|||||ƒ¡qRdS)z:Generate the difference in netifcons between the policies.zHGenerating netifcon differences from {0.left_policy} to {0.right_policy}css|]}t|ƒVqdS©N©ÚNetifconWrapper©Ú.0ÚnrrrÚ (óz5NetifconsDifference.diff_netifcons..css|]}t|ƒVqdSrrrrrrr!)r"N)ÚlogÚinfoÚformatZ _set_diffZ left_policyZ netifconsZ right_policyÚadded_netifconsÚremoved_netifconsÚmodified_netifconsrÚcontextZpacketÚappendr )ÚselfZmatched_netifconsZ left_netifconZright_netifconrr rrrrrr!s. ÿþ  ÿz"NetifconsDifference.diff_netifconscCs"|j d¡d|_d|_d|_dS)z%Reset diff results on policy changes.zResetting netifcon differencesN)r#Údebugr&r'r(©r+rrrÚ _reset_diffFs zNetifconsDifference._reset_diff) rrrrr r&r'r(rr.rrrrrs %rc@s<eZdZdZdZeddœdd„Zdd„Zd d „Zd d „Z dS) rz+Wrap netifcon statements for diff purposes.ÚnetifN)ÚoconrcCs||_|j|_t|ƒ|_dSr)Úoriginr/ÚhashÚkey)r+r0rrrÚ__init__TszNetifconWrapper.__init__cCs|jSr)r3r-rrrÚ__hash__YszNetifconWrapper.__hash__cCs |j|jkSr©r/©r+ÚotherrrrÚ__lt__\szNetifconWrapper.__lt__cCs |j|jkSrr6r7rrrÚ__eq___szNetifconWrapper.__eq__) rrrrÚ __slots__rr4r5r9r:rrrrrNs rN)ÚtypingrrZ policyreprrr)rZ descriptorsr Ú differencer r r rrrrrrÚs   5