
    Ngr
                    h    d Z ddlmZ ddlZddlmZ ddlmZ	 ddl
mZ ddlmZ  G d d	          ZdS )
a  Provides access to the properties of an attachment in an Outlook MSG file.

These properies include the attached file's original file-name, its last-modified date, size, and
content-type (MIME-type).

```python
>>> from oxmsg import Message

>>> msg = Message.load("message.msg")
>>> msg.attachment_count
1
>>> attachment = msg.attachments[0]
>>> attachment.file_name
'financial-forecast.xlsx'
>>> with open(attachment.file_name, "wb") as f:
...     f.write()
```
    )annotationsN)	constants)model)
Properties)lazypropertyc                      e Zd ZdZddZedd            Zedd	            Zedd            Zedd            Z	edd            Z
edd            Zedd            ZdS )
Attachmentz,A file attached to an Outlook email message.storage
m.StorageTc                    || _         d S )N)_storage)selfr
   s     L/var/www/html/ai-engine/env/lib/python3.11/site-packages/oxmsg/attachment.py__init__zAttachment.__init__!   s        returnboolc                    | j                             t          j                  }|J t	          |t
          j        z            S )zTrue when the `PidTagAttachDataBinary` property contains the attachment data.

        This is as opposed to "by-reference" where only a path or URL is stored.
        )
propertiesint_prop_valuecPID_ATTACH_METHODr   mAF_BY_VALUE)r   attach_methods     r   attached_by_valuezAttachment.attached_by_value$   s=     66q7JKK(((MAM1222r   bytes | Nonec                J    | j                             t          j                  S )zDThe attachment binary, suitable for saving to a file when detaching.)r   binary_prop_valuer   PID_ATTACH_DATA_BINARYr   s    r   
file_byteszAttachment.file_bytes.   s     001IJJJr   
str | Nonec                J    | j                             t          j                  S )zThe full name of this file as it was originally attached.

        Like "FY24-quarterly-projections.xlsx". Does not include a path.
        )r   str_prop_valuer   PID_ATTACH_LONG_FILENAMEr!   s    r   	file_namezAttachment.file_name3   s     --a.HIIIr   dt.datetime | Nonec                J    | j                             t          j                  S )zTimezone-aware UTC datetime when this attachment was last modified.

        `None` if this property is not present on the attachment.
        )r   date_prop_valuer   PID_LAST_MODIFICATION_TIMEr!   s    r   last_modifiedzAttachment.last_modified;   s     ..q/KLLLr   c                N    | j                             t          j                  pdS )zFISO 8601 str representation of time this attachment was last modified.zapplication/octet-stream)r   r%   r   PID_ATTACH_MIME_TAGr!   s    r   	mime_typezAttachment.mime_typeC   s#     --a.CDDbHbbr   r   c                B    t          | j        t          j                  S )z7Provides access to the properties of this OXMSG object.)properties_header_offset)r   r   r   ATTACH_HDR_OFFSETr!   s    r   r   zAttachment.propertiesH   s     $-!BUVVVVr   intc                <    | j         rt          | j                   ndS )z#Length in bytes of this attachment.r   )r"   lenr!   s    r   sizezAttachment.sizeM   s      (,=s4?###A=r   N)r
   r   )r   r   )r   r   )r   r#   )r   r(   )r   r   )r   r3   )__name__
__module____qualname____doc__r   r   r   r"   r'   r,   r/   r   r6    r   r   r	   r	      s"       66        3 3 3 \3 K K K \K J J J \J M M M \M c c c \c W W W \W > > > \> > >r   r	   )r:   
__future__r   datetimedtoxmsg.domainr   r   r   r   oxmsg.propertiesr   
oxmsg.utilr   r	   r;   r   r   <module>rB      s    & # " " " " "     ' ' ' ' ' ' # # # # # # ' ' ' ' ' ' # # # # # #2> 2> 2> 2> 2> 2> 2> 2> 2> 2>r   