<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import urllib . request , urllib . parse , urllib . error <EOL> import atom <EOL> import gdata . service <EOL> import gdata . analytics <EOL> class AccountsService ( gdata . service . GDataService ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , email = "<STR_LIT>" , password = None , source = None , <EOL> server = '<STR_LIT>' , additional_headers = None , <EOL> ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> gdata . service . GDataService . __init__ ( <EOL> self , email = email , password = password , service = '<STR_LIT>' , <EOL> source = source , server = server , additional_headers = additional_headers , <EOL> ** kwargs ) <EOL> def QueryAccountListFeed ( self , uri ) : <EOL> """<STR_LIT>""" <EOL> return self . Get ( uri , converter = gdata . analytics . AccountListFeedFromString ) <EOL> def GetAccountListEntry ( self , uri ) : <EOL> """<STR_LIT>""" <EOL> return self . Get ( uri , converter = gdata . analytics . AccountListEntryFromString ) <EOL> def GetAccountList ( self , max_results = <NUM_LIT:1000> , text_query = None , <EOL> params = None , categories = None ) : <EOL> """<STR_LIT>""" <EOL> q = gdata . analytics . service . AccountQuery ( max_results = max_results , <EOL> text_query = text_query , <EOL> params = params , <EOL> categories = categories ) ; <EOL> return self . QueryAccountListFeed ( q . ToUri ( ) ) <EOL> class AnalyticsDataService ( gdata . service . GDataService ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , email = None , password = None , source = None , <EOL> server = '<STR_LIT>' , additional_headers = None , <EOL> ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> gdata . service . GDataService . __init__ ( self , <EOL> email = email , password = password , service = '<STR_LIT>' , source = source , <EOL> server = server , additional_headers = additional_headers , ** kwargs ) <EOL> def GetData ( self , ids = '<STR_LIT>' , dimensions = '<STR_LIT>' , metrics = '<STR_LIT>' , <EOL> sort = '<STR_LIT>' , filters = '<STR_LIT>' , start_date = '<STR_LIT>' , <EOL> end_date = '<STR_LIT>' , start_index = '<STR_LIT>' , <EOL> max_results = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> q = gdata . analytics . service . DataQuery ( ids = ids , <EOL> dimensions = dimensions , <EOL> metrics = metrics , <EOL> filters = filters , <EOL> sort = sort , <EOL> start_date = start_date , <EOL> end_date = end_date , <EOL> start_index = start_index , <EOL> max_results = max_results ) ; <EOL> return self . AnalyticsDataFeed ( q . ToUri ( ) ) <EOL> def AnalyticsDataFeed ( self , uri ) : <EOL> """<STR_LIT>""" <EOL> return self . Get ( uri , <EOL> converter = gdata . analytics . AnalyticsDataFeedFromString ) <EOL> """<STR_LIT>""" <EOL> def QueryAccountListFeed ( self , uri ) : <EOL> """<STR_LIT>""" <EOL> return self . Get ( uri , converter = gdata . analytics . AccountListFeedFromString ) <EOL> def GetAccountListEntry ( self , uri ) : <EOL> """<STR_LIT>""" <EOL> return self . Get ( uri , converter = gdata . analytics . AccountListEntryFromString ) <EOL> def GetAccountList ( self , username = "<STR_LIT:default>" , max_results = <NUM_LIT:1000> , <EOL> start_index = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> if not username : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> q = gdata . analytics . service . AccountQuery ( username = username , <EOL> max_results = max_results , <EOL> start_index = start_index ) ; <EOL> return self . QueryAccountListFeed ( q . ToUri ( ) ) <EOL> class DataQuery ( gdata . service . Query ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , feed = '<STR_LIT>' , text_query = None , <EOL> params = None , categories = None , ids = "<STR_LIT>" , <EOL> dimensions = "<STR_LIT>" , metrics = "<STR_LIT>" , sort = "<STR_LIT>" , filters = "<STR_LIT>" , <EOL> start_date = "<STR_LIT>" , end_date = "<STR_LIT>" , start_index = "<STR_LIT>" , <EOL> max_results = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> self . elements = { '<STR_LIT>' : ids , <EOL> '<STR_LIT>' : dimensions , <EOL> '<STR_LIT>' : metrics , <EOL> '<STR_LIT>' : sort , <EOL> '<STR_LIT>' : filters , <EOL> '<STR_LIT>' : start_date , <EOL> '<STR_LIT>' : end_date , <EOL> '<STR_LIT>' : start_index , <EOL> '<STR_LIT>' : max_results } <EOL> gdata . service . Query . __init__ ( self , feed , text_query , params , categories ) <EOL> def ToUri ( self ) : <EOL> """<STR_LIT>""" <EOL> old_feed = self . feed <EOL> self . feed = '<STR_LIT:/>' . join ( [ old_feed ] ) + '<STR_LIT:?>' + urllib . parse . urlencode ( dict ( [ ( key , value ) for key , value in self . elements . items ( ) if value ] ) ) <EOL> new_feed = gdata . service . Query . ToUri ( self ) <EOL> self . feed = old_feed <EOL> return new_feed <EOL> class AccountQuery ( gdata . service . Query ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , feed = '<STR_LIT>' , start_index = <NUM_LIT:1> , <EOL> max_results = <NUM_LIT:1000> , username = '<STR_LIT:default>' , text_query = None , <EOL> params = None , categories = None ) : <EOL> """<STR_LIT>""" <EOL> self . max_results = max_results <EOL> self . start_index = start_index <EOL> self . username = username <EOL> gdata . service . Query . __init__ ( self , feed , text_query , params , categories ) <EOL> def ToUri ( self ) : <EOL> """<STR_LIT>""" <EOL> old_feed = self . feed <EOL> self . feed = '<STR_LIT:/>' . join ( [ old_feed , self . username ] ) + '<STR_LIT:?>' + '<STR_LIT:&>' . join ( [ '<STR_LIT>' + str ( self . max_results ) , <EOL> '<STR_LIT>' + str ( self . start_index ) ] ) <EOL> new_feed = self . feed <EOL> self . feed = old_feed <EOL> return new_feed </s>
