U 췀g% @sVddlZddlZddlmZmZddlmZerDddlmZmZm Z GdddZ dS)N)Item PayloadRef) TYPE_CHECKING)OptionalUnionCallablec@s*eZdZdZd ddZddZdd ZdS) AttachmentaAdditional files/data to send along with an event. This class stores attachments that can be sent along with an event. Attachments are files or other data, e.g. config or log files, that are relevant to an event. Attachments are set on the ``Scope``, and are sent along with all non-transaction events (or all events including transactions if ``add_to_transactions`` is ``True``) that are captured within the ``Scope``. To add an attachment to a ``Scope``, use :py:meth:`sentry_sdk.Scope.add_attachment`. The parameters for ``add_attachment`` are the same as the parameters for this class's constructor. :param bytes: Raw bytes of the attachment, or a function that returns the raw bytes. Must be provided unless ``path`` is provided. :param filename: The filename of the attachment. Must be provided unless ``path`` is provided. :param path: Path to a file to attach. Must be provided unless ``bytes`` is provided. :param content_type: The content type of the attachment. If not provided, it will be guessed from the ``filename`` parameter, if available, or the ``path`` parameter if ``filename`` is ``None``. :param add_to_transactions: Whether to add this attachment to transactions. Defaults to ``False``. NFcCs||dkr|dkrtd|dkr4|dk r4tj|}|dkrDtd|dkrZt|d}||_||_||_||_||_ dS)Nz)path or raw bytes required for attachmentz#filename is required for attachmentr) TypeErrorospathbasename mimetypes guess_typebytesfilename content_typeadd_to_transactions)selfrrr rrrD/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/attachments.py__init__ s  zAttachment.__init__cCsJd}|jdk r*t|jr"|}q6|j}n t|jd}t|d|j|jdS)z-Returns an envelope item for this attachment.N)r attachment)payloadtyperr)rcallablerr rrr)rrrrrto_envelope_item7s    zAttachment.to_envelope_itemcCs d|jfS)Nz)r)rrrr__repr__IszAttachment.__repr__)NNNNF)__name__ __module__ __qualname____doc__rrrrrrrr s r) r r Zsentry_sdk.enveloperrtypingrrrrrrrrrs