
    ,hS&                        d dl Z d dlZd dlZd dlZd dlmZ d dlmZmZm	Z	m
Z
  ej                  e      Zej                   ej                                 G d de      Z G d de      Z G d d	e      Z G d
 de      Zy)    N)	constants)bytesToGuiddivide	properHexroundUpc                        e Zd ZdZ fdZddZddZd Zd Zd Z	d Z
d	 Zed
        Zed        Zed        Z xZS )Namedz__nameid_version1.0c           
      8   t         t        |           || _        | j	                  d      }| j	                  d      }| j	                  d      }|| j	                  dd      n|}|| j	                  dd      n|}|| j	                  dd      n|}|| _        || _        || _        t        |      }t        |      }t        |      }t        d t        j                  t        j                  gt        |d      D cg c]  }t        |       c}z         }	g }
t        |d      D ]V  }t        j                  j!                  |      }|d   |d   |d	   d	z	  |d	   d	z  d
}|	|d      |d<   |
j#                  |       X i }d}||k  r_t        j$                  j!                  |||dz          d   }|dz  }||||z    j'                  d      ||dz
  <   |t)        |d      z  }||k  r_|
| _        || _        |	| _        g | _        |
D ]  }t3        d|d   z         }|j5                  ||d   |d   t        j6                  k(  r||d      nd        |j9                  |      sZ| j0                  j#                  |d   t        j6                  k(  r"t;        |||d      |j=                  |            nt?        ||j=                  |                    i | _         | j0                  D ]7  }|| j@                  tC        |t:              r|jD                  n|jF                  <   9 y c c}w )Nz__substg1.0_00020102z__substg1.0_00030102z__substg1.0_00040102F      r         )idpid
guid_indexpkindr   guid   	utf_16_le   r   r   r   )$superr	   __init___Named__msg
_getStreamguid_streamentry_streamnames_streamlentupler   GUID_PS_MAPIGUID_PS_PUBLIC_STRINGSr   r   STNP_ENTunpackappendSTNP_NAMdecoder   entries_Named__names_Named__guids_Named__propertiesr   _registerNamedPropertySTRING_NAMEDExistsTypedPropertyStringNamedProperty_getTypedDataNumericalNamedProperty_Named__propertiesDict
isinstancename
propertyID)selfmsgr   r   r   guid_stream_lengthentry_stream_lengthnames_stream_lengthxguidsr'   tmpentrynamesposname_lengthstreamIDproperty	__class__s                     S/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/extract_msg/named.pyr   zNamed.__init__   s   eT#%
oo&<='=>'=>HSH[doo&<eDalIUI]t'=uEcoIUI]t'=uEco&(( -!,/!,/tY33Y5U5UVrx  zE  GI  sJ  ZKmnZefgZh  ZK  K  La( 		"A$$++A.C!f1v!!fkQ!	E "%"56E&MNN5!		" ''#,,33LSU4KLQOK1HC)#c+o>EEkRE#'N7;**C	 ''  	bE %,!67H&&ueGnTYZaTbfof|f|T|eE$K>P  CG  H&&x0!!((x}  F  yG  KT  Ka  Ka  ya)<UE%PT+DVX[XiXijrXs)t  g}  ~C  EH  EV  EV  W_  E`  ga  b		b
 !#)) 	BH zBD!!:hH[3\(--bjbubuv	BC ZKs   9L
c                 T    | j                   j                  | j                  |g|      S )Nprefix)r   r   _Named__dirr5   filenamerG   s      rD   r   zNamed._getStreamD   s%    zz$$djj(%;f$MM    c                 T    | j                   j                  | j                  |g|      S )a!  
        Gets a string representation of the requested filename.
        Checks for both ASCII and Unicode representations and returns
        a value if possible.  If there are both ASCII and Unicode
        versions, then :param prefer: specifies which will be
        returned.
        rF   )r   _getStringStreamrH   rI   s      rD   rM   zNamed._getStringStreamG   s'     zz**DJJ+AF*SSrK   c                     	 | j                   |   S # t        $ rX |j                         }| j                   j                         D ](  }||j                         k(  s| j                   |   c cY S  Y yw xY w)z]
        Tries to get a named property based on its name. Returns None if not found.
        N)namedPropertiesKeyErrorupperkeys)r5   propertyNamekeys      rD   getNamedzNamed.getNamedQ   sw    	''55 	'--/L++002 5399;.//445 	s    A	A2A2.A21A2c                 D    | j                  |      }||j                  S dS )zr
        Tries to get a the value of a named property based on its name. Returns None if it is not found.
        N)rU   data)r5   rS   props      rD   getNamedValuezNamed.getNamedValue^   s&     }}\* ,tyy6$6rK   c                 P    | j                   j                  | j                  |g      S )zM
        Checks if stream exists inside the named properties folder.
        )r   ExistsrH   r5   rJ   s     rD   r[   zNamed.Existse   s"     zz  $**h!788rK   c                 P    | j                   j                  | j                  |g      S )zX
        Checks if the string stream exists inside the named properties folder.
        )r   sExistsrH   r\   s     rD   r^   zNamed.sExistsk   s"     zz!!4::x"899rK   c                     t        j                   t        t        | j                  j	                                            y)zD
        Uses the pprint function on a sorted list of keys.
        N)pprintsortedr   r1   rR   r5   s    rD   
pprintKeyszNamed.pprintKeysq   s)     	fU4#8#8#=#=#?@ABrK   c                     | j                   S )zc
        Returns the directory inside the msg file where the named properties are located.
        )rH   rb   s    rD   dirz	Named.dirw       
 zzrK   c                     | j                   S )zI
        Returns the Message instance the attachment belongs to.
        )r   rb   s    rD   r6   z	Named.msg~   rf   rK   c                 @    t        j                  | j                        S zW
        Returns a copy of the dictionary containing all the named properties.
        )copydeepcopyr1   rb   s    rD   rO   zNamed.namedProperties       
 }}T2233rK   )T)__name__
__module____qualname__rH   r   r   rM   rU   rY   r[   r^   rc   rB   re   r6   rO   __classcell__rC   s   @rD   r	   r	      sq    !E2BhNT79:C     4 4rK   r	   c                   >    e Zd ZdZd ZddZed        Zed        Zy)NamedAttachmentPropertieszE
    The named properties associated with a specific attachment.
    c                 .    || _         g | _        i | _        y N)&_NamedAttachmentProperties__attachment&_NamedAttachmentProperties__properties*_NamedAttachmentProperties__propertiesDict)r5   
attachments     rD   r   z"NamedAttachmentProperties.__init__   s    & "rK   Nc                    t        d|d   z         j                         }| j                  j                  |      d   r| j                  j	                  |      }|t
        j                  k(  rt        |||      nt        ||      }| j                  j                  |       || j                  t        |t              r|j                  n|j                  <   yy)zP
        Informs the class of a named property that needs to be loaded.
        r   r   r   N)r   rQ   rv   r-   r/   r   r,   r.   r0   rw   r$   rx   r2   r3   r4   )r5   r=   _typer3   rA   rW   rB   s          rD   definePropertyz(NamedAttachmentProperties.defineProperty   s     VeEl2399;00:1=$$228<DAF)J`J`A`*5$=f|  ~C  EI  gJH$$X. zBD!!:hH[3\(--bjbubuv	 >rK   c                     | j                   S )za
        The attachment that this NamedAttachmentProperties instance is associated with.
        )rv   rb   s    rD   ry   z$NamedAttachmentProperties.attachment       
    rK   c                 @    t        j                  | j                        S ri   )rj   rk   rx   rb   s    rD   rO   z)NamedAttachmentProperties.namedProperties   rl   rK   ru   )	rm   rn   ro   __doc__r   r|   rB   ry   rO    rK   rD   rs   rs      s:    #
	B ! ! 4 4rK   rs   c                   ~     e Zd Z fdZed        Zed        Zed        Zed        Zed        Z	ed        Z
 xZS )r.   c                 0   t         t        |           || _        || _        |d   | _        |d   | _        |d   | _        dt        j                  |j                         j                  d            | j
                  dz  dz  z  dz  z   | _        || _        y )Nr   r   r      z	utf-16-ler      )r   r.   r   _StringNamedProperty__entry_StringNamedProperty__name_StringNamedProperty__guidIndex_StringNamedProperty__guid%_StringNamedProperty__namedPropertyIDzlibcrc32lowerencode_StringNamedProperty__streamID_StringNamedProperty__data)r5   r=   r3   rW   rC   s       rD   r   zStringNamedProperty.__init__   s    !413 .Fm!&u DJJtzz|/B/B;/O$PTXTdTdhiTilmTm$nrv#vvrK   c                 @    t        j                  | j                        S z+
        The data of the property.
        )rj   rk   r   rb   s    rD   rW   zStringNamedProperty.data       
 }}T[[))rK   c                     | j                   S z:
        The guid of the property's property set.
        )r   rb   s    rD   r   zStringNamedProperty.guid       
 {{rK   c                     | j                   S )z+
        The name of the property.
        )r   rb   s    rD   r3   zStringNamedProperty.name   r   rK   c                     | j                   S z(
        The named property id.
        )r   rb   s    rD   namedPropertyIDz#StringNamedProperty.namedPropertyID       
 %%%rK   c                     | j                   S zV
        Returns the streamID of the named property. This may not be accurate
        )r   rb   s    rD   rA   zStringNamedProperty.streamID       
 rK   c                 "    t         j                  S zn
        Returns the type of the named property. This will either be NUMERICAL_NAMED or STRING_NAMED.
        )r   r,   rb   s    rD   typezStringNamedProperty.type   s    
 %%%rK   )rm   rn   ro   r   rB   rW   r   r3   r   rA   r   rp   rq   s   @rD   r.   r.      s    	 * *     & &   & &rK   r.   c                   ~     e Zd Z fdZed        Zed        Zed        Zed        Zed        Z	ed        Z
 xZS )r0   c                     t         t        |           t        |d   d      j	                         | _        |d   | _        |d   | _        d|d   | j                  dz  z  dz  z   | _        || _	        y )Nr   r   r   r   r   r   r   )
r   r0   r   r   rQ   #_NumericalNamedProperty__propertyID"_NumericalNamedProperty__guidIndex(_NumericalNamedProperty__namedPropertyID!_NumericalNamedProperty__streamID_NumericalNamedProperty__data)r5   r=   rW   rC   s      rD   r   zNumericalNamedProperty.__init__   sr    $d46%eDk15;;= .!&u E$K43C3Cq3H$IT#QQrK   c                 @    t        j                  | j                        S r   )rj   rk   r   rb   s    rD   rW   zNumericalNamedProperty.data   r   rK   c                     | j                   S r   )_NumericalNamedProperty__guidrb   s    rD   r   zNumericalNamedProperty.guid   r   rK   c                     | j                   S r   )r   rb   s    rD   r   z&NumericalNamedProperty.namedPropertyID  r   rK   c                     | j                   S )z@
        The actualy property id of the named property.
        )r   rb   s    rD   r4   z!NumericalNamedProperty.propertyID  r~   rK   c                     | j                   S r   )r   rb   s    rD   rA   zNumericalNamedProperty.streamID  r   rK   c                 "    t         j                  S r   )r   NUMERICAL_NAMEDrb   s    rD   r   zNumericalNamedProperty.type  s    
 (((rK   )rm   rn   ro   r   rB   rW   r   r   r4   rA   r   rp   rq   s   @rD   r0   r0      s     * *   & & ! !   ) )rK   r0   )rj   loggingr`   r   extract_msgr   extract_msg.utilsr   r   r   r   	getLoggerrm   logger
addHandlerNullHandlerobjectr	   rs   r.   r0   r   rK   rD   <module>r      s}        ! E E 
		8	$   %'%%' (|4F |4@ 4  4H4&& 4&p1)V 1)rK   