#NEWLINE# def RenderObject( self , aff4_object , args ) : #NEWLINE# #INDENT# 'Renders RDFValueCollection as plain JSON-friendly data structure.' #NEWLINE# if args . filter : #NEWLINE# #INDENT# index = 0 #NEWLINE# items = [ ] #NEWLINE# for item in aff4_object . GenerateItems ( ) : #NEWLINE# #INDENT# serialized_item = item . SerializeToString ( ) #NEWLINE# if re . search ( re . escape ( args . filter ) , serialized_item , re . I ) : #NEWLINE# #INDENT# if ( index >= args . offset ) : #NEWLINE# #INDENT# items . append ( item ) #NEWLINE# #UNINDENT# index += 1 #NEWLINE# if ( args . count and ( len ( items ) >= args . count ) ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# items = list ( itertools . islice ( aff4_object . GenerateItems ( offset = args . offset ) , ( args . count or sys . maxint ) ) ) #NEWLINE# #UNINDENT# result = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# result [ 'offset' ] = args . offset #NEWLINE# result [ 'count' ] = len ( items ) #NEWLINE# result [ 'items' ] = [ api_value_renderers . RenderValue ( i , limit_lists = args . items_limit_lists ) for i in items ] #NEWLINE# if args . with_total_count : #NEWLINE# #INDENT# if hasattr ( aff4_object , 'CalculateLength' ) : #NEWLINE# #INDENT# total_count = aff4_object . CalculateLength ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# total_count = len ( aff4_object ) #NEWLINE# #UNINDENT# result [ 'total_count' ] = total_count #NEWLINE# #UNINDENT# return result