
    Mi                        S r SSKJr  SSKrSSKJrJr  SSKJ	r	  SSK
JrJrJr  SSKJr  \R                    " S S	5      5       r\R                    " S
 S5      5       rg)aF  A "folder" in Microsoft Compound File Binary (CFB) format.

The CFB/OLE file format encloses a filesystem, to a first appoximation, much like a Zip
archive does. In this format, a "storage" corresponds to a directory and a "stream"
corresponds to a file. A storage can contain both streams and other storages.

Each MSG file has a "root" storage, represented in this package by `MessageStorage`.
Each attachment and recipient has their own storage in the root, with a pre-defined
name, and there are other top-level objects than can appear in a MSG file that get their
own storage.
    )annotationsN)IteratorMapping)	OleFileIO)STGTY_STORAGESTGTY_STREAMOleDirectoryEntry)lazypropertyc                      \ rS rSr% SrS\S'   S\S'   S\S'   SS	 jr\ S       SS jj5       rSS jr	SS jr
\SS j5       r\SS j5       rSS jr\SS j5       rSrg
)Storage   z'Container for streams and sub-storages.strpathztuple[Stream, ...]streamsztuple[Storage, ...]storagesc                    S[        U R                  5       S[        U R                  5       S[        U R                  5       S3$ )NzStorage(path=, z
 streams, z
 storages))reprr   lenr   r   selfs    g/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/oxmsg/storage.py__repr__Storage.__repr__    sC    DO,Bs4<</@.A BDMM"#:/	
    Nc                   ^ ^^ U(       a  UOTR                   nSS jn[        U" TUT5      5      n[        U UU4S jUR                   5       5      nT " TXVS9$ )zPReturn a Storage loaded from `node` and containing its streams and sub-storages.c              3    #    S UR                    5        H_  nU(       a  U SUR                   3OUR                  nU R                  U5       nUR                  5       nSSS5        [	        UW5      v   Ma     g! , (       d  f       N!= f7f)z4Generate `Stream` object for each stream in `nodes`.c              3  P   #    U  H  oR                   [        :X  d  M  Uv   M     g 7f)N)
entry_typer   ).0ks     r   	<genexpr>:Storage.from_ole.<locals>._iter_streams.<locals>.<genexpr>0   s     U9a8T9s   &	&/N)kidsname
openstreamreadStream)olenodeprefixstream_noder   fbytes_s          r   _iter_streams'Storage.from_ole.<locals>._iter_streams.   sk     U499U9?&;#3#3"45[EUEU^^D)QVVXF *T6**	  V))s   ABA:B:
B	Bc              3     >#    U  HP  nUR                   [        :X  d  M  TR                  TUT(       a  T S UR                   3OUR                  5      v   MR     g7f)r$   N)r   r   from_oler&   )r    r!   clsr*   r,   s     r   r"   #Storage.from_ole.<locals>.<genexpr>7   sN      
||}, MCLLaF81QVVH!5QVVLLs
   A<A)r   r   r   )r*   r   r+   r	   r,   r   returnzIterator[Stream])roottupler%   )r4   r*   r+   r,   r0   r   sub_storagess   `` `   r   r3   Storage.from_ole&   sV     t	+ c489 
YY
 

 GGr   c              #  ~   #    U R                    H)  nUR                  R                  S5      (       d  M%  Uv   M+     g7f)zDGenerate storage object specific to each attachment in this message.z__attach_version1.0_#Nr   r&   
startswithr   ss     r   iter_attachment_storages Storage.iter_attachment_storages>   s.     Avv  !899    .=	=c              #  ~   #    U R                    H)  nUR                  R                  S5      (       d  M%  Uv   M+     g7f)zBGenerate storage object specific to each recipent in this message.z__recip_version1.0_#Nr<   r>   s     r   iter_recipient_storagesStorage.iter_recipient_storagesD   s.     Avv  !788 rB   c                >    U R                   R                  S5      S   $ )z:The "directory-name" of this storage, with no path-prefix.r$   r   splitr   s    r   r&   Storage.nameJ        yys#B''r   c                4    U R                   S   R                  $ )zDThe bytes of the one-and-only-one properties stream in this storage.z__properties_version1.0_streams_by_namer/   r   s    r   properties_stream_bytesStorage.properties_stream_bytesO   s     $$%>?FFFr   c                B    U R                   SUS US 3   R                  $ )zCRead variable-length property bytes from the stream it's stored in.z__substg1.0_04XrM   )r   pidptyps      r   property_stream_bytesStorage.property_stream_bytesU   s*    
 $$|C9T#J%GHOOOr   c                Z    U R                    Vs0 s H  oR                  U_M     sn$ s  snf )z*dict semantics on streams of this storage.)r   r&   r>   s     r   rN   Storage._streams_by_name\   s&     $(<<0<a	<000s   ( r6   r   )N )r*   r   r+   zOleDirectoryEntry | Noner,   r   r6   r   )r6   zIterator[Storage])r6   bytes)rS   intrT   r]   r6   r\   )r6   zMapping[str, Stream])__name__
__module____qualname____firstlineno____doc____annotations__r   classmethodr3   r@   rD   r
   r&   rO   rU   rN   __static_attributes__rY   r   r   r   r      s    1
I!!
 RTHH#;HLOH	H H. ( ( G G
P 1 1r   r   c                  L    \ rS rSr% SrS\S'   S\S'   SS jr\SS j5       rS	r	g
)r)   b   z;Bytes of a property of a top-level object in an OXMSG file.r   r   r\   r/   c                b    S[        U R                  5       S[        U R                  5      S S3$ )NzStream(path=r   ,z bytes))r   r   r   r/   r   s    r   r   Stream.__repr__i   s,    d499o.bT[[1A!0DGLLr   c                >    U R                   R                  S5      S   $ )z3The "filename" of this stream, with no path-prefix.r$   rG   rH   r   s    r   r&   Stream.namel   rK   r   rY   NrZ   )
r^   r_   r`   ra   rb   rc   r   r
   r&   re   rY   r   r   r)   r)   b   s)    E
IMM ( (r   r)   )rb   
__future__r   dataclassesdctypingr   r   olefiler   olefile.olefiler   r   r	   
oxmsg.utilr
   	dataclassr   r)   rY   r   r   <module>ru      s_   
 #  $  J J # F1 F1 F1R ( ( (r   