
    Mi                       S r SSKJr  SSKrSSKJrJr  SSKrSSKJ	r	  SSK
Jr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  \R2                  " 5       S 5       r\R7                  5       \R8                  " S\S9SS j5       5       r\R7                  5       \R8                  " S\S9SS j5       5       rSS jr SS jr!SS jr"SS jr#g)z\The command-line interface (CLI) for `python-oxmsg`.

The CLI provides the command `oxmsg`.
    )annotationsN)Iteratorcast)	OleFileIO)
Attachment)	constants)encoding_from_codepage)Message)
Properties)	Recipient)Storagec                     g)zwUtility CLI for `python-oxmsg`.

Provides the subcommands listed below, useful for exploratory or diagnostic purposes.
N r       c/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/oxmsg/cli.pyoxmsgr      s     	r   msg_file_path)typec                N   [         R                  " U 5      n[        [        U5       5        UR                   H  n[        [        U5       5        M     UR                   HB  nUR                  (       d  [        SUR                   S35        [        [        U5       5        MD     g)z7Write a summary of the MSG file's properties to stdout.zattachment z- is not embedded in message, file unavailableN)
r
   loadprintdump_message_properties
recipientsdump_recipient_propertiesattachmentsattached_by_value	file_namedump_attachment_properties)r   msgras       r   dumpr"   %   s     ,,}
%C	$S)*,^^*1-.0  __""K},YZ[+A./1 r   c                   ^ SSU4S jjjm[        U 5       n[        R                  " U5      nSSS5        [        SR	                  T" W5      5      5        g! , (       d  f       N/= f)z=Summarize low-level "directories and files" structure of MSG.c              3     >#    U U R                   =(       d    S 3v   U R                   H  nU SUR                    3v   M     U R                   H  nT" X1S-   5       S h  vN   M     g  N	7f)Nrootz    )namestreamsstorages)storageprefixstreamsiter_storage_dump_liness       r   r-   (storage.<locals>.iter_storage_dump_lines:   sg     /011ooFHD.. &!!A.q6/BBB "Bs   AA."A,#
A.N
) )r)   r   r*   strreturnIterator[str])r   r   from_oler   join)r   oleroot_storager-   s      @r   r)   r)   5   sR    
C C 
=	!S'', 
" 
$))+L9
:; 
"	!s   A
A%c                   ^ ^^^ T R                   R                  mT R                   R                  mT R                   R                  S5      nUc  SO
[	        U5      mSUU UU4S jjnSR                  U" 5       5      $ )z9A summary of this MS-OXMSG object's top-level properties.i?  Nc               3    >#    Sv   Sv   Sv   Sv   Sv   Sv   Sv   STR                   S    3v   Sv   Sv   S	v   S
TR                   3v   ST  3v   STR                   3v   STR                   3v   STR                   3v   ST 3v   T(       d  ST 3v   S[        TR                  5       3v   S[        R                  " TR                  SSS9 3v   Sv   Sv   [        TR                  5      v   g 7f)Nr0   z------------------zMessage Propertieszheader-propertiesz-----------------zrecipient_count:       distinguished-properties------------------------zattachment_count:         zinternet_code_page:       zmessage_class:            zsender:                   zsent_date:                zstring_props_are_unicode: zstring_props_encoding:    zsubject:                  zmessage_headers:
   T)indent	sort_keysother properties)_header_prop_valuesattachment_countmessage_classsender	sent_datereprsubjectjsondumpsmessage_headersdump_properties
properties)internet_encodingr   str_prop_encodingstring_props_are_unicodes   r   
iter_lines+dump_message_properties.<locals>.iter_linesP   s%    """"""!!!!$S%<%<Q%?$@AA((((*3+?+?*@AA*+<*=>>*3+<+<*=>>*3::,77*3==/::*+C*DEE'./@.ABB*4+<*=>>"4::c.A.A!W[#\"]^^  cnn--s   C<C?r/   r2   r3   )rL   rO   _str_prop_encodingint_prop_valuer	   r5   )r   internet_code_pagerP   rM   rN   rO   s   `  @@@r   r   r   G   sk    "~~FF9966v>"*0FGY0Z . .4 99Z\""r   c                @   ^  SU 4S jjnSR                  U" 5       5      $ )@Report of message properies suitable for writing to the console.c               3  0  >#    Sv   Sv   Sv   Sv   Sv   Sv   Sv   ST R                    3v   ST R                   3v   ST R                   3v   S	T R                   3v   S
T R                  S 3v   Sv   Sv   [        T R                  5      v   g 7f)Nr0   ---------------------zAttachment Propertiesr;   r<   zattached_by_value: zfile_name:         zlast_modified:     zmime_type:         zsize:              ,r@   )r   r   last_modified	mime_typesizerK   rL   )
attachments   r   rP   .dump_attachment_properties.<locals>.iter_linesp   s     %%%%%%((((#J$@$@#ABB#J$8$8#9::#J$<$<#=>>#J$8$8#9::#JOOA#677  j3344s   BBr/   rR   r5   )r^   rP   s   ` r   r   r   m   s    5" 99Z\""r   c                @   ^  SU 4S jjnSR                  U" 5       5      $ )rW   c               3     >#    Sv   Sv   Sv   Sv   Sv   Sv   Sv   S[        T R                  5       3v   ST R                   3v   Sv   Sv   [        T R                  5      v   g 7f)	Nr0   rY   zRecipient Propertiesr;   r<   zname:          zemail_address: r@   )rF   r&   email_addressrK   rL   )	recipients   r   rP   -dump_recipient_properties.<locals>.iter_lines   su     %%$$%%((((Y^^ 4566	 7 7899  i2233s   A(A+r/   rR   r`   )rd   rP   s   ` r   r   r      s    4 99Z\""r   c                @   ^  SU 4S jjnSR                  U" 5       5      $ )zCA summary of these properties suitable for printing to the console.c            	   3    >#    S SS SS 3n U v   Sv   U v   T GH  nUR                   nUR                  [        R                  [        R                  4;   aU  [        [        TR                  UR                  5      5      n[        U5      S:  a  [        U5      S S S-   O
[        U5      nOUR                  [        R                  :X  a;  UR                  [        R                  :X  a  [        U[        5      (       d   eUS S nO[        U[        5      (       a  [        U5      S S	3nOcUR                  [        R                  :X  aE  [        U[         5      (       d   eUS
-  nUS-  S-	  nUS-  S-	  nUS-  S-	  nUS SUS SUS SUS 3nSUR                  S SUR"                  S SUR$                  S SU 3v   GM     g 7f)Nz5-----------------------------------------------------+z-----------------------zF----------------------------------------------------------------------zTproperty-id                                          | type                  | value@   z...rZ   z bytes   i      i      l      ~    02X 0x04Xz - z<43z | z<21)valueptypcPTYP_STRINGPTYP_STRING8r   r1   str_prop_valuepidlenrF   PTYP_BINARYPID_HTML
isinstancebytesPTYP_INTEGER_32intr&   	ptyp_name)	head_ruleprr   b0b1b2b3selfs          r   rP   #dump_properties.<locals>.iter_lines   s    haxq1	HHAGGEvv!--88S$"5"5aee"<=47JOUCR(50e1==(QUUajj-@!%////cr
E5))u:a./1,,,!%----T\fn*h&2-j(R/c(!Bs81RHAbX>quuSkQVVCLAKK3DCwOO% s   GGr/   rR   r`   )r   rP   s   ` r   rK   rK      s    P4 99Z\""r   )r   r1   )r   r
   r2   r1   )r^   r   r2   r1   )rd   r   r2   r1   )r   r   r2   r1   )$__doc__
__future__r   rH   typingr   r   clickolefiler   oxmsg.attachmentr   oxmsg.domainr   rt   oxmsg.domain.encodingsr	   oxmsg.messager
   oxmsg.propertiesr   oxmsg.recipientr   oxmsg.storager   groupr   commandargumentr1   r"   r)   r   r   r   rK   r   r   r   <module>r      s   
 #  !   ' ' 9 ! ' % ! 	 	 c*2 + 2 c*< + < ##L#.#(#r   