
    hi                        d Z ddlmZ ddlZddlmZmZ ddlm	Z	 erddl
mZmZ ddlmZ ddlmZ dd	lmZ  G d
 d          Z G d de	          ZdS )z?Collection providing access to comments added to this document.    )annotationsN)TYPE_CHECKINGIterator)BlockItemContainer)
CT_CommentCT_Comments)CommentsPart)ParagraphStyle)	Paragraphc                  <    e Zd ZdZddZdd	ZddZdddZddZdS )Commentsz:Collection containing the comments added to this document.comments_elmr   comments_partr	   c                "    || _         || _        d S N)_comments_elm_comments_part)selfr   r   s      e/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/docx/comments.py__init__zComments.__init__   s    )+    returnIterator[Comment]c                4      fd j         j        D             S )z.Iterator over the comments in this collection.c              3  B   K   | ]}t          |j                  V  d S r   )Commentr   ).0comment_elmr   s     r   	<genexpr>z$Comments.__iter__.<locals>.<genexpr>   sD       
 
 K!455
 
 
 
 
 
r   )r   comment_lstr   s   `r   __iter__zComments.__iter__   s4    
 
 
 
#1=
 
 
 	
r   intc                4    t          | j        j                  S )z*The number of comments in this collection.)lenr   r    r!   s    r   __len__zComments.__len__   s    4%1222r    textstrauthorinitials
str | Noner   c                   | j                                         }||_        ||_        t          j                            t          j        j                  |_	        t          || j                  }|dk    r|S t          |                    d                    }t          |          }|j        d         }|                    |           |D ]}	|                    |	           |S )a  Add a new comment to the document and return it.

        The comment is added to the end of the comments collection and is assigned a unique
        comment-id.

        If `text` is provided, it is added to the comment. This option provides for the common
        case where a comment contains a modest passage of plain text. Multiple paragraphs can be
        added using the `text` argument by separating their text with newlines (`"\\n"`).
        Between newlines, text is interpreted as it is in `Document.add_paragraph(text=...)`.

        The default is to place a single empty paragraph in the comment, which is the same
        behavior as the Word UI when you add a comment. New runs can be added to the first
        paragraph in the empty comment with `comments.paragraphs[0].add_run()` to adding more
        complex text with emphasis or images. Additional paragraphs can be added using
        `.add_paragraph()`.

        `author` is a required attribute, set to the empty string by default.

        `initials` is an optional attribute, set to the empty string by default. Passing |None|
        for the `initials` parameter causes that attribute to be omitted from the XML.
        r'   
r   r(   )r   add_commentr*   r+   dtdatetimenowtimezoneutcdater   r   itersplitnext
paragraphsadd_runadd_paragraph)
r   r(   r*   r+   r   commentpara_text_iterfirst_para_text
first_parass
             r   r0   zComments.add_comment#   s    , (4466#';??2;?;;+t':;;2::Ndjj..//~..'*
?+++ 	* 	*A!!q!))))r   
comment_idComment | Nonec                h    | j                             |          }|t          || j                  ndS )zFReturn the comment identified by `comment_id`, or |None| if not found.N)r   get_comment_by_idr   r   )r   rB   r   s      r   getzComments.getM   s6    (:::FF<G<Sw{D$7888Y]]r   N)r   r   r   r	   )r   r   r   r#   )r'   r'   r'   )r(   r)   r*   r)   r+   r,   r   r   )rB   r#   r   rC   )	__name__
__module____qualname____doc__r   r"   r&   r0   rF    r   r   r   r      s        DD, , , ,
 
 
 
3 3 3 3( ( ( ( (T^ ^ ^ ^ ^ ^r   r   c                       e Zd ZdZd fdZdd fdZedd            Zej        dd            Zed d            Z	ed!d            Z
e
j        d"d            Z
edd            Zed#d            Z xZS )$r   as  Proxy for a single comment in the document.

    Provides methods to access comment metadata such as author, initials, and date.

    A comment is also a block-item container, similar to a table cell, so it can contain both
    paragraphs and tables and its paragraphs can contain rich text, hyperlinks and images,
    although the common case is that a comment contains a single paragraph of plain text like a
    sentence or phrase.

    Note that certain content like tables may not be displayed in the Word comment sidebar due to
    space limitations. Such "over-sized" content can still be viewed in the review pane.
    r   r   r   r	   c                Z    t                                          ||           || _        d S r   )superr   _comment_elm)r   r   r   	__class__s      r   r   zComment.__init__a   s+    m444'r   r'   Nr(   r)   stylestr | ParagraphStyle | Noner   r   c                h    t                                          ||          }|d|j        _        |S )aA  Return paragraph newly added to the end of the content in this container.

        The paragraph has `text` in a single run if present, and is given paragraph style `style`.
        When `style` is |None| or ommitted, the "CommentText" paragraph style is applied, which is
        the default style for comments.
        NCommentText)rO   r<   _prR   )r   r(   rR   	paragraphrQ   s       r   r<   zComment.add_paragraphe   s5     GG))$66	 =!.ILr   c                    | j         j        S )z}Read/write. The recorded author of this comment.

        This field is required but can be set to the empty string.
        rP   r*   r!   s    r   r*   zComment.authoru   s      ''r   valuec                    || j         _        d S r   rY   r   rZ   s     r   r*   zComment.author}   s    #(   r   r#   c                    | j         j        S )z&The unique identifier of this comment.)rP   idr!   s    r   rB   zComment.comment_id   s      ##r   r,   c                    | j         j        S )zRead/write. The recorded initials of the comment author.

        This attribute is optional in the XML, returns |None| if not set. Assigning |None| removes
        any existing initials from the XML.
        rP   r+   r!   s    r   r+   zComment.initials   s      ))r   c                    || j         _        d S r   r`   r\   s     r   r+   zComment.initials   s    %*"""r   c                J    d                     d | j        D                       S )zThe text content of this comment as a string.

        Only content in paragraphs is included and of course all emphasis and styling is stripped.

        Paragraph boundaries are indicated with a newline (`"\\n"`)
        r.   c              3  $   K   | ]}|j         V  d S r   r/   )r   ps     r   r   zComment.text.<locals>.<genexpr>   s$      99A999999r   )joinr:   r!   s    r   r(   zComment.text   s'     yy99999999r   dt.datetime | Nonec                    | j         j        S )zThe date and time this comment was authored.

        This attribute is optional in the XML, returns |None| if not set.
        )rP   r6   r!   s    r   	timestampzComment.timestamp   s      %%r   )r   r   r   r	   )r'   N)r(   r)   rR   rS   r   r   )r   r)   )rZ   r)   rG   )r   r,   )rZ   r,   )r   rf   )rH   rI   rJ   rK   r   r<   propertyr*   setterrB   r+   r(   rh   __classcell__)rQ   s   @r   r   r   S   sN        ( ( ( ( ( (        ( ( ( X( ]) ) ) ]) $ $ $ X$ * * * X* _+ + + _+ : : : X: & & & X& & & & &r   r   )rK   
__future__r   r2   r1   typingr   r   docx.blkcntnrr   docx.oxml.commentsr   r   docx.parts.commentsr	   docx.styles.styler
   docx.text.paragraphr   r   r   rL   r   r   <module>rs      s   E E " " " " " "     * * * * * * * * , , , , , , .::::::::000000000000------?^ ?^ ?^ ?^ ?^ ?^ ?^ ?^DP& P& P& P& P&  P& P& P& P& P&r   