#NEWLINE# def ChangePhoto( self , media , contact_entry_or_url , content_type = None , content_length = None ) : #NEWLINE# #INDENT# 'Change the photo for the contact by uploading a new photo.\n\n    Performs a PUT against the photo edit URL to send the binary data for the\n    photo.\n\n    Args:\n      media: filename, file-like-object, or a gdata.MediaSource object to send.\n      contact_entry_or_url: ContactEntry or str If it is a ContactEntry, this\n                            method will search for an edit photo link URL and\n                            perform a PUT to the URL.\n      content_type: str (optional) the mime type for the photo data. This is\n                    necessary if media is a file or file name, but if media\n                    is a MediaSource object then the media object can contain\n                    the mime type. If media_type is set, it will override the\n                    mime type in the media object.\n      content_length: int or str (optional) Specifying the content length is\n                      only required if media is a file-like object. If media\n                      is a filename, the length is determined using \n                      os.path.getsize. If media is a MediaSource object, it is\n                      assumed that it already contains the content length.\n    ' #NEWLINE# if isinstance ( contact_entry_or_url , gdata . contacts . ContactEntry ) : #NEWLINE# #INDENT# url = contact_entry_or_url . GetPhotoEditLink ( ) . href #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# url = contact_entry_or_url #NEWLINE# #UNINDENT# if isinstance ( media , gdata . MediaSource ) : #NEWLINE# #INDENT# payload = media #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if hasattr ( media , 'read' ) : #NEWLINE# #INDENT# payload = gdata . MediaSource ( file_handle = media , content_type = content_type , content_length = content_length ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# payload = gdata . MediaSource ( content_type = content_type , content_length = content_length , file_path = media ) #NEWLINE# #UNINDENT# #UNINDENT# return self . Put ( payload , url )