<s> from awscli . customizations . s3 . utils import human_readable_to_bytes <EOL> DEFAULTS = { <EOL> '<STR_LIT>' : <NUM_LIT:8> * ( <NUM_LIT> ** <NUM_LIT:2> ) , <EOL> '<STR_LIT>' : <NUM_LIT:8> * ( <NUM_LIT> ** <NUM_LIT:2> ) , <EOL> '<STR_LIT>' : <NUM_LIT:10> , <EOL> '<STR_LIT>' : <NUM_LIT:1000> , <EOL> } <EOL> class InvalidConfigError ( Exception ) : <EOL> pass <EOL> class RuntimeConfig ( object ) : <EOL> POSITIVE_INTEGERS = [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> HUMAN_READABLE_SIZES = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> @ staticmethod <EOL> def defaults ( ) : <EOL> return DEFAULTS . copy ( ) <EOL> def build_config ( self , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> runtime_config = DEFAULTS . copy ( ) <EOL> if kwargs : <EOL> runtime_config . update ( kwargs ) <EOL> self . _convert_human_readable_sizes ( runtime_config ) <EOL> self . _validate_config ( runtime_config ) <EOL> return runtime_config <EOL> def _convert_human_readable_sizes ( self , runtime_config ) : <EOL> for attr in self . HUMAN_READABLE_SIZES : <EOL> value = runtime_config . get ( attr ) <EOL> if value is not None and not isinstance ( value , int ) : <EOL> runtime_config [ attr ] = human_readable_to_bytes ( value ) <EOL> def _validate_config ( self , runtime_config ) : <EOL> for attr in self . POSITIVE_INTEGERS : <EOL> value = runtime_config . get ( attr ) <EOL> if value is not None : <EOL> try : <EOL> runtime_config [ attr ] = int ( value ) <EOL> if not runtime_config [ attr ] > <NUM_LIT:0> : <EOL> self . _error_positive_value ( attr , value ) <EOL> except ValueError : <EOL> self . _error_positive_value ( attr , value ) <EOL> def _error_positive_value ( self , name , value ) : <EOL> raise InvalidConfigError ( <EOL> "<STR_LIT>" % ( name , value ) ) </s>
