HEX
Server: Apache/2.4.62 (Unix) OpenSSL/1.1.1k
System: Linux ns565604.ip-54-39-133.net 4.18.0-553.50.1.el8_10.x86_64 #1 SMP Tue Apr 15 08:09:22 EDT 2025 x86_64
User: greer489 (1034)
PHP: 8.3.19
Disabled: NONE
Upload Files
File: //usr/lib/python3.6/site-packages/sepolgen/__pycache__/output.cpython-36.opt-1.pyc
3

Kl�f��@spdZddlmZddlmZejr.ddlmZGdd�d�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)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@seZdZdd�Zdd�ZdS)�ModuleWritercCsd|_d|_d|_d|_dS)NT)�fd�module�sort�requires)�self�r�/usr/lib/python3.6/output.py�__init__&szModuleWriter.__init__cCsJ||_|jrt|j�x.tj|jdd�D]\}}|jdt|��q(WdS)NT)Z	showdepthz%s
)rr�sort_filterrZwalktree�write�str)r
rr�node�depthrrrr,s

zModuleWriter.writeN)�__name__�
__module__�__qualname__r
rrrrrr%srcCs�tj|�}|j�tj|�}|j�t|�t|�krFt|d|d�Sx4t||�D]&}|d|dkrRt|d|d�SqRWdS)N�r)rZset_to_listr�lenr�zip)�x�yZxlZyl�vrrr�
id_set_cmp=s

rcCsdt|j|j�}|dkr|St|j|j�}|dkr4|St|j|j�}|dkrN|Stt|j�t|j��S)Nr)r�	src_typesZ	tgt_typesZobj_classesrrZperms)�a�b�retrrr�
avrule_cmpKsr!cCs8|jd|jdkr*t|jd|jd�St|j|j�S)Nr)�argsrZifname)rrrrr�
ifcall_cmpZsr#cCsft|tj�r8t|tj�r"t||�St|jdg|j�Sn*t|tj�rNt||�St|j|jdg�SdS)Nr)	�
isinstancer�
InterfaceCallr#rr"rZAVRuler!)rrrrr�rule_cmp`s

r&cCst|j|j�S)N)rZrole)rrrrr�
role_type_cmplsr'cCs&dd�}x|j�D]}||�qWdS)z/Sort and group the output for readability.
    cSs�g}x(|j�D]}|j|�|jtj��qWx|j�D]}|j|�q8W|jtj��g}|j|j��|j|j��|jt	j
t�d�d}g}x||D]t}t|tj
�r�|jd}nt	j|j�}||k�r|r�|jtj��|}tj�}	|	jjd|�|j|	�|j|�q�W|j|�g}
|
j|j��|
jt	j
t�d�t|
��rftj�}	|	jjd�|j|	�|j|
�x$|jD]}||k�rx|j|��qxW||_dS)N)�keyrz============= %s ==============z"============= ROLES ==============)Zmodule_declarations�appendr�Commentr	�extendZavrulesZinterface_callsrr�
cmp_to_keyr&r$r%r"�firstr�linesZ
role_typesr'rZchildren)r�c�modZrequireZrulesZcurZ	sep_rulesZrulerZcommentZrasZchildrrr�	sort_nodersL








zsort_filter.<locals>.sort_nodeN)Znodes)rr1rrrrros<rN)
�__doc__�rrZPY3rrrr!r#r&r'rrrrr�<module>s