^c@sdZddlmZddlmZejrBddlmZndddYZdZdZd Z d Z d Z d Z d S(si 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. i(t refpolicy(tutil(tcmpt ModuleWritercBseZdZdZRS(cCs(d|_d|_t|_t|_dS(N(tNonetfdtmoduletTruetsorttrequires(tself((s5/usr/lib64/python2.7/site-packages/sepolgen/output.pyt__init__&s   cCsf||_|jr"t|jnx=tj|jdtD]#\}}|jdt|q;WdS(Nt showdepths%s (RRt sort_filterRtwalktreeRtwritetstr(R RRtnodetdepth((s5/usr/lib64/python2.7/site-packages/sepolgen/output.pyR,s   %(t__name__t __module__R R(((s5/usr/lib64/python2.7/site-packages/sepolgen/output.pyR%s cCstj|}|jtj|}|jt|t|kr_t|d|dSx@t||D]/}|d|dkrot|d|dSqoWdS(Nii(Rt set_to_listRtlenRtzip(txtytxltyltv((s5/usr/lib64/python2.7/site-packages/sepolgen/output.pyt id_set_cmp=s  cCst|j|j}|dk r%|St|j|j}|dk rJ|St|j|j}|dk ro|Stt|jt|jS(Ni(Rt src_typest tgt_typest obj_classesRRtperms(tatbtret((s5/usr/lib64/python2.7/site-packages/sepolgen/output.pyt avrule_cmpKs   cCsH|jd|jdkr5t|jd|jdSt|j|jS(Ni(targsRtifname(R"R#((s5/usr/lib64/python2.7/site-packages/sepolgen/output.pyt ifcall_cmpZscCst|tjrNt|tjr1t||St|jdg|jSn9t|tjrmt||St|j|jdgSdS(Ni( t isinstanceRt InterfaceCallR(RR&RtAVRuleR%(R"R#((s5/usr/lib64/python2.7/site-packages/sepolgen/output.pytrule_cmp`s  cCst|j|jS(N(Rtrole(R"R#((s5/usr/lib64/python2.7/site-packages/sepolgen/output.pyt role_type_cmplscCs.d}x|jD]}||qWdS(s/Sort and group the output for readability. c Ss6g}x4|jD]&}|j||jtjqWx!|jD]}|j|qJW|jtjg}|j|j|j|j|jdt j t d}g}x|D]}t |tjr|jd}nt j|j}||krd|r.|jtjn|}tj} | jjd||j| n|j|qW|j|g} | j|j| jdt j tt| rtj} | jjd|j| n|j| x-|jD]"} | |kr|j| qqW||_dS(Ntkeyis============= %s ==============s"============= ROLES ==============(tmodule_declarationstappendRtCommentR textendtavrulestinterface_callsRRt cmp_to_keyR,RR)R*R&tfirstRtlinest role_typesR.Rtchildren( Rtctmodtrequiretrulestcurt sep_rulestruleRtcommenttrastchild((s5/usr/lib64/python2.7/site-packages/sepolgen/output.pyt sort_nodersL         N(tnodes(RRER((s5/usr/lib64/python2.7/site-packages/sepolgen/output.pyR os <N(( t__doc__tRRtPY3RRRR%R(R,R.R (((s5/usr/lib64/python2.7/site-packages/sepolgen/output.pyts