<s> from django import template <EOL> import utils . quota_util <EOL> register = template . Library ( ) <EOL> @ register . filter ( name = '<STR_LIT>' ) <EOL> def param_group ( graph_config ) : <EOL> return '<STR_LIT:|>' . join ( [ group for group , key in graph_config ] ) <EOL> @ register . filter ( name = '<STR_LIT>' ) <EOL> def param_key ( graph_config ) : <EOL> return '<STR_LIT:|>' . join ( [ '<STR_LIT:->' . join ( ( group , key ) ) for group , key , unit in graph_config ] ) <EOL> @ register . filter ( name = '<STR_LIT>' ) <EOL> def param_multikey_for_view ( view_config ) : <EOL> return '<STR_LIT:|>' . join ( [ param_key ( graph_config ) for graph_config in view_config ] ) <EOL> @ register . filter ( name = '<STR_LIT>' ) <EOL> def param_height ( view_config ) : <EOL> graph_per_row = <NUM_LIT:3> <EOL> height_per_row = <NUM_LIT> <EOL> return ( len ( view_config ) + ( graph_per_row - <NUM_LIT:1> ) ) / graph_per_row * height_per_row <EOL> @ register . filter ( name = '<STR_LIT>' ) <EOL> def pic_width ( span ) : <EOL> return span * <NUM_LIT:100> <EOL> @ register . filter ( name = '<STR_LIT>' ) <EOL> def pic_heigth ( metrics ) : <EOL> return len ( metrics ) * <NUM_LIT:10> + <NUM_LIT> <EOL> @ register . filter ( name = '<STR_LIT>' ) <EOL> def format_bigint ( value ) : <EOL> try : <EOL> value = int ( value ) <EOL> except ( TypeError , ValueError ) : <EOL> return value <EOL> if value < <NUM_LIT> * <NUM_LIT> : <EOL> return value <EOL> K = <NUM_LIT> <EOL> formaters = ( <EOL> ( <NUM_LIT:2> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT:3> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT:5> , '<STR_LIT>' ) , <EOL> ) <EOL> for exponent , formater in formaters : <EOL> larger_num = K ** exponent <EOL> if value < larger_num * K : <EOL> return formater % ( value / float ( larger_num ) ) <EOL> @ register . filter ( name = '<STR_LIT>' ) <EOL> def is_space_quota_healthy ( total , used ) : <EOL> return utils . quota_util . is_space_quota_healthy ( total , used ) <EOL> @ register . filter ( name = '<STR_LIT>' ) <EOL> def is_name_quota_healthy ( total , used ) : <EOL> return utils . quota_util . is_name_quota_healthy ( total , used ) </s>
