#NEWLINE# @ task_filter ( protocol = 'size' ) #NEWLINE# def filter_by_size( keyword , task ) : #NEWLINE# #INDENT# '\n\tExample:\n\tlx download size:10m-\n\tlx download size:1G+\n\tlx download 0/size:1g-\n\t' #NEWLINE# m = re . match ( '^([<>])?(\\d+(?:\\.\\d+)?)([GM])?([+-])?$' , keyword , flags = re . I ) #NEWLINE# assert m , keyword #NEWLINE# ( less_or_great , n , u , less_or_more ) = m . groups ( ) #NEWLINE# assert ( bool ( less_or_great ) ^ bool ( less_or_more ) ) , 'must bt <size, >size, size-, or size+' #NEWLINE# size = ( float ( n ) * { #NEWLINE# #INDENT# None : 1 , #NEWLINE# 'G' : ( 1000 ** 3 ) , #NEWLINE# 'g' : ( 1000 ** 3 ) , #NEWLINE# 'M' : ( 1000 ** 2 ) , #NEWLINE# 'm' : ( 1000 ** 2 ) , #NEWLINE# #UNINDENT# } [ u ] ) #NEWLINE# if ( ( less_or_great == '<' ) or ( less_or_more == '-' ) ) : #NEWLINE# #INDENT# return ( task [ 'size' ] < size ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( task [ 'size' ] > size )