
    dh                        S r SSKJr  SSKrSSKrSSKJr  \(       a  SSKJr  \R                  " \
5      rS	S jrS
S jrSrg)zO365 tool utils.    )annotationsN)TYPE_CHECKINGAccountc                T    SSK Jn   U" [        U 5      S5      nUR                  5       n SR	                  U R                  5       5      n SR	                  U R                  5       5      n [        U 5      $ ! [         a    [        U 5      s $ f = f! [         a    [        U 5      s $ f = f)z!Clean body of a message or event.r   )BeautifulSoupzhtml.parser  )	bs4r   strget_textjoin
splitlinessplit	ExceptionImportError)bodyr   soups      a/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/tools/office365/utils.py
clean_bodyr      s    %	 TM:D==?D 774??,-D 88DJJL)Dt9 	t9	 4ys/   B A*A4 4B	B BB B'&B'c                     SSK Jn   S[        R                  ;   a>  S[        R                  ;   a*  [        R                  S   n[        R                  S   nX#4nO[
        R                  S5        gU " U5      nUR                  SL a$  UR                  / S	QS
9(       d  [        S5        gU$ U$ ! [         a  n[        S5      UeSnAff = f)z*Authenticate using the Microsoft Graph APIr   r   zGCannot import 0365. Please install the package with `pip install O365`.N	CLIENT_IDCLIENT_SECRETzError: The CLIENT_ID and CLIENT_SECRET environmental variables have not been set. Visit the following link on how to acquire these authorization tokens: https://learn.microsoft.com/en-us/graph/auth/F)z*https://graph.microsoft.com/Mail.ReadWritez%https://graph.microsoft.com/Mail.Sendz/https://graph.microsoft.com/Calendars.ReadWritez5https://graph.microsoft.com/MailboxSettings.ReadWrite)scopeszError: Could not authenticate)
O365r   r   osenvironloggererroris_authenticatedauthenticateprint)r   e	client_idclient_secretcredentialsaccounts         r   r!   r!   &   s      bjj _

%BJJ{+	

?3 0D	

 k"G5(## $ 
 12NC  U
	s   B- -
C7CCz%Y-%m-%dT%H:%M:%S%z)r   r   returnr   )r(   r   )__doc__
__future__r   loggingr   typingr   r   r   	getLogger__name__r   r   r!   
UTC_FORMAT     r   <module>r2      s?     "  	  			8	$.%P #
 &r1   