<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import gdata <EOL> import atom . service <EOL> import gdata . service <EOL> import gdata . calendar <EOL> import atom <EOL> DEFAULT_BATCH_URL = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> class Error ( Exception ) : <EOL> pass <EOL> class RequestError ( Error ) : <EOL> pass <EOL> class ContactsService ( gdata . service . GDataService ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , email = None , password = None , source = None , <EOL> server = '<STR_LIT>' , <EOL> additional_headers = None ) : <EOL> gdata . service . GDataService . __init__ ( self , email = email , password = password , <EOL> service = '<STR_LIT>' , source = source , <EOL> server = server , <EOL> additional_headers = additional_headers ) <EOL> def GetContactsFeed ( self , <EOL> uri = '<STR_LIT>' ) : <EOL> return self . Get ( uri , converter = gdata . contacts . ContactsFeedFromString ) <EOL> def GetContact ( self , uri ) : <EOL> return self . Get ( uri , converter = gdata . contacts . ContactEntryFromString ) <EOL> def CreateContact ( self , new_contact , <EOL> insert_uri = '<STR_LIT>' , url_params = None , <EOL> escape_params = True ) : <EOL> """<STR_LIT>""" <EOL> return self . Post ( new_contact , insert_uri , url_params = url_params , <EOL> escape_params = escape_params , <EOL> converter = gdata . contacts . ContactEntryFromString ) <EOL> def UpdateContact ( self , edit_uri , updated_contact , url_params = None , <EOL> escape_params = True ) : <EOL> """<STR_LIT>""" <EOL> url_prefix = '<STR_LIT>' % self . server <EOL> if edit_uri . startswith ( url_prefix ) : <EOL> edit_uri = edit_uri [ len ( url_prefix ) : ] <EOL> return self . Put ( updated_contact , '<STR_LIT>' % edit_uri , <EOL> url_params = url_params , <EOL> escape_params = escape_params , <EOL> converter = gdata . contacts . ContactEntryFromString ) <EOL> def DeleteContact ( self , edit_uri , extra_headers = None , <EOL> url_params = None , escape_params = True ) : <EOL> """<STR_LIT>""" <EOL> url_prefix = '<STR_LIT>' % self . server <EOL> if edit_uri . startswith ( url_prefix ) : <EOL> edit_uri = edit_uri [ len ( url_prefix ) : ] <EOL> return self . Delete ( '<STR_LIT>' % edit_uri , <EOL> url_params = url_params , escape_params = escape_params ) <EOL> def GetGroupsFeed ( self , <EOL> uri = '<STR_LIT>' ) : <EOL> return self . Get ( uri , converter = gdata . contacts . GroupsFeedFromString ) <EOL> def CreateGroup ( self , new_group , <EOL> insert_uri = '<STR_LIT>' , url_params = None , <EOL> escape_params = True ) : <EOL> return self . Post ( new_group , insert_uri , url_params = url_params , <EOL> escape_params = escape_params , <EOL> converter = gdata . contacts . GroupEntryFromString ) <EOL> def UpdateGroup ( self , edit_uri , updated_group , url_params = None , <EOL> escape_params = True ) : <EOL> url_prefix = '<STR_LIT>' % self . server <EOL> if edit_uri . startswith ( url_prefix ) : <EOL> edit_uri = edit_uri [ len ( url_prefix ) : ] <EOL> return self . Put ( updated_group , '<STR_LIT>' % edit_uri , <EOL> url_params = url_params , <EOL> escape_params = escape_params , <EOL> converter = gdata . contacts . GroupEntryFromString ) <EOL> def DeleteGroup ( self , edit_uri , extra_headers = None , <EOL> url_params = None , escape_params = True ) : <EOL> url_prefix = '<STR_LIT>' % self . server <EOL> if edit_uri . startswith ( url_prefix ) : <EOL> edit_uri = edit_uri [ len ( url_prefix ) : ] <EOL> return self . Delete ( '<STR_LIT>' % edit_uri , <EOL> url_params = url_params , escape_params = escape_params ) <EOL> def ChangePhoto ( self , media , contact_entry_or_url , content_type = None , <EOL> content_length = None ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( contact_entry_or_url , gdata . contacts . ContactEntry ) : <EOL> url = contact_entry_or_url . GetPhotoEditLink ( ) . href <EOL> else : <EOL> url = contact_entry_or_url <EOL> if isinstance ( media , gdata . MediaSource ) : <EOL> payload = media <EOL> elif hasattr ( media , '<STR_LIT>' ) : <EOL> payload = gdata . MediaSource ( file_handle = media , <EOL> content_type = content_type , content_length = content_length ) <EOL> else : <EOL> payload = gdata . MediaSource ( content_type = content_type , <EOL> content_length = content_length , file_path = media ) <EOL> return self . Put ( payload , url ) <EOL> def GetPhoto ( self , contact_entry_or_url ) : <EOL> """<STR_LIT>""" <EOL> url = None <EOL> if isinstance ( contact_entry_or_url , gdata . contacts . ContactEntry ) : <EOL> photo_link = contact_entry_or_url . GetPhotoLink ( ) <EOL> if photo_link : <EOL> url = photo_link . href <EOL> else : <EOL> url = contact_entry_or_url <EOL> if url : <EOL> return self . Get ( url , converter = str ) <EOL> else : <EOL> return None <EOL> def DeletePhoto ( self , contact_entry_or_url ) : <EOL> url = None <EOL> if isinstance ( contact_entry_or_url , gdata . contacts . ContactEntry ) : <EOL> url = contact_entry_or_url . GetPhotoEditLink ( ) . href <EOL> else : <EOL> url = contact_entry_or_url <EOL> if url : <EOL> self . Delete ( url ) <EOL> def ExecuteBatch ( self , batch_feed , url , <EOL> converter = gdata . contacts . ContactsFeedFromString ) : <EOL> """<STR_LIT>""" <EOL> return self . Post ( batch_feed , url , converter = converter ) <EOL> class ContactsQuery ( gdata . service . Query ) : <EOL> def __init__ ( self , feed = None , text_query = None , params = None , <EOL> categories = None , group = None ) : <EOL> self . feed = feed or '<STR_LIT>' <EOL> if group : <EOL> self . _SetGroup ( group ) <EOL> gdata . service . Query . __init__ ( self , feed = self . feed , text_query = text_query , <EOL> params = params , categories = categories ) <EOL> def _GetGroup ( self ) : <EOL> if '<STR_LIT>' in self : <EOL> return self [ '<STR_LIT>' ] <EOL> else : <EOL> return None <EOL> def _SetGroup ( self , group_id ) : <EOL> self [ '<STR_LIT>' ] = group_id <EOL> group = property ( _GetGroup , _SetGroup , <EOL> doc = '<STR_LIT>' ) <EOL> class GroupsQuery ( gdata . service . Query ) : <EOL> def __init__ ( self , feed = None , text_query = None , params = None , <EOL> categories = None ) : <EOL> self . feed = feed or '<STR_LIT>' <EOL> gdata . service . Query . __init__ ( self , feed = self . feed , text_query = text_query , <EOL> params = params , categories = categories ) </s>
