Retrieves an attachment from a note.
15212
def get_note_attachment(id)
    login! unless logged_in?
    json = <<-EOF
      {
        "session": "#{@sugar_session_id}",
        "id": "#{id}"
      }
    EOF
    json.gsub!(/^\s{6}/,'')
    send!(:get_note_attachment, json)["note_attachment"]
  end
1301971
@SuppressWarnings("unchecked")
  public <S> S getAttachment(String name) {
    return (S) attachments.get(name);
  }
1205660
def attachment(filename=nil)
      response['Content-Disposition'] = 'attachment'
      if filename
        params = '; filename="%s"' % File.basename(filename)
        response['Content-Disposition'] << params
        ext = File.extname(filename)
        content_type(ext) unless response['Content-Type'] or ext.empty?
      end
    end
313175
function( bindingPoint, res ){
    var attachment = new Attachment( res );
    bindingPoint = 0|bindingPoint;

    this.detach( bindingPoint );

    this.attachments[bindingPoint.toString()] = attachment;
    this.attachmentsList.push( attachment );

    attachment._resize( this.width, this.height );
    attachment._attach( bindingPoint );
    return attachment;
  }
238175
public Note get(long id)
	{
		SingleElementHandler<Note> noteHandler = new SingleElementHandler<>();
		try
		{
			osm.makeAuthenticatedRequest(NOTES + "/" + id, null, new NotesParser(noteHandler));
		}
		catch (OsmNotFoundException e)
		{
			return null;
		}
		return noteHandler.get();
	}
659243
def from_data(cls, type, **data):
        
        try:
            return cls._types[type](**data)
        except KeyError:
            return cls(type=type, **data)
        except TypeError as e:
            error = 'could not create {!r} attachment'.format(type)
            raise TypeError('{}: {}'.format(error, e.args[0]))
38059
def openattachment(self, attachid):
        
        attachments = self.get_attachments(None, attachid)
        data = attachments["attachments"][str(attachid)]
        xmlrpcbinary = data["data"]

        ret = BytesIO()
        ret.write(xmlrpcbinary.data)
        ret.name = data["file_name"]
        ret.seek(0)
        return ret
318386
def get_note(self, noteid):

        

        if self.standard_grant_type is not "authorization_code":
            raise DeviantartError("Authentication through Authorization Code (Grant Type) is required in order to connect to this endpoint.")

        response = self._req('/notes/{}'.format(noteid))

        return response
660030
public static String getAttachmentUrl(String applicationId, UUID callId, String attachmentName) {
        return String.format("%s%s/%s/%s", ATTACHMENT_URL_BASE, applicationId, callId.toString(), attachmentName);
    }
1129600
def _get_attachment_data(self, id, filename):
        
        uri = '/'.join([self.base_url, self.name, id, 'Attachments', filename])
        return uri, {}, 'get', None, None, False
465110
def to_email_attachment(self, filename, filedata, **kw):
        
        maintype = "application"
        subtype = "octet-stream"

        mime_type = mimetypes.guess_type(filename)[0]
        if mime_type is not None:
            maintype, subtype = mime_type.split("/")

        attachment = MIMEBase(maintype, subtype, **kw)
        attachment.set_payload(filedata)
        encoders.encode_base64(attachment)
        attachment.add_header("Content-Disposition",
                              "attachment; filename=%s" % filename)
        return attachment
1354151
def get_attachment_content(self, request, queryset):
        

        return self.dump_report_content(request, self.get_report_data_rows(request, queryset))
1039166
def note_to_int(note):
    
    if is_valid_note(note):
        val = _note_dict[note[0]]
    else:
        raise NoteFormatError("Unknown note format '%s'" % note)

    # Check for '#' and 'b' postfixes
    for post in note[1:]:
        if post == 'b':
            val -= 1
        elif post == '#':
            val += 1
    return val % 12
405625
def get_records_with_attachments(attachment_table, rel_object_field="REL_OBJECTID"):
    """"""
    if arcpyFound == False:
        raise Exception("ArcPy is required to use this function")
    OIDs = []
    with arcpy.da.SearchCursor(attachment_table,
                               [rel_object_field]) as rows:
        for row in rows:
            if not str(row[0]) in OIDs:
                OIDs.append("%s" % str(row[0]))
            del row
    del rows
    return OIDs
1069298
def update_attachment(self, volumeID, attachmentID, metadata):
        '''
        '''
        log.debug('updating metadata of attachment {} from volume {}'.format(attachmentID, volumeID))
        modifiable_fields = ['name', 'mime', 'notes', 'download_count']
        for k in metadata.keys():
            if k not in modifiable_fields:
                raise ValueError('Not modifiable field given: {}'.format(k))
        if 'name' in metadata and not isinstance(metadata['name'], basestring):
            raise ValueError("'name' must be a string")
        if 'mime' in metadata and not isinstance(metadata['mime'], basestring):
            raise ValueError("'mime' must be a string")
        if 'notes' in metadata and not isinstance(metadata['notes'], basestring):
            raise ValueError("'notes' must be a string")
        if 'download_count' in metadata and not isinstance(metadata['download_count'], Integral):
            raise ValueError("'download_count' must be a number")
        rawVolume = self._req_raw_volume(volumeID)
        for attachment in rawVolume['_source']['_attachments']:
            if attachment['id'] == attachmentID:
                attachment.update(metadata)
                self._db.modify_book(id=volumeID, body=rawVolume['_source'], version=rawVolume['_version'])
                return
        raise NotFoundException('Could not found attachment with id {} in volume {}'.format(attachmentID, volumeID))
974576
def notes(self):
        """"""
        return tuple(self._get_note_data(note) for note in self.root.iter('note'))
954412
def build_attachment(self, text, target, attachment, thread):
        '''
        '''

        attachment = {
            'as_user': True,
            'text': text,
            'channel': target,
            'attachments': [
                {
                    'fallback': text,
                    'image_url': attachment
                }
            ]
        }
        if thread:
            attachment['thread_ts'] = thread
        return attachment