
    ,h                         d dl Z d dlZd dlmZ d dlmZmZmZ  ej                  e	      Z
e
j                   ej                                d Z G d de      Z G d de      Z G d	 d
e      Zy)    N)	constants)fromTimeStampmsgEpoch	properHexc                    t         j                  j                  |       d   }|t         j                  v rt	        |       S |t         j
                  vr-t        j                  dj                  t        |                   t        |       S )Nr   zUnknown property type: {})r   ST2unpackFIXED_LENGTH_PROPSFixedLengthPropVARIABLE_LENGTH_PROPSloggerwarningformatr   VariableLengthProp)stringtemps     R/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/extract_msg/prop.pycreate_propr      si    =='*Dy+++v&&y666NN6==ioNO!&))    c                        e Zd ZdZ fdZed        Zed        Zed        Zed        Z	ed        Z
ed        Zed	        Z xZS )
PropBasez(
    Base class for Prop instances.
    c                 b   t         t        |           || _        t	        |dd d         j                         | _        t        j                  j                  |      \  | _
        | _        | j                  dz  dk(  | _        | j                  dz  dk(  | _        | j                  dz  dk(  | _        y )N            )superr   __init___PropBase__rawr   upper_PropBase__namer   r   r	   _PropBase__type_PropBase__flags_PropBase__fm_PropBase__fr_PropBase__fwselfr   	__class__s     r   r   zPropBase.__init__   s    h&(
qu"u.446$-MM$8$8$@!T\LL1$)	LL1$)	LL1$)	r   c                     | j                   S )z7
        Boolean, is the "mandatory" flag set?
        )r%   r)   s    r   flagMandatoryzPropBase.flagMandatory$       
 yyr   c                     | j                   S )z6
        Boolean, is the "readable" flag set?
        )r&   r,   s    r   flagReadablezPropBase.flagReadable+   r.   r   c                     | j                   S )z6
        Boolean, is the "writable" flag set?
        )r'   r,   s    r   flagWritablezPropBase.flagWritable2   r.   r   c                     | j                   S )z7
        Integer that contains property flags.
        )r$   r,   s    r   flagszPropBase.flags9       
 ||r   c                     | j                   S )z"
        Property "name".
        )r"   r,   s    r   namezPropBase.name@       
 {{r   c                     | j                   S )z>
        Raw binary string that defined the property.
        )r    r,   s    r   rawzPropBase.rawG   s    
 zzr   c                     | j                   S )z'
        The type of property.
        )r#   r,   s    r   typezPropBase.typeN   r8   r   )__name__
__module____qualname____doc__r   propertyr-   r0   r2   r4   r7   r:   r<   __classcell__r*   s   @r   r   r      s    *              r   r   c                   8     e Zd ZdZ fdZd Zed        Z xZS )r   zj
    Class to contain the data for a single fixed length property.

    Currently a work in progress.
    c                     t         t        |   |       | j                  | j                  t
        j                  j                  |      d         | _        y )Nr   )	r   r   r   	parseTyper<   r   STFIXr	   _FixedLengthProp__valuer(   s     r   r   zFixedLengthProp.__init__]   s=    ot-f5~~dii1G1G1OPQ1RSr   c           
         |}|dk(  r	 |S |dk(  r|dk7  rt         j                  d       d}|S |dk(  r$t        j                  j	                  |      d   }|S |dk(  r$t        j
                  j	                  |      d   }|S |dk(  r$t        j                  j	                  |      d   }|S |d	k(  r$t        j                  j	                  |      d   }|S |d
k(  r't        j                  j	                  |      d   dz  }|S |dk(  rIt        j                  j	                  |      d   }t        j                  t        j                  |      z   S |dk(  r%t        j
                  j	                  |      d   }	 |S |dk(  r-t        t        j                  j	                  |      d         }|S |dk(  r$t        j                  j	                  |      d   }|S |dk(  r7	 t        t        t        j                  j	                  |      d               }|S |dk(  r	 |S # t         $ r}t         j#                  |       t         j%                  dj'                  t        t        j                  j	                  |      d                      t         j%                  | j(                         t        j                  j	                  |      d   }Y d}~|S d}~ww xY w)z
        Converts the data in :param stream: to a
        much more accurate type, specified by
        :param _type:, if possible.
        :param stream: #TODO what is stream for?

        WARNING: Not done.
        r   r   s           z1Property type is PtypNull, but is not equal to 0.Nr   r   r         g     @   )days
         @   zrTimestamp value of {} caused an exception. This was probably caused by the time stamp being too far in the future.H   )r   r   r   STI16r	   STI32STF32STF64STI64PYTPFLOATINGTIME_STARTdatetime	timedeltaboolST3r   r   	Exception	exceptionerrorr   r:   )r)   _typestreamvaluees        r   rF   zFixedLengthProp.parseTypea   s    F?L K f_;;RSEB A f_OO**51!4E> = f_OO**51!4E: 9 f_OO**51!4E6 5 f_OO**51!4E2 1 f___++E2A6@E. - f_OO**51!4E33h6H6HPU6VVVf_OO**51!4E   f_--e4Q78E  f_OO**51!4E  f_7%hy}}/C/CE/J1/M&NO  f_  7  #  R  Y  Y  Zb  cl  cp  cp  cw  cw  x}  c~  @  cA  ZB  C  DTXX&!,,U3A6 7s   4H 	KB#KKc                     | j                   S )z!
        Property value.
        )rH   r,   s    r   rb   zFixedLengthProp.value   r5   r   )	r=   r>   r?   r@   r   rF   rA   rb   rB   rC   s   @r   r   r   V   s(    T2h  r   r   c                   R     e Zd ZdZ fdZed        Zed        Zed        Z xZ	S )r   zJ
    Class to contain the data for a single variable length property.
    c                    t         t        |   |       t        j                  j                  |      \  | _        | _        | j                  dk(  r| j                  dz
  | _	        y | j                  dk(  r| j                  dz
  | _	        y | j                  t        j                  v r| j                  dz  | _	        y | j                  t        j                  v r| j                  dz  | _	        y | j                  t        j                  v r| j                  dz  | _	        y | j                  t        j                  v r| j                  dz  | _	        y | j                  dk(  rd | _	        y | j                  | _	        y )	N   r      r   r            )r   r   r   r   STVARr	   _VariableLengthProp__length_VariableLengthProp__reservedr<   _VariableLengthProp__realLengthMULTIPLE_2_BYTES_HEXMULTIPLE_4_BYTES_HEXMULTIPLE_8_BYTES_HEXMULTIPLE_16_BYTES_HEXr(   s     r   r   zVariableLengthProp.__init__   s    $08)2)?)?)G&t99 $ 1DYY&  $ 1DYY)888 $ 2DYY)888 $ 2DYY)888 $ 2DYY)999 $ 3DYY&  $D $Dr   c                     | j                   S )zC
        The length field of the variable length property.
        )rm   r,   s    r   lengthzVariableLengthProp.length   s    
 }}r   c                     | j                   S )zT
        The ACTUAL length of the stream that this property corresponds to.
        )ro   r,   s    r   
realLengthzVariableLengthProp.realLength   s    
    r   c                     | j                   S )zK
        The reserved flags field of the variable length property.
        )rn   r,   s    r   reservedFlagsz VariableLengthProp.reservedFlags   s    
 r   )
r=   r>   r?   r@   r   rA   ru   rw   ry   rB   rC   s   @r   r   r      sI    .(   ! !  r   r   )rY   loggingextract_msgr   extract_msg.utilsr   r   r   	getLoggerr=   r   
addHandlerNullHandlerr   objectr   r   r    r   r   <module>r      sm      ! @ @			8	$   %'%%' (*=v =@Dh DN, ,r   