3 í«„^Öã@slddlmZddlmZddlmZddlmZmZedddd d d gƒZ Gd d „d eƒZ Gdd„deƒZ dS)é)Ú namedtupleé)ÚContextWrapper)ÚDiffResultDescriptor)Ú DifferenceÚWrapperZmodified_netifconZruleÚ added_contextÚremoved_contextÚ added_packetÚremoved_packetc@s8eZdZdZedƒZedƒZedƒZdd„Zdd„Z dS)ÚNetifconsDifferencez;Determine the difference in netifcons between two policies.Údiff_netifconscCsØ|jjdj|ƒƒ|jdd„|jjƒDƒdd„|jjƒDƒƒ\|_|_}g|_ x„|D]|\}}t |j ƒt |j ƒkr~|j }|j }nd}d}t |j ƒt |j ƒkr¨|j }|j }nd}d}|s¸|rT|j j t|||||ƒƒqTWdS)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Ún©rú /usr/lib64/python3.6/netifcon.pyú 0sz5NetifconsDifference.diff_netifcons..css|]}t|ƒVqdS)N)r)rrrrrr1sN)ÚlogÚinfoÚformatZ _set_diffZ left_policyZ netifconsZ right_policyÚadded_netifconsÚremoved_netifconsÚmodified_netifconsrÚcontextZpacketÚappendÚmodified_netifcon_record)ÚselfZmatched_netifconsZ left_netifconZright_netifconr rr r rrrr )s(  z"NetifconsDifference.diff_netifconscCs"|jjdƒd|_d|_d|_dS)z%Reset diff results on policy changes.zResetting netifcon differencesN)rÚdebugrrr)rrrrÚ _reset_diffNs zNetifconsDifference._reset_diffN) Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrr rrrrrr !s %r c@s4eZdZdZdZdd„Zdd„Zdd„Zd d „Zd S) rz+Wrap netifcon statements for diff purposes.ÚnetifcCs||_|j|_t|ƒ|_dS)N)Úoriginr$ÚhashÚkey)rZoconrrrÚ__init__\szNetifconWrapper.__init__cCs|jS)N)r')rrrrÚ__hash__aszNetifconWrapper.__hash__cCs |j|jkS)N)r$)rÚotherrrrÚ__lt__dszNetifconWrapper.__lt__cCs |j|jkS)N)r$)rr*rrrÚ__eq__gszNetifconWrapper.__eq__N) r r!r"r#Ú __slots__r(r)r+r,rrrrrVs rN) Ú collectionsrrrZ descriptorsrÚ differencerrrr rrrrrÚs   5