HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //usr/lib/python3.6/site-packages/awscli/customizations/history/__pycache__/show.cpython-36.pyc
3

�T_j<�@s�ddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZGdd�de�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZdS)�N)�COLORAMA_KWARGS)�six)�HistorySubcommand)�RegexFilterc@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)�	FormatterNcCs8||_|jdkrtj|_|r(|r(td��||_||_dS)a#Formats and outputs CLI history events

        :type output: File-like obj
        :param output: The stream to write the formatted event to. By default
            sys.stdout is used.

        :type include: list
        :param include: A filter specifying which event to only be displayed.
            This parameter is mutually exclusive with exclude.

        :type exclude: list
        :param exclude: A filter specifying which events to exclude from being
            displayed. This parameter is mutually exclusive with include.

        Nz4Either input or exclude can be provided but not both)�_output�sys�stdout�
ValueError�_include�_exclude)�self�output�include�exclude�r�/usr/lib/python3.6/show.py�__init__s
zFormatter.__init__cCs|j|�r|j|�dS)z�Displays a formatted version of the event record

        :type event_record: dict
        :param event_record: The event record to format and display.
        N)�_should_display�_display)r
�event_recordrrr�display5s
zFormatter.displaycCstd��dS)Nz
_display())�NotImplementedError)r
rrrrr>szFormatter._displaycCs0|jr|d|jkS|jr(|d|jkSdSdS)N�
event_typeT)rr)r
rrrrrAs
zFormatter._should_display)NNN)�__name__�
__module__�__qualname__rrrrrrrrrs
	rcs@eZdZedd�Zdddigd�dddigid	d
dd�d
dd�dddd�gd�dddd�ddd�dddegd�dddd�gd�ddd d�dddd�dddd�gd�d!d"dd#�gd�d$dd%igd�d&�Zejjej	j
d'�Zd@�fd*d+�	Zd,d-�Z
d.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�ZdAd<d=�Zd>d?�Z�ZS)B�DetailedFormatterz#Signature=([a-z0-9]{4})[a-z0-9]{60}zSignature=\1...zAWS CLI command entered�descriptionzwith AWS CLI version)�title�valuesr zwith argumentsz
API call madez
to serviceZservice)r�payload_keyzusing operationZ	operationzwith parametersZparamsZ
dictionary)rr!�value_formatzHTTP request sentzto URLZurlzwith method�methodzwith headersZheaders)rr!r"�filtersz	with body�bodyZ	http_bodyzHTTP response receivedzwith status codeZstatus_codezHTTP response parsedz	parsed to)rr"zAWS CLI command exitedzwith return code)ZCLI_VERSIONZ
CLI_ARGUMENTSZAPI_CALLZHTTP_REQUESTZ
HTTP_RESPONSEZPARSED_RESPONSEZCLI_RC)rrNTcsDtt|�j|||�i|_d|_||_t�|_|jr@tj	ft
�dS)Nr)�superrr�_request_id_to_api_num�_num_api_calls�	_colorize�SectionValuePrettyFormatter�_value_pformatter�coloramaZinitr)r
rrr�colorize)�	__class__rrr�szDetailedFormatter.__init__cCs(|jj|d�}|dk	r$|j||�dS)Nr)�	_SECTIONS�get�_display_section)r
r�section_definitionrrrr�szDetailedFormatter._displaycCs:d|kr|j|d|�x|dD]}|j||�q"WdS)Nrr )�_display_title�_display_value)r
rr2�value_definitionrrrr1�sz"DetailedFormatter._display_sectioncCs|j||�}|j|�dS)N)�_format_section_title�
_write_output)r
rr�formatted_titlerrrr3�sz DetailedFormatter._display_titlecCs||d}|d}|}d|kr(||d}|j|�}||j|||jd��7}d|krnx|dD]}|j|�}q\W|j|�dS)Nr�payloadr!r"r$)�_format_description�
_format_valuer0Zfilter_textr7)r
r5r�value_descriptionZevent_record_payload�value�formatted_valueZtext_filterrrrr4�s
z DetailedFormatter._display_valuecCs&t|tj�r|jd�}|jj|�dS)Nzutf-8)�
isinstancerZ	text_type�encoder�write)r
Zcontentrrrr7�s
zDetailedFormatter._write_outputcCsd|}|j|�}|dk	r"d||}|j|d�}|d7}|jd�}||j|d|dd�7}d||S)Nz[%s] r�
zat timeZ	timestamp)r")�_get_api_num�_color_if_configuredr:r;)r
rrr8Zapi_numZformatted_timestamprrrr6�s

z'DetailedFormatter._format_section_titlecCs>|d}|r:||jkr0|j|j|<|jd7_|j|SdS)N�
request_id�)r'r()r
rrErrrrC�s
zDetailedFormatter._get_api_numcCs|j|dd�S)Nz: r)rD)r
r<rrrr:�sz%DetailedFormatter._format_descriptioncCs&|r|jj|||�}nt|�}|dS)NrB)r+�pformat�str)r
r=rr"r>rrrr;�s
zDetailedFormatter._format_valuecCs$|jr |j|}||tjjS|S)N)r)�_COMPONENT_COLORSr,�StyleZ	RESET_ALL)r
�textZ	componentZcolorrrrrD�s
z&DetailedFormatter._color_if_configured)NNNT)N)rrrrZ_SIG_FILTERr/r,rJZBRIGHTZForeZCYANrIrrr1r3r4r7r6rCr:r;rD�
__classcell__rr)r.rrJsl
		
rc@sXeZdZdd�Zddd�Zddd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdS)r*cCst|d|�||�S)NZ	_pformat_)�getattr)r
r=r"rrrrrGsz#SectionValuePrettyFormatter.pformatNcCstjj|d�jd�dd�S)Ng@�@z%Y-%m-%d %H:%M:%S.%f����)�datetimeZ
fromtimestampZstrftime)r
Zevent_timestamprrrr�_pformat_timestamp
sz.SectionValuePrettyFormatter._pformat_timestampcCstj|ddd�S)NT�)�objZ	sort_keys�indent)�json�dumps)r
rSrrrr�_pformat_dictionarysz/SectionValuePrettyFormatter._pformat_dictionarycCsL|sdS|djdd�rdS|j|�r0|j|�S|j|�rD|j|�S|SdS)NzThere is no associated bodyr9Z	streamingFz.The body is a stream and will not be displayed)r0�_is_xml�_get_pretty_xml�_is_json_structure�_get_pretty_json)r
r%rrrr�_pformat_http_bodys



z.SectionValuePrettyFormatter._pformat_http_bodycCs&|j|�}tjjj|�}|jddd�S)N� rRrB)rTZnewlz    )�_strip_whitespace�xml�dom�minidom�parseStringZtoprettyxml)r
r%Z
stripped_body�xml_domrrrrY#s
z+SectionValuePrettyFormatter._get_pretty_xmlcCstj|�}|j|�S)N)rU�loadsrW)r
r%rSrrrr[.s
z,SectionValuePrettyFormatter._get_pretty_jsoncCs2ytjjj|�Wntjjjk
r,dSXdS)NFT)r_r`rarbZparsersZexpatZ
ExpatError)r
r%rrrrX4s
z#SectionValuePrettyFormatter._is_xmlcCs*tjjj|�}djdd�|j�j�D��S)N�cSsg|]}|j��qSr)�strip)�.0�linerrr�
<listcomp>>szASectionValuePrettyFormatter._strip_whitespace.<locals>.<listcomp>)r_r`rarb�joinZtoxml�
splitlines)r
Z
xml_stringrcrrrr^;sz-SectionValuePrettyFormatter._strip_whitespacecCs6|jd�r2ytj|�dStjjk
r0dSXdS)N�{TF)�
startswithrUrd�decoderZJSONDecodeError)r
r%rrrrZAs

z.SectionValuePrettyFormatter._is_json_structure)N)N)rrrrGrQrWr\rYr[rXr^rZrrrrr*s

r*c@sreZdZdZdZdeiZdddddd	�d
ddd
�dddd
�dej�ddd�gZdd�Z	dd�Z
dd�Zdd�ZdS)�ShowCommandZshowz�Shows the various events related to running a specific CLI command. If this command is ran without any positional arguments, it will display the events for the last CLI command ran.�detailed�
command_id�?�latestTzuThe ID of the CLI command to show. If this positional argument is omitted, it will show the last the CLI command ran.)�name�nargs�defaultZpositional_arg�	help_textr�+z�Specifies which events to **only** include when showing the CLI command. This argument is mutually exclusive with ``--exclude``.)rtrurwrzwSpecifies which events to exclude when showing the CLI command. This argument is mutually exclusive with ``--include``.�formataESpecifies which format to use in showing the events for the specified CLI command. The following formats are supported:

<ul><li> detailed - This the default format. It prints out a detailed overview of the CLI command ran. It displays all of the key events in the command lifecycle where each important event has a title and its important values underneath. The events are ordered by timestamp and events of the same API call are associated together with the [``api_id``] notation where events that share the same ``api_id`` belong to the lifecycle of the same API call.</li></ul>)rt�choicesrvrwcCsf|j�zN|j|�|j��2}|j|||�}x|j|�D]}|j|�q8WWdQRXWd|j�XdS)Nr)Z_connect_to_history_db�_validate_argsZ_get_output_stream�_get_formatter�_get_record_iteratorrZ_close_history_db)r
�parsed_args�parsed_globals�
output_streamZ	formatter�recordrrr�	_run_mainys



zShowCommand._run_maincCs|jr|jrtd��dS)Nz:Either --exclude or --include can be provided but not both)rrr
)r
r~rrrr{�szShowCommand._validate_argscCs<|j}|j|j|d�}|dkr,|j|�|d<|j|f|�S)N)rrrrpr-)ryrrZ_should_use_color�
FORMATTERS)r
r~rr�Zformat_typeZformatter_kwargsrrrr|�s
zShowCommand._get_formattercCs&|jdkr|jj�S|jj|j�SdS)Nrs)rqZ
_db_readerZiter_latest_recordsZiter_records)r
r~rrrr}�s

z ShowCommand._get_record_iteratorN)
rrr�NAMEZDESCRIPTIONrr��keysZ	ARG_TABLEr�r{r|r}rrrrroKs"

ro)rPrUrZxml.parsers.expatr_Zxml.dom.minidomr,Zawscli.tablerZ
awscli.compatrZ&awscli.customizations.history.commandsrZ%awscli.customizations.history.filtersr�objectrrr*rorrrr�<module>
s/=E