+
    ,i>)  c                   s  a  R t"0 t ^ RIHt ^ RIHt ^RIHtHtHtH	t	H
t
 ^RIHt ^RIHtHtHtHt ^RIHt ]! ]4      t] ^ k ]! ]4      t] ^k ]! RRR7       ! R	 R
]4      4       t]! RRR7       ! R R]4      4       t]! RRR7       ! R R]4      4       tR R ltR R lt ! R R]4      t ! R R]4      t ! R R]4      t ! R R]],          4      t ! R R]],          4      t  ! R R]]	,          4      t!R # )!i    )defaultdict)	dataclass)CategoryLevel	LevelDeclRangeSensitivity)DiffResultDescriptor)
DifferenceDifferenceResultSymbolWrapperWrapper)SymbolCacheT)ZfrozenZorderc                   s0   a  ] tR t^t o RtV 3R ltRtV tR# )ModifiedCategoryz+Difference details for a modified category.c                z   < V ^8  d   Qh/ S[ ;R&   S[S[,          ;R&   S[S[,          ;R&   S[S[,          ;R&   # )   categoryadded_aliasesremoved_aliasesmatched_aliases)r   setstrformat__classdict__   "7/usr/lib64/python3.14/site-packages/setools/diff/mls.py__annotate__ZModifiedCategory.__annotate__   sE     
   s8  X  X      N__name__
__module____qualname____firstlineno____doc__Z__annotate_func____static_attributes____classdictcell__r      @r   r   r      s      6  r   r   c                   s0   a  ] tR t^t o RtV 3R ltRtV tR# )ModifiedSensitivityz.Difference details for a modified sensitivity.c                r   )r   sensitivityr   r   r   )r   r   r   r   r   r   r   Z ModifiedSensitivity.__annotate__   sE     
   s8  X  X r   r   Nr   r&   r'   r   r(   r(      s      9  r   r(   c                   s0   a  ] tR t^)t o RtV 3R ltRtV tR# )ModifiedLevelDeclz4Difference details for a modified level declaration.c                r   )r   leveladded_categoriesremoved_categoriesmatched_categories)r   r   r   r   r   r   r   ZModifiedLevelDecl.__annotate__)   sE     
   (m#  H%  H% r   r   Nr   r&   r'   r   r*   r*   )   s      ?  r   r*   c                F    V ^8  d   QhR\         R\        \         ,          /# )r   r   return)r   r
   r      "r   r   r   4   s      x M(4K r   c                     \         V P                  ,          V ,          #   \         d+    \        T 4      pT\         T P                  ,          T &   Tu # i ; i)zo
Wrap category from the specified policy.

This caches results to prevent duplicate wrapper
objects in memory.
)_cats_cachepolicyKeyErrorr
   )r   c   & r   category_wrapper_factoryr9   4   sL    8??+H55 (#12HOO$X.     2AAc                r/   )r   r)   r0   )r   r
   r1   r2   r   r   r   C   s      [ ];=W r   c                r3   )zr
Wrap sensitivity from the specified policy.

This caches results to prevent duplicate wrapper
objects in memory.
)_sens_cacher5   r6   r
   )r)   r7   r8   r   sensitivity_wrapper_factoryr<   C   sP    ;--.{;; +&78K&&'4r:   c                   s   a  ] tR t^Rt o RtV 3R lR lt]],          ! ]4      t]],          ! ]4      t	]]
,          ! ]4      tV 3R lR ltRtV tR# )CategoriesDifferencez<Determine the difference in categories between two policies.c                   < V ^8  d   QhRR/# r   r0   Nr   r   r   r   r   !CategoriesDifference.__annotate__V   s     S S Sr   c           	     P   V P                   P                  RV P                   RV P                   24       V P	                  R V P                  P                  4        4       R V P                  P                  4        4       4      w  V n        V n        p\        \        ,          ! 4       V n
        V Fq  w  r#V P	                  VP                  4       VP                  4       RR7      w  rEpV'       g   V'       g   KJ  V P                  P                  \        VVVV4      4       Ks  	  R# )z;Generate the difference in categories between the policies.z%Generating category differences from  to c              3   8   "   T F  p\        V4      x  K  	  R # 5iNr9   .0r7   r8   r   	<genexpr>7CategoriesDifference.diff_categories.<locals>.<genexpr>]   s     P2OQ%a((2O   c              3   rC   rD   rE   rF   r8   r   rH   rI   ^   s     Q2PQ%a((2PrJ   FZunwrapN)loginfoleft_policyright_policy	_set_diff
categoriesr,   r-   listr   modified_categoriesaliasesappend)selfr.   Zleft_categoryZright_categoryr   r   r      &      r   diff_categoriesZ$CategoriesDifference.diff_categoriesV   s    	3D4D4D3ET$J[J[I\]	_ NR^^P$2B2B2M2M2OPQ$2C2C2N2N2PQNSJt68J $((8#9#; -?)M ?Cnn%%')?)?)A% ?M ?Q;MO ((//0@ANAPAP1R S .@r   c                r>   r?   r   r   r   r   r   r@   u   s     % %T %r   c                H    V P                   P                  R4       V =V =V =R# )%Reset diff results on policy changes.zResetting category differencesN)rL   debugr,   r-   rS   rV      &r   _reset_diffZ CategoriesDifference._reset_diffu   s%    78!#$r   )r,   rS   r-   N)r   r    r!   r"   r#   rX   r   r   r,   r-   r   rS   r^   r$   r%   r&   r'   r   r=   r=   R   sQ     FS S0 ,H5oF-h7H./?@Q
% %r   r=   c                   s   a  ] tR t^}t o RtV 3R lR lt]],          ! ]4      t]],          ! ]4      t	]]
,          ! ]4      tV 3R lR ltRtV tR# )SensitivitiesDifferencez?Determine the difference in sensitivities between two policies.c                r>   r?   r   r   r   r   r   $SensitivitiesDifference.__annotate__   s     Y YD Yr   c           	     rA   )z>Generate the difference in sensitivities between the policies.z(Generating sensitivity differences from rB   c              3   rC   rD   r<   rG   Zsr8   r   rH   =SensitivitiesDifference.diff_sensitivities.<locals>.<genexpr>   s     Z9YA,Q//9YrJ   c              3   rC   rD   ra   rb   r8   r   rH   rc      s     [9ZA,Q//9ZrJ   FrK   N)rL   rM   rN   rO   rP   Zsensitivitiesadded_sensitivitiesremoved_sensitivitiesrR   r(   modified_sensitivitiesrT   rU   )rV   Zmatched_sensitivitiesZ	left_sensZ
right_sensr   r   r   rW   r   diff_sensitivitiesZ*SensitivitiesDifference.diff_sensitivities   s    	6t7G7G6HTM^M^L_`	b NNZ9I9I9W9W9YZ[9J9J9X9X9Z[] 	T $"<>S
 '++>&?&A#%:!I ?Cnn!!#Z%7%7%9% ?M ?I;MO ++223FyGTGVGV4X Y &;r   c                r>   r?   r   r   r   r   r   r`      s     ( (T (r   c                rY   rZ   z!Resetting sensitivity differencesN)rL   r[   rd   re   rf   r\   r]   r   r^   Z#SensitivitiesDifference._reset_diff   s%    :;$&'r   )rd   rf   re   N)r   r    r!   r"   r#   rg   r   r   rd   re   r(   rf   r^   r$   r%   r&   r'   r   r_   r_   }   sT     IY Y2 /{;<NO0=>PQ12EFGYZ
( (r   r_   c                   s   a  ] tR t^t o RtV 3R lR lt]],          ! ]4      t]],          ! ]4      t	]]
,          ! ]4      tV 3R lR ltRtV tR# )LevelDeclsDifferencez8Determine the difference in levels between two policies.c                r>   r?   r   r   r   r   r   !LevelDeclsDifference.__annotate__   s     [ [T [r   c           	     sd   V P                   P                  RV P                   RV P                   24       V P	                  R V P                  P                  4        4       R V P                  P                  4        4       4      w  V n        V n        p\        \        ,          ! 4       V n
        V F{  w  r#V P	                  R VP                  4        4       R VP                  4        4       4      w  rEpV'       g   V'       g   KV  V P                  P                  \        W$WV4      4       K}  	  R# )z7Generate the difference in levels between the policies.z'Generating level decl differences from rB   c              3   rC   rD   LevelDeclWrapperrb   r8   r   rH   3LevelDeclsDifference.diff_levels.<locals>.<genexpr>   s     H.G!!$$.GrJ   c              3   rC   rD   rk   rb   r8   r   rH   rm      s     I.H!!$$.HrJ   c              3   rC   rD   rE   rF   r8   r   rH   rm      s     N6M)!,,6MrJ   c              3   rC   rD   rE   rF   r8   r   rH   rm      s     O6N)!,,6NrJ   N)rL   rM   rN   rO   rP   Zlevelsadded_levelsremoved_levelsrR   r*   modified_levelsrQ   rU   )rV   Zmatched_levelsZ
left_levelZright_levelr,   r-   r.   rW   r   diff_levelsZ LevelDeclsDifference.diff_levels   s    	5d6F6F5GtDL]L]K^_	a NNHd.>.>.E.E.GHId.?.?.F.F.HIK 	?4.
  $$568'5#J HL~~Nj6K6K6MNOk6L6L6NOHQD2D  #5#5$$++,=2D-Z [ (6r   c                r>   r?   r   r   r   r   r   rj      s     ! !T !r   c                rY   rh   )rL   r[   rn   ro   rp   r\   r]   r   r^   Z LevelDeclsDifference._reset_diff   s%    :; r   )rn   rp   ro   N)r   r    r!   r"   r#   rq   r   r   rn   ro   r*   rp   r^   r$   r%   r&   r'   r   ri   ri      sN     B[ [0 (	2;?L))4[AN*+<=kJO
! !r   ri   c                   sL   a  ] tR t^t o RtR	tV 3R lR ltR tR tR t	Rt
V tR# )
rl   z-Wrap level declarations to allow comparisons.c                $   < V ^8  d   QhRS[ RR/# r   r+   r0   N)r   r   r   r   r   ZLevelDeclWrapper.__annotate__   s      i D r   c                sf    Wn         \        VP                  4      V n        \        V4      V n        R # rD   )originr<   r)   hashkeyrV   r+      &&r   __init__ZLevelDeclWrapper.__init__   s%    6u7H7HI;r   c                s    V P                   # rD   )rv   r\   r]   r   __hash__ZLevelDeclWrapper.__hash__   s    xxr   c                s4    V P                   VP                   8H  # rD   r)   rV   Zotherrx   r   __eq__ZLevelDeclWrapper.__eq__   s     5#4#444r   c                s4    V P                   VP                   8  # rD   r{   r|   rx   r   __lt__ZLevelDeclWrapper.__lt__   s    %"3"333r   )rv   rt   r)   Nr{   r   r    r!   r"   r#   Z	__slots__ry   rz   r}   r~   r$   r%   r&   r'   r   rl   rl      s+     7 I 
5
4 4r   rl   c                   sL   a  ] tR t^t o RtR	tV 3R lR ltR tR tR t	Rt
V tR# )
LevelWrapperz!Wrap levels to allow comparisons.c                rr   rs   )r   r   r   r   r   ZLevelWrapper.__annotate__   s     W We W Wr   c                s    Wn         \        VP                  4      V n        \        R  VP	                  4        4       4      V n        R# )c              3   rC   rD   rE   rF   r8   r   rH   Z(LevelWrapper.__init__.<locals>.<genexpr>   s     VCUa6q99CUrJ   N)rt   r<   r)   r   rQ   rw   rx   r   ry   ZLevelWrapper.__init__   s5    6u7H7HIV5CSCSCUVVr   c                ,    \        V P                  4      # rD   ru   rt   r\   r]   r   rz   ZLevelWrapper.__hash__       DKK  r   c                     V P                   VP                   8H  ;'       d    V P                  VP                  8H  #   \         d     R # i ; iFr)   rQ   AttributeErrorr|   rx   r   r}   ZLevelWrapper.__eq__   sP    	##u'8'88 4 45#3#334 	 	   < < A
Ac                     V P                   VP                   8  ;'       d    V P                  VP                  8  #   \         d     R # i ; ir   r   r|   rx   r   r~   ZLevelWrapper.__lt__  sP    	##e&7&77 3 3%"2"223 	 	r   )rQ   rt   r)   N)r)   rQ   r   r&   r'   r   r   r      s-     +-IW W
! r   r   c                   sL   a  ] tR tRt o RtR
tV 3R lR ltR tR tR t	Rt
V tR	# )RangeWrapperi  z
Wrap ranges to allow comparisons.

This only compares the low and high levels of the range.
It does not detect additions/removals/modifications
to levels between the low and high levels of the range.
c                rr   )r   range_r0   N)r   r   r   r   r   ZRangeWrapper.__annotate__  s     . .u . .r   c                sz    Wn         \        VP                  4      V n        \        VP                  4      V n        R # rD   )rt   r   lowhigh)rV   r   rx   r   ry   ZRangeWrapper.__init__  s'    

+ -	r   c                r   rD   r   r\   r]   r   rz   ZRangeWrapper.__hash__  r   r   c                r   r   r   r   r   r|   rx   r   r}   ZRangeWrapper.__eq__   sJ    	88uyy( ( (		UZZ'( 	 	r   c                r   r   r   r|   rx   r   r~   ZRangeWrapper.__lt__)  sJ    	88eii' ' '		EJJ&' 	 	r   )r   r   rt   N)r   r   r   r&   r'   r   r   r     s/       I. .
! r   r   c                s    V ^8  d   Qh/ ^ \         9   d   \        \        ,          ;R&   ^\         9   d   \        \        ,          ;R&   # )r   r4   r;   )__conditional_annotations__r   r   r   r1   r2   r   r   r      s6     # # 7 6[" 6 $ : 9[% 9 $r   N)#r   Zcollectionsr    Zdataclassesr   Z	policyrepr   r   r   r   r   Zdescriptorsr   Z
differencer   r	   r
   r   Ztypingr   Zdictr4   r;   r   r(   r*   r9   r<   r=   r_   ri   rl   r   r   r   )r   r'   r   <module>r      s	   $ # ! F F - L L %0%6 6(3D(9 9 $d#'  $ $d#*  $ $d#&( & $&(%: (%V)(j )(X(!: (!V4wy) 4.75> B$75> $r   