/opt/alt/python37/lib/python3.7/site-packages/sentry_sdk
NameSizeModeActions
integrations/-0755rm
__pycache__/-0755rm
api.py48070644editdlrm
attachments.py17930644editdlrm
client.py143680644editdlrm
consts.py35840644editdlrm
debug.py11320644editdlrm
envelope.py83710644editdlrm
hub.py218610644editdlrm
py.typed00644editdlrm
scope.py159910644editdlrm
serializer.py163070644editdlrm
sessions.py78490644editdlrm
tracing.py257910644editdlrm
transport.py117520644editdlrm
utils.py268900644editdlrm
worker.py39610644editdlrm
_compat.py23590644editdlrm
_functools.py22760644editdlrm
_queue.py84030644editdlrm
_types.py12920644editdlrm
__init__.py8540644editdlrm
Edit: /opt/alt/python37/lib/python3.7/site-packages/sentry_sdk/attachments.py (1793B)
import os import mimetypes from sentry_sdk._types import MYPY from sentry_sdk.envelope import Item, PayloadRef if MYPY: from typing import Optional, Union, Callable class Attachment(object): def __init__( self, bytes=None, # type: Union[None, bytes, Callable[[], bytes]] filename=None, # type: Optional[str] path=None, # type: Optional[str] content_type=None, # type: Optional[str] add_to_transactions=False, # type: bool ): # type: (...) -> None if bytes is None and path is None: raise TypeError("path or raw bytes required for attachment") if filename is None and path is not None: filename = os.path.basename(path) if filename is None: raise TypeError("filename is required for attachment") if content_type is None: content_type = mimetypes.guess_type(filename)[0] self.bytes = bytes self.filename = filename self.path = path self.content_type = content_type self.add_to_transactions = add_to_transactions def to_envelope_item(self): # type: () -> Item """Returns an envelope item for this attachment.""" payload = None # type: Union[None, PayloadRef, bytes] if self.bytes is not None: if callable(self.bytes): payload = self.bytes() else: payload = self.bytes else: payload = PayloadRef(path=self.path) return Item( payload=payload, type="attachment", content_type=self.content_type, filename=self.filename, ) def __repr__(self): # type: () -> str return "" % (self.filename,)