#NEWLINE# def get_grouped_file_previews( files ) : #NEWLINE# #INDENT# groups = { #NEWLINE# #INDENT# 'all' : [ ] , #NEWLINE# #UNINDENT# } #NEWLINE# for file_info in files : #NEWLINE# #INDENT# system_file = filedict . system_file #NEWLINE# filedict = { #NEWLINE# #INDENT# 'id' : system_file . id , #NEWLINE# 'object' : system_file , #NEWLINE# 'name' : file_info . filename , #NEWLINE# 'preview' : ( json . loads ( system_file . filepreview ) if system_file . filepreview else None ) , #NEWLINE# 'url' : get_storage ( local = False ) . url ( system_file . filepath . name ) , #NEWLINE# 'slug' : ( file_info . parameter . parameter . script_param if file_info . parameter else None ) , #NEWLINE# 'basename' : os . path . basename ( system_file . filepath . name ) , #NEWLINE# 'filetype' : system_file . filetype , #NEWLINE# 'size_bytes' : system_file . size_bytes , #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# groups [ system_file . filetype ] . append ( filedict ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# groups [ system_file . filetype ] = [ filedict ] #NEWLINE# #UNINDENT# if ( system_file . filetype != 'all' ) : #NEWLINE# #INDENT# groups [ 'all' ] . append ( filedict ) #NEWLINE# #UNINDENT# #UNINDENT# return groups