HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/docx/__pycache__/document.cpython-310.pyc
o

$weh�@s�dZddlmZddlmZmZmZmZddlm	Z	ddl
mZddlm
Z
ddlmZmZddlmZmZerldd	lmZdd
lmZmZddlmZddlmZdd
lmZddlm Z m!Z!ddl"m#Z#ddl$m%Z%Gdd�de�Z&Gdd�de	�Z'dS)z'|Document| and closely related objects.�)�annotations)�IO�
TYPE_CHECKING�Iterator�List)�BlockItemContainer)�
WD_SECTION)�WD_BREAK)�Section�Sections)�ElementProxy�Emu)�types)�CT_Body�CT_Document)�DocumentPart)�Settings)�Length)�ParagraphStyle�_TableStyle)�Table)�	Paragraphcs
eZdZdZdI�fdd�ZdJdKdd�Zdd�Z	dLdMdd�Z		dNdOdd�Ze	j
fdPd"d#�ZdQdRd'd(�Ze
d)d*��Ze
d+d,��ZdSd.d/�Ze
dTd1d2��Ze
dUd3d4��ZdVd6d7�Ze
dWd9d:��Ze
dXd<d=��Ze
d>d?��Ze
dYdAdB��Ze
dZdDdE��Ze
d[dGdH��Z�ZS)\�Documentz�WordprocessingML (WML) document.

    Not intended to be constructed directly. Use :func:`docx.Document` to open or create
    a document.
    �elementr�partrcs&tt|��|�||_||_d|_dS�N)�superr�__init__�_element�_part�_Document__body)�selfrr��	__class__��F/home/arjun/projects/env/lib/python3.10/site-packages/docx/document.pyr"s
zDocument.__init__���text�str�level�intcCsBd|kr
dksntd|��|dkrdnd|}|�||�S)a�Return a heading paragraph newly added to the end of the document.

        The heading paragraph will contain `text` and have its paragraph style
        determined by `level`. If `level` is 0, the style is set to `Title`. If `level`
        is 1 (or omitted), `Heading 1` is used. Otherwise the style is set to `Heading
        {level}`. Raises |ValueError| if `level` is outside the range 0-9.
        r�	z"level must be in range 0-9, got %d�Titlez
Heading %d)�
ValueError�
add_paragraph)r!r(r*�styler$r$r%�add_heading(szDocument.add_headingcCs|��}|���tj�|S)z=Return newly |Paragraph| object containing only a page break.)r/�add_run�	add_breakr	�PAGE)r!�	paragraphr$r$r%�add_page_break5szDocument.add_page_breakNr0�str | ParagraphStyle | None�returnrcCs|j�||�S)a�Return paragraph newly added to the end of the document.

        The paragraph is populated with `text` and having paragraph style `style`.

        `text` can contain tab (``\t``) characters, which are converted to the
        appropriate XML form for a tab. `text` can also include newline (``\n``) or
        carriage return (``\r``) characters, each of which is converted to a line
        break.
        )�_bodyr/)r!r(r0r$r$r%r/;szDocument.add_paragraph�image_path_or_stream�str | IO[bytes]�width�int | Length | None�heightcCs|����}|�|||�S)a�Return new picture shape added in its own paragraph at end of the document.

        The picture contains the image at `image_path_or_stream`, scaled based on
        `width` and `height`. If neither width nor height is specified, the picture
        appears at its native size. If only one is specified, it is used to compute a
        scaling factor that is then applied to the unspecified dimension, preserving the
        aspect ratio of the image. The native size of the picture is calculated using
        the dots-per-inch (dpi) value specified in the image file, defaulting to 72 dpi
        if no value is specified, as is often the case.
        )r/r2�add_picture)r!r:r<r>�runr$r$r%r?IszDocument.add_picture�
start_typercCs|jj��}||_t||j�S)z�Return a |Section| object newly added at the end of the document.

        The optional `start_type` argument must be a member of the :ref:`WdSectionStart`
        enumeration, and defaults to ``WD_SECTION.NEW_PAGE`` if not provided.
        )r�body�add_section_breakrAr
r)r!rA�
new_sectPrr$r$r%�add_section\szDocument.add_section�rows�cols�str | _TableStyle | NonecCs|j�|||j�}||_|S)z�Add a table having row and column counts of `rows` and `cols` respectively.

        `style` may be a table style object or a table style name. If `style` is |None|,
        the table inherits the default table style of the document.
        )r9�	add_table�_block_widthr0)r!rFrGr0�tabler$r$r%rIfszDocument.add_tablecC�|jjS)zGA |CoreProperties| object providing Dublin Core properties of document.)r�core_properties�r!r$r$r%rMp�zDocument.core_propertiescCrL)z�The |InlineShapes| collection for this document.

        An inline shape is a graphical object, such as a picture, contained in a run of
        text and behaving like a character glyph, being flowed like other text in a
        paragraph.
        )r�
inline_shapesrNr$r$r%rPuszDocument.inline_shapes�Iterator[Paragraph | Table]cCs
|j��S)zHGenerate each `Paragraph` or `Table` in this document in document order.)r9�iter_inner_contentrNr$r$r%rRs
zDocument.iter_inner_content�List[Paragraph]cCrL)z�The |Paragraph| instances in the document, in document order.

        Note that paragraphs within revision marks such as ``<w:ins>`` or ``<w:del>`` do
        not appear in this list.
        )r9�
paragraphsrNr$r$r%rT�szDocument.paragraphscCs|jS)z+The |DocumentPart| object of this document.)rrNr$r$r%r�sz
Document.part�path_or_streamcCs|j�|�dS)z�Save this document to `path_or_stream`.

        `path_or_stream` can be either a path to a filesystem location (a string) or a
        file-like object.
        N)r�save)r!rUr$r$r%rV�sz
Document.savercCst|j|j�S)zD|Sections| object providing access to each section in this document.)rrrrNr$r$r%�sections�szDocument.sectionsrcCrL)zDA |Settings| object providing access to the document-level settings.)r�settingsrNr$r$r%rX�rOzDocument.settingscCrL)zBA |Styles| object providing access to the styles in this document.)r�stylesrNr$r$r%rY�rOzDocument.styles�List[Table]cCrL)aPAll |Table| instances in the document, in document order.

        Note that only tables appearing at the top level of the document appear in this
        list; a table nested inside a table cell does not appear. A table within
        revision marks such as ``<w:ins>`` or ``<w:del>`` will also not appear in the
        list.
        )r9�tablesrNr$r$r%r[�s	zDocument.tablesrcCs |jd}t|j|j|j�S)zGA |Length| object specifying the space between margins in last section.���)rWr
�
page_width�left_margin�right_margin)r!�sectionr$r$r%rJ�s
zDocument._block_width�_BodycCs |jdur
t|jj|�|_|jS)z>The |_Body| instance containing the content for this document.N)r rarrBrNr$r$r%r9�s
zDocument._body)rrrr)r&r')r(r)r*r+)r&N)r(r)r0r7r8r)NN)r:r;r<r=r>r=)rArr)rFr+rGr+r0rH)r8rQ)r8rS)r8r)rUr;)r8r)r8r)r8rZ)r8r)r8ra)�__name__�
__module__�__qualname__�__doc__rr1r6r/r?r�NEW_PAGErErI�propertyrMrPrRrTrrVrWrXrYr[rJr9�
__classcell__r$r$r"r%rsD
��




	


rcs*eZdZdZd
�fdd�Zdd	�Z�ZS)razoProxy for `<w:body>` element in this document.

    It's primary role is a container for document content.
    �body_elmr�parent�t.ProvidesStoryPartcstt|��||�||_dSr)rrarr9)r!rirjr"r$r%r�s
z_Body.__init__cCs|j��|S)z�Return this |_Body| instance after clearing it of all content.

        Section properties for the main document story, if present, are preserved.
        )r9�
clear_contentrNr$r$r%rl�s
z_Body.clear_content)rirrjrk)rbrcrdrerrlrhr$r$r"r%ra�sraN)(re�
__future__r�typingrrrr�
docx.blkcntnrr�docx.enum.sectionr�docx.enum.textr	�docx.sectionr
r�docx.sharedrr
�docxr�t�docx.oxml.documentrr�docx.parts.documentr�
docx.settingsrr�docx.styles.stylerr�
docx.tabler�docx.text.paragraphrrrar$r$r$r%�<module>s('