+
    	:i  c                   s    R t ^RIHt ^RIHt ]P                  '       d   ^RIHt  ! R R4      tR tR tR t	R	 t
R
 tR tR# )ai  
Classes and functions for the output of reference policy modules.

This module takes a refpolicy.Module object and formats it for
output using the ModuleWriter object. By separating the output
in this way the other parts of Madison can focus solely on
generating policy. This keeps the semantic / syntactic issues
cleanly separated from the formatting issues.
)	refpolicy)util)cmpc                   s2   a  ] tR t^%t o R tR tR tRtV tR# )ModuleWriterc                sL    R V n         R V n        RV n        RV n        RV n        R # )NTF)fdmodulesortrequiresgen_cil)selfs   &4/usr/lib/python3.14/site-packages/sepolgen/output.py__init__ZModuleWriter.__init__&   s%    	    c                s.   Wn         V P                  '       d   \        V P                   4       \        P                  ! V P                   R R7       FA  w  r4VP                  V P                  4       VP                  R\        V4      ,          4       KC  	  R# )T)Z	showdepthz%s
N)	r   r   sort_filterr    Zwalktreeset_gen_cilr   writeZstr)r	   r   r   nodeZdepths   &&&  r
   r   ZModuleWriter.write-   sc    999$ %--dkkTJKDT\\*HHVc$i'( Kr   c                s    Wn         R # N)r   )r	   r      &&r
   r   ZModuleWriter.set_gen_cil8   s    r   )r   r   r   r   r   N)	Z__name__Z
__module__Z__qualname__Z__firstlineno__r   r   r   Z__static_attributes__Z__classdictcell__)Z__classdict__s   @r
   r   r   %   s     	) r   r   c                 s   \         P                  ! V 4      pVP                  4        \         P                  ! V4      pVP                  4        \        V4      \        V4      8w  d   \	        V^ ,          V^ ,          4      # \        W#4       F4  pV^ ,          V^,          8w  g   K  \	        V^ ,          V^,          4      u # 	  ^ # i    )r   Zset_to_listr   lenr   Zzip)xZyZxlZylZvs   &&   r
   
id_set_cmpr   B   s    			!	BGGI			!	BGGI
2w#b'2a5"Q%  [Q41Q4<qtQqT?"  r   c                 s    \        V P                  VP                  4      pV^ 8w  d   V# \        V P                  VP                  4      pV^ 8w  d   V# \        V P                  VP                  4      pV^ 8w  d   V# ^ # r   )r   	src_typesZ	tgt_typesZobj_classes)abZrets   && r
   
avrule_cmpr   P   sg    
Q[[!++
.C
ax

Q[[!++
.C
ax

Q]]AMM
2C
ax
 r   c                 s    V P                   ^ ,          VP                   ^ ,          8w  d/   \        V P                   ^ ,          VP                   ^ ,          4      # \        V P                  VP                  4      # r   )argsr   Zifnamer   r   r   r
   
ifcall_cmpr   _   sL    vvayAFF1I166!9affQi((qxx""r   c                 s   \        V \        P                  4      '       dT   \        V\        P                  4      '       d   \        W4      # \	        V P
                  ^ ,          .VP                  4      # \        V\        P                  4      '       g!   \        V\        P                  4      '       d   \        W4      # \	        V P                  VP
                  ^ ,          .4      # r   )

isinstancer    InterfaceCallr   r   r   r   ZAVRuleZ	AVExtRuler   r   r   r
   rule_cmpr    e   s    !Y,,--a0011a##qvvayk1;;77a))**jI<O<O.P.Pa?"akkAFF1I;77r   c                 sB    \        V P                  VP                  4      # r   )r   Zroler   r   r
   role_type_cmpr!   q   s    qvvqvvr   c                sJ    R pV P                  4        F  pV! V4       K  	  R# )z/Sort and group the output for readability.
    c                 s
   . pV P                  4        F8  pVP                  V4       VP                  \        P                  ! 4       4       K:  	  V P	                  4        F  pVP                  V4       K  	  VP                  \        P                  ! 4       4       . pVP                  V P                  4       4       VP                  V P                  4       4       VP                  V P                  4       4       VP                  \        P                  ! \        4      R 7       Rp. pV F  p\        V\        P                  4      '       d   VP                  ^ ,          pM \        P                   ! VP"                  4      pWX8w  dw   V'       d%   VP                  \        P                  ! 4       4       Tp\        P                  ! 4       p	V	P$                  P                  RV,          4       VP                  V	4       VP                  V4       K  	  VP                  V4       . p
V
P                  V P'                  4       4       V
P                  \        P                  ! \(        4      R 7       \+        V
4      '       dB   \        P                  ! 4       p	V	P$                  P                  R4       VP                  V	4       VP                  V
4       V P,                   F  pW9  g   K  VP                  V4       K  	  Wn        R# ))ZkeyNz============= %s ==============z"============= ROLES ==============)Zmodule_declarationsZappendr    ZCommentr   ZextendZavrulesZ
avextrulesZinterface_callsr   r   Z
cmp_to_keyr    r   r   r   Zfirstr   ZlinesZ
role_typesr!   r   Zchildren)r   ZcZmodZrequireZrulesZcurZ	sep_rulesZruler   ZcommentZrasZchilds   &           r
   	sort_nodeZsort_filter.<locals>.sort_nodew   s    ++-CHHSMHHY&&() .
 }}GHHW '	""$% T\\^$T__&'T))+,

tx0
1	D$	 7 788IIaLJJt~~.x$$Y%6%6%89#++-$$%F%LM  )T"  	
 

4??$%T__]34s88'')GMM  !EFHHW 	
 ]]E~ # r   N)Znodes)r   r"   r   s   &  r
   r   r   t   s!    ;z $ r   N)Z__doc__Z r    r   ZPY3r   r   r   r   r   r    r!   r   ) r   r
   <module>r#      sG   (  888 :#
8Ar   