def __init__(self, attachment=None, *, parent=None, **kwargs):
kwargs.setdefault('<STR_LIT>', getattr(parent, '<STR_LIT>', None))<EOL>kwargs.setdefault('<STR_LIT>',<EOL>getattr(parent, '<STR_LIT>', None))<EOL>super().__init__(**kwargs)<EOL>self.name = None<EOL>self.attachment_type = '<STR_LIT:file>'<EOL>self.attachment_id = None<EOL>self.attachment = None<EOL>self.content = None<EOL>self.on_disk = False<EOL>self.on_cloud = kwargs.get('<STR_LIT>', False)<EOL>if attachment:<EOL><INDENT>if isinstance(attachment, dict):<EOL><INDENT>if self._cloud_data_key in attachment:<EOL><INDENT>attachment = attachment.get(self._cloud_data_key)<EOL>self.attachment_id = attachment.get(self._cc('<STR_LIT:id>'), None)<EOL>self.name = attachment.get(self._cc('<STR_LIT:name>'), None)<EOL>self.content = attachment.get(self._cc('<STR_LIT>'),<EOL>None)<EOL>self.attachment_type = '<STR_LIT>' if '<STR_LIT>' in attachment.get(<EOL>'<STR_LIT>', '<STR_LIT>').lower() else '<STR_LIT:file>'<EOL>self.on_disk = False<EOL><DEDENT>else:<EOL><INDENT>file_path = attachment.get('<STR_LIT:path>', attachment.get('<STR_LIT:name>'))<EOL>if file_path is None:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>self.content = attachment.get('<STR_LIT:content>')<EOL>self.on_disk = attachment.get('<STR_LIT>')<EOL>self.attachment_id = attachment.get('<STR_LIT>')<EOL>self.attachment = Path(file_path) if self.on_disk else None<EOL>self.name = (self.attachment.name if self.on_disk<EOL>else attachment.get('<STR_LIT:name>'))<EOL><DEDENT><DEDENT>elif isinstance(attachment, str):<EOL><INDENT>self.attachment = Path(attachment)<EOL>self.name = self.attachment.name<EOL><DEDENT>elif isinstance(attachment, Path):<EOL><INDENT>self.attachment = attachment<EOL>self.name = self.attachment.name<EOL><DEDENT>elif isinstance(attachment, (tuple, list)):<EOL><INDENT>file_path, custom_name = attachment<EOL>self.attachment = Path(file_path)<EOL>self.name = custom_name<EOL><DEDENT>elif isinstance(attachment, AttachableMixin):<EOL><INDENT>self.attachment_type = '<STR_LIT>'<EOL>self.attachment = attachment<EOL>self.name = attachment.attachment_name<EOL>self.content = attachment.to_api_data()<EOL>self.content['<STR_LIT>'] = attachment.attachment_type<EOL><DEDENT>if self.content is None and self.attachment andself.attachment.exists():<EOL><INDENT>with self.attachment.open('<STR_LIT:rb>') as file:<EOL><INDENT>self.content = base64.b64encode(file.read()).decode('<STR_LIT:utf-8>')<EOL><DEDENT>self.on_disk = True<EOL><DEDENT><DEDENT>
Creates a new attachment, optionally from existing cloud data

        :param attachment: attachment data (dict = cloud data,
         other = user data)
        :type attachment: dict or str or Path or list[str] or AttachableMixin
        :param BaseAttachments parent: the parent Attachments
        :param Protocol protocol: protocol to use if no parent specified
         (kwargs)
        :param str main_resource: use this resource instead of parent resource
         (kwargs)