
    :Qgr
                    `    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y)
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y
)
Attachmentz,A file attached to an Outlook email message.c                    || _         y )N)_storage)selfstorages     M/var/www/html/answerous/venv/lib/python3.12/site-packages/oxmsg/attachment.py__init__zAttachment.__init__!   s	        c                    | j                   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_METHODboolmAF_BY_VALUE)r   attach_methods     r   attached_by_valuezAttachment.attached_by_value$   s>     66q7J7JK(((MAMM122r   c                T    | 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1I1IJJr   c                T    | 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.HIIr   c                T    | 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/KLLr   c                \    | j                   j                  t        j                        xs 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.CDbHbbr   c                L    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     $--!BUBUVVr   c                H    | j                   rt        | j                         S dS )z#Length in bytes of this attachment.r   )r   lenr   s    r   sizezAttachment.sizeM   s     (,s4??#=A=r   N)r   z
m.StorageT)returnr   )r1   zbytes | None)r1   z
str | None)r1   zdt.datetime | None)r1   r   )r1   int)__name__
__module____qualname____doc__r   r   r   r   r#   r'   r*   r   r0    r   r   r	   r	      s    6  3 3 K K J J M M c c W W > >r   r	   )r6   
__future__r   datetimedtoxmsg.domainr   r   r   r   oxmsg.propertiesr   
oxmsg.utilr   r	   r7   r   r   <module>r>      s(   & #  ' # ' #2> 2>r   