;idZddlmZddlZddlmZmZddlm Z erddl m Z m Z ddl mZddlmZdd lmZGd d ZGd d e ZdS)z?Collection providing access to comments added to this document.) annotationsN) TYPE_CHECKINGIterator)BlockItemContainer) CT_Comment CT_Comments) CommentsPart)ParagraphStyle) Paragraphc<eZdZdZddZdd Zdd ZdddZddZdS)Commentsz:Collection containing the comments added to this document. comments_elmr comments_partr c"||_||_dSN) _comments_elm_comments_part)selfrrs AC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\docx/comments.py__init__zComments.__init__s)+returnIterator[Comment]c4fdjjDS)z.Iterator over the comments in this collection.c3BK|]}t|jVdSr)Commentr).0 comment_elmrs r z$Comments.__iter__..sD   K!4 5 5      r)r comment_lstrs`r__iter__zComments.__iter__s4    #1=    rintc4t|jjS)z*The number of comments in this collection.)lenrr r!s r__len__zComments.__len__s4%1222rtextstrauthorinitials str | Nonerc|j}||_||_tjtjj|_ t||j }|dkr|St| d}t|}|jd}|||D]} || |S)aAdd 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' rr()r add_commentr*r+dtdatetimenowtimezoneutcdaterritersplitnext paragraphsadd_run add_paragraph) rr(r*r+rcommentpara_text_iterfirst_para_text first_parass rr0zComments.add_comment#s,(4466 # ' ;??2;?;; +t':;; 2::Ndjj..//~..'* ?+++ * *A  ! !q ! ) ) ) )r comment_idComment | Nonech|j|}|t||jndS)zFReturn the comment identified by `comment_id`, or |None| if not found.N)rget_comment_by_idrr)rrBrs rgetz Comments.getMs6(:::FF .s$99A999999r)joinr:r!s rr(z Comment.texts'yy99999999rdt.datetime | Nonec|jjS)zThe date and time this comment was authored. This attribute is optional in the XML, returns |None| if not set. )rPr6r!s r timestampzComment.timestamps  %%r)rrrr )r'N)r(r)rRrSrr )rr))rZr)rG)rr,)rZr,)rrf)rHrIrJrKrr<propertyr*setterrBr+r(rh __classcell__)rQs@rrrSsN  (((((( (((X( ])))])$$$X$***X*_+++_+:::X:&&&X&&&&&rr)rK __future__rr2r1typingrr docx.blkcntnrrdocx.oxml.commentsrrdocx.parts.commentsr docx.styles.styler docx.text.paragraphr r rrLrrrssEE""""""********,,,,,,.::::::::000000000000------?^?^?^?^?^?^?^?^DP&P&P&P&P& P&P&P&P&P&r