3 ^! @shddlmZddlmZddlmZddlmZmZedddd gZ Gd d d eZ Gd d d eZ dS)) namedtuple)ContextWrapper)DiffResultDescriptor) DifferenceWrapperZmodified_ibendportconZruleZ added_contextZremoved_contextc@s8eZdZdZedZedZedZddZddZ dS)IbendportconsDifferencez?Determine the difference in ibendportcons between two policies.diff_ibendportconscCs|jjdj||jdd|jjDdd|jjD\|_|_}g|_ x<|D]4\}}t |j t |j krT|j j t ||j |j qTWdS)z>Generate the difference in ibendportcons between the policies.zLGenerating ibendportcon differences from {0.left_policy} to {0.right_policy}css|]}t|VqdS)N)IbendportconWrapper).0nr $/usr/lib64/python3.6/ibendportcon.py 0sz=IbendportconsDifference.diff_ibendportcons..css|]}t|VqdS)N)r )r r r r rr1sN)loginfoformatZ _set_diffZ left_policyZ ibendportconsZ right_policyadded_ibendportconsremoved_ibendportconsmodified_ibendportconsrcontextappendmodified_ibendportcon_record)selfZmatched_ibendportconsZ left_ibepZ right_ibepr r rr 's z*IbendportconsDifference.diff_ibendportconscCs"|jjdd|_d|_d|_dS)z%Reset diff results on policy changes.z"Resetting ibendportcon differencesN)rdebugrrr)rr r r _reset_diffAs z#IbendportconsDifference._reset_diffN) __name__ __module__ __qualname____doc__rrrrr rr r r rrs rc@s4eZdZdZd ZddZddZdd Zd d Zd S)r z/Wrap ibendportcon statements for diff purposes.nameportcCs$||_|j|_|j|_t||_dS)N)originr r!hashkey)rZoconr r r__init__OszIbendportconWrapper.__init__cCs|jS)N)r$)rr r r__hash__UszIbendportconWrapper.__hash__cCs |j|jkS)N)r")rotherr r r__lt__XszIbendportconWrapper.__lt__cCs|j|jko|j|jkS)N)r r!)rr'r r r__eq__[s zIbendportconWrapper.__eq__N)r r!) rrrr __slots__r%r&r(r)r r r rr Is r N) collectionsrrrZ descriptorsr differencerrrrr r r r rs   *