o idS@sdZzddlZWn eyddlZYnwGdddeZGdddeZGdddeZd d ZGd d d eZ Gd ddeZ GdddeZ GdddeZ GdddeZ GdddeZddZGdddeZGdddeZGdddeZdS)zR This provides a restricted tag language to define the sosreport index/report Nc@seZdZddZddZdS)NodecCs t|jSN)jsondumpsdataselfr 6/usr/lib/python3/dist-packages/sos/report/reporting.py__str__s z Node.__str__cCsdS)NFr rnoder r r can_addsz Node.can_addN)__name__ __module__ __qualname__r rr r r r rs rc@seZdZdZdS)Leafz0Marker class that can be added to a Section nodeN)rrr__doc__r r r r rsrc@(eZdZdZddZddZddZdS) Reportz?The root element of a report. This is a container for sections.cCs i|_dSr)rrr r r __init__' zReport.__init__cC t|tSr) isinstanceSectionr r r r r*rzReport.can_addcGs&|D]}||r|j|j|j<qdSr)rrnamernodesr r r r add-s  z Report.addNrrrrrrrr r r r r$s  rcCt|tr|S|ddS)z3returns a string text for a given unicode/str inpututf8ignorerstrdecode)sr r r _decode3sr'c@r) rzeA section is a container for leaf elements. Sections may be nested inside of Report objects only.cCst||_i|_dSr)r'rr)rrr r r r<s  zSection.__init__cCrr)rrr r r r r@rzSection.can_addcGs0|D]}||r|j|jg|jqdSr)rr setdefaultADDS_TOappendrr r r rCs  z Section.addNrr r r r r8s  rc@eZdZdZddZdS)CommandcommandscCst||t|d|_dS)N)r return_codehrefr'r)rrr.r/r r r rMs zCommand.__init__Nrrrr)rr r r r r,I r,c@r+) CopiedFile copied_filescCt|t|d|_dSN)rr/r0rrr/r r r rW zCopiedFile.__init__Nr1r r r r r3Sr2r3c@r+) CreatedFile created_filescCr5r6r0r7r r r r`r8zCreatedFile.__init__Nr1r r r r r9\r2r9c@r+)AlertalertscCt||_dSrr0rcontentr r r rizAlert.__init__Nr1r r r r r;er2r;c@r+)NotenotescCr=rr0r>r r r rqr@z Note.__init__Nr1r r r r rAmr2rAcCs |dS)a Return True if 'string' ends with a backslash, and False otherwise. Define this as a named function for no other reason than that pep8 now forbids binding of a lambda expression to a name: 'E731 do not assign a lambda expression, use a def' \)endswith)stringr r r ends_bsus rFc@seZdZdZdZdZdZdZdZdZ dZ dZ d Z dZ d Zd Zeed dfeed dfeeddfeeddfeeddffZgZddZddZddZdS)PlainTextReportz@Will generate a plain text report from a top_level Report objectz * %(name)sz ! %sz * %szLoaded Plugins:z {name} z{name}zH========================================================================z- commands executed:z- files copied:z- files created:z - alerts:z - notes:cCstt|j|_dSr)sorteddictitemsr report_data)r report_noder r r rszPlainTextReport.__init__c Cs*g|_}t|jdkr||j||jd}d}t|j}|jD]!\}}||jj|d7}|d7}||jdkrE||krE||j 7}q$||j 7}|||jD](\}}||j ||j j|d|j D]\}} } } |||j| | | qjqSt|jdkr||jdtdd|} | S)NrrH)rrIcSr )Nr!r"r#)ir r r s z)PlainTextReport.unicode..)line_buflenHEADERr*PLUGLISTHEADERrN PLUGLISTITEMformatPLUGLISTMAXITEMS PLUGLISTSEPPLUGLISTFOOTER PLUGDIVIDER PLUGINFORMAT subsectionsprocess_subsectionr)FOOTERjoinmap) rrSlinerQ plugcount section_name_section_contentstype_format_headerfooteroutputr r r unicodes:           zPlainTextReport.unicodecCsd||vr.|j|t||dddD] }|j||qt|dkr0|j|dSdSdS)NcSst|tr |dSdS)NrrH)rrL)xr r r rRsz4PlainTextReport.process_subsection..)keyr)rSr*rKgetrT)rsectionrorjrirkitemr r r r_s   z"PlainTextReport.process_subsectionN)rrrrrUr`LEAFALERTNOTErVrWrZrYr[r]r\r,r3r9r;rAr^rSrrmr_r r r r rGs0      "rGc@sveZdZdZdZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zeed dfeeddfeeddfeeddfeeddffZdS) HTMLReportz:Will generate a HTML report from a top_level Report objecta Sos System Report zz(
  • %(name)s
  • z
  • %s
  • z#

    Loaded Plugins:

    z& z rJz
    {name}
    z+

    Plugin {name}

    z
    z

    Commands executed:

      z
    z

    Files copied:

      z

      Files created:

        z

        Alerts:

          z

          Notes:

            N)rrrrrUr`rsrtrurVrWrZrYr[r]r\r,r3r9r;rAr^r r r r rvs(     rvc@r+) JSONReportz:Will generate a JSON report from a top_level Report objectcCstj|jddd}|S)NF)indent ensure_ascii)rrrN)rrlr r r rmszJSONReport.unicodeN)rrrrrmr r r r rws rw)rr ImportError simplejsonobjectrrrr'rr,r3r9r;rArFrGrvrwr r r r s(         K&