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/bcdoc/__pycache__/restdoc.cpython-310.pyc
o

.&�a,�@sZddlZddlmZddlmZddlmZe�d�ZGdd�de	�Z
Gdd	�d	e
�ZdS)
�N)�OrderedDict)�DocStringParser)�	ReSTStyle�bcdocsc@sneZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�ReSTDocument�mancCsBt|�|_||_t|�|_d|_d|_i|_i|_g|_	d|_
dS)NTF)r�style�targetr�parser�	keep_data�do_translation�translation_map�hrefs�_writes�_last_doc_string)�selfr	�r�6/usr/lib/python3/dist-packages/awscli/bcdoc/restdoc.py�__init__s


zReSTDocument.__init__cCs&|jr|dur|j�|�dSdSdS�N)rr�append�r�srrr�_write#s�zReSTDocument._writecCs|�|�dS)z2
        Write content into the document.
        N)r�r�contentrrr�write'szReSTDocument.writecCs|�d|j��|f�dS)z-
        Write content on a newline.
        z%s%s
N)rr�spacesrrrr�writeln-szReSTDocument.writelncCs
|jdS)zn
        Returns the last content written to the document without
        removing it from the stack.
        ����r�rrrr�
peek_write3s
zReSTDocument.peek_writecCs
|j��S)zL
        Removes and returns the last content written to the stack.
        )r�popr!rrr�	pop_write:s
zReSTDocument.pop_writecCs|j�|�dS)z2
        Places new content on the stack.
        N)rrrrrr�
push_write@szReSTDocument.push_writecCsD|jr|j��|j��D]\}}|j�||�q
d�|j��d�S)zJ
        Returns the current content of the document as a string.
        ��utf-8)rr�
new_paragraph�items�link_target_definition�joinr�encode)r�refname�linkrrr�getvalueFs

zReSTDocument.getvaluecs�fdd�|D�S)Ncsg|]	}�j�||��qSr)r
�get)�.0�wr!rr�
<listcomp>Qsz0ReSTDocument.translate_words.<locals>.<listcomp>r)r�wordsrr!r�translate_wordsP�zReSTDocument.translate_wordscCs |r|jr|�|�dSdSdSr)rr)r�datarrr�handle_dataSs
�zReSTDocument.handle_datacCsp|r6zt|j�}|j�|�|j��t|j�}||f|_WdSty5tjddd�t�|�YdSwdS)NzError parsing doc stringT)�exc_info)	�lenrr
�feed�closer�	Exception�LOG�debug)r�
doc_string�start�endrrr�include_doc_stringWs


��zReSTDocument.include_doc_stringcCs(|jdur|j\}}|j||�=dSdSr)rr)rrArBrrr�remove_last_doc_stringcs

�z#ReSTDocument.remove_last_doc_stringN)r)�__name__�
__module__�__qualname__rrrrr"r$r%r/r5r8rCrDrrrrrs

rcs�eZdZd�fdd�	Zedd��Zedd��Zejd	d��Zed
d��Zedd
��Z	dd�Z
ddd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Z�ZS) �DocumentStructureNrcsXtt|�j|d�||_t�|_|jg|_i|_|dur||_|dur*|�|�dSdS)a5Provides a Hierarichial structure to a ReSTDocument

        You can write to it similiar to as you can to a ReSTDocument but
        has an innate structure for more orginaztion and abstraction.

        :param name: The name of the document
        :param section_names: A list of sections to be included
            in the document.
        :param target: The target documentation of the Document structure
        :param context: A dictionary of data to store with the strucuture. These
            are only stored per section not the entire structure.
        )r	N)	�superrHr�_namer�
_structure�_path�_context�_generate_structure)r�name�
section_namesr	�context��	__class__rrrks

�zDocumentStructure.__init__cC�|jS)z"The name of the document structure)rJr!rrrrO�szDocumentStructure.namecCrT)zv
        A list of where to find a particular document structure in the
        overlying document structure.
        �rLr!rrr�path�szDocumentStructure.pathcCs
||_dSrrU)r�valuerrrrV��
cCs
t|j�Sr)�listrKr!rrr�available_sections�rXz$DocumentStructure.available_sectionscCrTr)rMr!rrrrQ�szDocumentStructure.contextcCs|D]}|�|�qdSr)�add_new_section)rrP�section_namerrrrN�s�z%DocumentStructure._generate_structurecCsJ|j||j|d�}|j|g|_|jj|j_|j|_|j|_||j|<|S)a�Adds a new section to the current document structure

        This document structure will be considered a section to the
        current document structure but will in itself be an entirely
        new document structure that can be written to and have sections
        as well

        :param name: The name of the section.
        :param context: A dictionary of data to store with the strucuture. These
            are only stored per section not the entire structure.
        :rtype: DocumentStructure
        :returns: A new document structure to add to but lives as a section
            to the document structure it was instantiated from.
        )rOr	rQ)rSr	rVr�indentationr
rrK)rrOrQ�sectionrrrr[�s
�
z!DocumentStructure.add_new_sectioncCs
|j|S)zRetrieve a section�rK�rrOrrr�get_section�rXzDocumentStructure.get_sectioncCs|j|=dS)zDelete a sectionNr_r`rrr�delete_section�sz DocumentStructure.delete_sectioncCslt|j�dkr |jr |j��|j��D]\}}|j�||�q|��}|j��D]
\}}||�	�7}q)|S)z�Flushes a doc structure to a ReSTructed string

        The document is flushed out in a DFS style where sections and their
        subsections' values are added to the string as they are visited.
        �)
r:rVrrr(r)r*r/rK�flush_structure)rr-r.rWrOr^rrrrd�s
z!DocumentStructure.flush_structurecCsd�|j��d�S)Nr&r')r+rr,r!rrrr/�r6zDocumentStructure.getvaluecCst�|_dSr)rrKr!rrr�remove_all_sections�sz%DocumentStructure.remove_all_sectionscCs
g|_dSrr r!rrr�
clear_text�s
zDocumentStructure.clear_text)NrNr)rErFrGr�propertyrOrV�setterrZrQrNr[rarbrdr/rerf�
__classcell__rrrRrrHjs(





rH)�logging�botocore.compatr�awscli.bcdoc.docstringparserr�awscli.bcdoc.styler�	getLoggerr>�objectrrHrrrr�<module>s
T