#NEWLINE# def account_listing_response( account , req , response_content_type , broker = None , limit = '' , marker = '' , end_marker = '' , prefix = '' , delimiter = '' , reverse = False ) : #NEWLINE# #INDENT# if ( broker is None ) : #NEWLINE# #INDENT# broker = FakeAccountBroker ( ) #NEWLINE# #UNINDENT# resp_headers = get_response_headers ( broker ) #NEWLINE# account_list = broker . list_containers_iter ( limit , marker , end_marker , data , delimiter , reverse ) #NEWLINE# if ( response_content_type == 'application/json' ) : #NEWLINE# #INDENT# data = [ ] #NEWLINE# for ( name , object_count , bytes_used , is_subdir ) in account_list : #NEWLINE# #INDENT# if is_subdir : #NEWLINE# #INDENT# data . append ( { #NEWLINE# #INDENT# 'subdir' : name , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# data . append ( { #NEWLINE# #INDENT# 'name' : name , #NEWLINE# 'count' : object_count , #NEWLINE# 'bytes' : bytes_used , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# account_list = json . dumps ( data ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if response_content_type . endswith ( '/xml' ) : #NEWLINE# #INDENT# output_list = [ '<?xml version="1.0" encoding="UTF-8"?>' , ( '<account name=%s>' % saxutils . quoteattr ( account ) ) ] #NEWLINE# for ( name , object_count , bytes_used , is_subdir ) in account_list : #NEWLINE# #INDENT# if is_subdir : #NEWLINE# #INDENT# output_list . append ( ( '<subdir name=%s />' % saxutils . quoteattr ( name ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# item = ( '<container><name>%s</name><count>%s</count><bytes>%s</bytes></container>' % ( saxutils . escape ( name ) , object_count , bytes_used ) ) #NEWLINE# output_list . append ( item ) #NEWLINE# #UNINDENT# #UNINDENT# output_list . append ( '</account>' ) #NEWLINE# account_list = '\n' . join ( output_list ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not account_list ) : #NEWLINE# #INDENT# resp = HTTPNoContent ( request = req , headers = resp_headers ) #NEWLINE# resp . content_type = response_content_type #NEWLINE# resp . charset = 'utf-8' #NEWLINE# return resp #NEWLINE# #UNINDENT# account_list = ( '\n' . join ( ( r [ 0 ] for r in account_list ) ) + '\n' ) #NEWLINE# #UNINDENT# #UNINDENT# ret = HTTPOk ( body = account_list , request = req , headers = resp_headers ) #NEWLINE# ret . content_type = response_content_type #NEWLINE# ret . charset = 'utf-8' #NEWLINE# return ret