HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/awscli/customizations/history/__pycache__/show.cpython-310.pyc
o

.&�aj<�@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||_|jdurtj|_|r|rtd��||_||_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�D/usr/lib/python3/dist-packages/awscli/customizations/history/show.py�__init__s
�
zFormatter.__init__cCs|�|�r|�|�dSdS)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.displaycCstd��)Nz
_display())�NotImplementedErrorrrrrr>szFormatter._displaycCs,|jr
|d|jvS|jr|d|jvSdS)N�
event_typeT)rr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 service�service)r�payload_keyzusing operation�	operationzwith parameters�params�
dictionary)rr#�value_formatzHTTP request sentzto URL�urlzwith method�methodzwith headers�headers)rr#r'�filtersz	with body�body�	http_bodyzHTTP response receivedzwith status code�status_codezHTTP response parsedz	parsed to)rr'zAWS CLI command exitedzwith return code)�CLI_VERSION�
CLI_ARGUMENTS�API_CALL�HTTP_REQUEST�
HTTP_RESPONSE�PARSED_RESPONSE�CLI_RC)r rNTcsLtt|��|||�i|_d|_||_t�|_|jr$tj	dit
��dSdS)Nrr)�superrr�_request_id_to_api_num�_num_api_calls�	_colorize�SectionValuePrettyFormatter�_value_pformatter�colorama�initr)r
rrr�colorize��	__class__rrr�s�zDetailedFormatter.__init__cCs,|j�|d�}|dur|�||�dSdS)Nr)�	_SECTIONS�get�_display_section)r
r�section_definitionrrrr�s�zDetailedFormatter._displaycCs6d|vr|�|d|�|dD]}|�||�qdS)Nr r!)�_display_title�_display_value)r
rrD�value_definitionrrrrC�s
�z"DetailedFormatter._display_sectioncCs|�||�}|�|�dS�N)�_format_section_title�
_write_output)r
r r�formatted_titlerrrrE�sz DetailedFormatter._display_titlecCsx|d}|d}|}d|vr||d}|�|�}||�|||�d��7}d|vr5|dD]}|�|�}q-|�|�dS)Nr�payloadr#r'r+)�_format_description�
_format_valuerB�filter_textrJ)r
rGr�value_description�event_record_payload�value�formatted_value�text_filterrrrrF�s
�z DetailedFormatter._display_valuecCs&t|tj�r|�d�}|j�|�dS)Nzutf-8)�
isinstancer�	text_type�encoder�write)r
�contentrrrrJ�s
zDetailedFormatter._write_outputcCsd|}|�|�}|durd||}|�|d�}|d7}|�d�}||j|d|dd�7}d||S)Nz[%s] r �
zat time�	timestamp)r')�_get_api_num�_color_if_configuredrMrN)r
r rrK�api_num�formatted_timestamprrrrI�s


�z'DetailedFormatter._format_section_titlecCs>|d}|r||jvr|j|j|<|jd7_|j|SdS)N�
request_id�)r7r8)r
rr`rrrr\�s
��
�zDetailedFormatter._get_api_numcCs|�|dd�S)Nz: r)r])r
rPrrrrM�s�z%DetailedFormatter._format_descriptioncCs,|r|j�|||�}|dSt|�}|dS)NrZ)r;�pformat�str)r
rRrr'rSrrrrN�s��zDetailedFormatter._format_valuecCs$|jr|j|}||tjjS|SrH)r9�_COMPONENT_COLORSr<�Style�	RESET_ALL)r
�text�	component�colorrrrr]�s
z&DetailedFormatter._color_if_configured)NNNTrH)rrrr�_SIG_FILTERrAr<re�BRIGHT�Fore�CYANrdrrrCrErFrJrIr\rMrNr]�
__classcell__rrr?rrJs�������������������������
���\�		
rc@sXeZdZdd�Zddd�Zddd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdS)r:cCst|d|�||�S)N�	_pformat_)�getattr)r
rRr'rrrrrbsz#SectionValuePrettyFormatter.pformatNcCstj�|d��d�dd�S)Ng@�@z%Y-%m-%d %H:%M:%S.%f���)�datetime�
fromtimestamp�strftime)r
�event_timestamprrrr�_pformat_timestamp
s
��z.SectionValuePrettyFormatter._pformat_timestampcCstj|ddd�S)NT�)�obj�	sort_keys�indent)�json�dumps)r
rxrrrr�_pformat_dictionarysz/SectionValuePrettyFormatter._pformat_dictionarycCsH|sdS|d�dd�rdS|�|�r|�|�S|�|�r"|�|�S|S)NzThere is no associated bodyrL�	streamingFz.The body is a stream and will not be displayed)rB�_is_xml�_get_pretty_xml�_is_json_structure�_get_pretty_json)r
r,rrrr�_pformat_http_bodys



z.SectionValuePrettyFormatter._pformat_http_bodycCs&|�|�}tjj�|�}|jddd�S)Nz    rZ)rz�newl)�_strip_whitespace�xml�dom�minidom�parseString�toprettyxml)r
r,�
stripped_body�xml_domrrrr�#s
z+SectionValuePrettyFormatter._get_pretty_xmlcCst�|�}|�|�SrH)r{�loadsr})r
r,rxrrrr�.s

z,SectionValuePrettyFormatter._get_pretty_jsoncCs0z
tjj�|�WdStjjjyYdSw)NFT)r�r�r�r��parsers�expat�
ExpatError�r
r,rrrr4s��z#SectionValuePrettyFormatter._is_xmlcCs*tjj�|�}d�dd�|����D��S)N�cSsg|]}|���qSr)�strip)�.0�linerrr�
<listcomp>>szASectionValuePrettyFormatter._strip_whitespace.<locals>.<listcomp>)r�r�r�r��join�toxml�
splitlines)r
�
xml_stringr�rrrr�;s�z-SectionValuePrettyFormatter._strip_whitespacecCs8|�d�rzt�|�WdStjjyYdSwdS)N�{TF)�
startswithr{r��decoder�JSONDecodeErrorr�rrrr�As

�z.SectionValuePrettyFormatter._is_json_structurerH)rrrrbrvr}r�r�r�rr�r�rrrrr:s

r:c@sreZdZdZdZdeiZdddddd	�d
ddd
�dddd
�de��ddd�gZdd�Z	dd�Z
dd�Zdd�ZdS)�ShowCommand�showz�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�default�positional_arg�	help_textr�+z�Specifies which events to **only** include when showing the CLI command. This argument is mutually exclusive with ``--exclude``.)r�r�r�rzwSpecifies 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>)r��choicesr�r�cCs�|��z;|�|�|���}|�|||�}|�|�D]}|�|�qWd�n1s-wYW|��dSW|��dS|��w)Nr)�_connect_to_history_db�_validate_args�_get_output_stream�_get_formatter�_get_record_iteratorr�_close_history_db)r
�parsed_args�parsed_globals�
output_stream�	formatter�recordrrr�	_run_mainys"

����
�zShowCommand._run_maincCs|jr
|jrtd��dSdS)Nz:Either --exclude or --include can be provided but not both)rrr
�r
r�rrrr��s
��zShowCommand._validate_argscCs@|j}|j|j|d�}|dkr|�|�|d<|j|di|��S)N)rrrr�r>r)r�rr�_should_use_color�
FORMATTERS)r
r�r�r��format_type�formatter_kwargsrrrr��s��zShowCommand._get_formattercCs"|jdkr
|j��S|j�|j�S)Nr�)r��
_db_reader�iter_latest_records�iter_recordsr�rrrr��s

z ShowCommand._get_record_iteratorN)
rrr�NAME�DESCRIPTIONrr��keys�	ARG_TABLEr�r�r�r�rrrrr�Ks2�������$
r�)rrr{r�xml.parsers.expatr��xml.dom.minidomr<�awscli.tabler�
awscli.compatr�&awscli.customizations.history.commandsr�%awscli.customizations.history.filtersr�objectrrr:r�rrrr�<module>s/=E