#NEWLINE# def count_usage( ) : #NEWLINE# #INDENT# 'Count personal and group file space usage.\n\n    :returns: Tuple of dicts mapping users to dicts mapping version IDs to sizes\n    ' #NEWLINE# personal = collections . defaultdict ( dict ) #NEWLINE# group = collections . defaultdict ( dict ) #NEWLINE# for node in models . Node . find ( ) : #NEWLINE# #INDENT# tree = node . get_addon ( 'osfstorage' ) . file_tree #NEWLINE# if ( not tree ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# for record in tree . children : #NEWLINE# #INDENT# for version in record . versions : #NEWLINE# #INDENT# size = ( version . size or version . metadata . get ( 'size' ) ) #NEWLINE# if ( not size ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# size = int ( size ) #NEWLINE# personal [ version . creator ] [ version . _id ] = size #NEWLINE# for user in node . contributors : #NEWLINE# #INDENT# group [ user ] [ version . _id ] = size #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return ( personal , group )