ó â„^c@sdZddlmZddlmZejrBddlmZnddd„ƒYZd„Zd„Zd „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 ModuleWritercBseZd„Zd„ZRS(cCs(d|_d|_t|_t|_dS(N(tNonetfdtmoduletTruetsorttrequires(tself((s5/usr/lib64/python2.7/site-packages/sepolgen/output.pyt__init__&s   cCsf||_|jr"t|jƒnx=tj|jdtƒD]#\}}|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 cCs¦tj|ƒ}|jƒtj|ƒ}|jƒt|ƒt|ƒkr_t|d|dƒSx@t||ƒD]/}|d|dkrot|d|dƒSqoWdS(Nii(Rt set_to_listRtlenRtzip(txtytxltyltv((s5/usr/lib64/python2.7/site-packages/sepolgen/output.pyt id_set_cmp=s  cCsŽt|j|jƒ}|dk r%|St|j|jƒ}|dk rJ|St|j|jƒ}|dk ro|Stt|jƒt|jƒƒS(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|jdƒSt|j|jƒS(Ni(targsRtifname(R"R#((s5/usr/lib64/python2.7/site-packages/sepolgen/output.pyt ifcall_cmpZscCs‹t|tjƒrNt|tjƒr1t||ƒSt|jdg|jƒSn9t|tjƒrmt||ƒSt|j|jdgƒSdS(Ni( t isinstanceRt InterfaceCallR(RR&RtAVRuleR%(R"R#((s5/usr/lib64/python2.7/site-packages/sepolgen/output.pytrule_cmp`s  cCst|j|jƒS(N(Rtrole(R"R#((s5/usr/lib64/python2.7/site-packages/sepolgen/output.pyt role_type_cmplscCs.d„}x|jƒD]}||ƒqWdS(s/Sort and group the output for readability. c Ss6g}x4|jƒD]&}|j|ƒ|jtjƒƒqWx!|jƒD]}|j|ƒqJW|jtjƒƒg}|j|jƒƒ|j|jƒƒ|jdt j t ƒƒd}g}x­|D]¥}t |tjƒrô|jd}nt j|jƒ}||krd|r.|jtjƒƒn|}tjƒ} | jjd|ƒ|j| ƒn|j|ƒqÌW|j|ƒg} | j|jƒƒ| jdt j tƒƒt| ƒrìtjƒ} | 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