a >hq@sdZz ddlZWney*ddlZYn0GdddZGdddeZGdddeZd d ZGd d d eZGd ddeZ GdddeZ GdddeZ GdddeZ GdddeZ ddZGdddZGdddeZGdddeZdS)zS This provides a restricted tag language to define the sos report index/report Nc@s eZdZiZddZddZdS)NodecCs t|jSN)jsondumpsdataselfr 8/usr/lib/python3.9/site-packages/sos/report/reporting.py__str__sz Node.__str__cCsdS)NFr rnoder r r can_addsz Node.can_addN)__name__ __module__ __qualname__rr rr r r r rsrc@seZdZdZdS)Leafz0Marker class that can be added to a Section nodeN)rrr__doc__r r r r r"src@s(eZdZdZddZddZddZdS) Reportz?The root element of a report. This is a container for sections.cCs i|_dSr)rrr r r __init__)szReport.__init__cCs t|tSr) isinstanceSectionr r r r r,szReport.can_addcGs&|D]}||r|j|j|j<qdSr)rrnamerZnodesr r r r add/s z Report.addNrrrrrrrr r r r r&srcCst|tr|S|ddS)z3returns a string text for a given unicode/str inpututf8ignorerstrdecode)sr r r _decode5sr"c@s(eZdZdZddZddZddZdS) 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__cCs t|tSr)rrr r r r rBszSection.can_addcGs0|D]&}||r|j|jg|jqdSr)rr setdefaultADDS_TOappendrr r r rEs z Section.addNrr r r r r:src@seZdZdZddZdS)CommandZcommandscCst||t|d|_dS)N)r return_codehrefr"r)rrr'r(r r r rOszCommand.__init__Nrrrr$rr r r r r&Ksr&c@seZdZdZddZdS) CopiedFileZ copied_filescCst|t|d|_dSN)rr(r)rrr(r r r rYszCopiedFile.__init__Nr*r r r r r+Usr+c@seZdZdZddZdS) CreatedFileZ created_filescCst|t|d|_dSr,r)r-r r r rbszCreatedFile.__init__Nr*r r r r r.^sr.c@seZdZdZddZdS)AlertZalertscCst||_dSrr)rZcontentr r r rkszAlert.__init__Nr*r r r r r/gsr/c@seZdZdZddZdS)NoteZnotescCst||_dSrr)r0r r r rssz Note.__init__Nr*r r r r r1osr1cCs |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_bswsr5c@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)s z%(name)szH========================================================================z- commands executed:z- files copied:z- files created:z - alerts:z - notes:cCstt|j|_dSr)sorteddictitemsr report_data)rZ report_noder r r rszPlainTextReport.__init__c Cs,g|_}t|jdkr$||j||jd}d}t|j}|jD]B\}}||jd|i7}|d7}||jdkrH||krH||j7}qH||j 7}|||jD]P\}}||j ||j d|i|j D] \}} } } | ||j| | | qqt|jdkr||jdtdd|} | S)Nrr7rr8cSst|tr|S|ddS)Nrrr)ir r r sz)PlainTextReport.unicode..)line_buflenHEADERr%PLUGLISTHEADERr= PLUGLISTITEMPLUGLISTMAXITEMS PLUGLISTSEPPLUGLISTFOOTER PLUGDIVIDER PLUGINFORMAT subsectionsprocess_subsectionr$FOOTERjoinmap) rrAliner?Z plugcountZ section_name_Zsection_contentstype_format_headerfooteroutputr r r unicodes6           zPlainTextReport.unicodecCs\||vrX|j|t||dddD]}|j||q*t|dkrX|j|dS)NcSst|tr|dSdS)Nrr7)rr;)xr r r r@z4PlainTextReport.process_subsection..)keyr)rAr%r:getrB)rsectionrZrTrSrUitemr r r rLs   z"PlainTextReport.process_subsectionN)rrrrrCrMLEAFALERTNOTErDrErGrFrHrJrIr&r+r.r/r1rKrArrWrLr r r r r6s.     "r6c@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 r9z
    %(name)s
    z/

    Plugin %(name)s

    z
    z

    Commands executed:

      z
    z

    Files copied:

      z

      Files created:

        z

        Alerts:

          z

          Notes:

            N)rrrrrCrMr^r_r`rDrErGrFrHrJrIr&r+r.r/r1rKr r r r ras&     rac@seZdZdZddZdS) JSONReportz:Will generate a JSON report from a top_level Report objectcCstj|jddd}|S)NF)indentZ ensure_ascii)rrr=)rrVr r r rWszJSONReport.unicodeN)rrrrrWr r r r rbsrb)rr ImportErrorZ simplejsonrrrr"rr&r+r.r/r1r5r6rarbr r r r  s$       K&