<s> """<STR_LIT>""" <EOL> from cafe . engine . models . base import AutoMarshallingModel <EOL> class Unit ( ) : <EOL> def __init__ ( self , size , unit ) : <EOL> self . size = size <EOL> self . unit = unit <EOL> @ classmethod <EOL> def _dict_to_obj ( cls , unit_dict ) : <EOL> return Unit ( unit_dict . get ( '<STR_LIT>' ) , <EOL> unit_dict . get ( '<STR_LIT>' ) ) <EOL> class CellCapacity ( AutoMarshallingModel ) : <EOL> def __init__ ( self , total_mb = None , <EOL> units_by_mb = None ) : <EOL> super ( CellCapacity , self ) . __init__ ( ) <EOL> self . total_mb = total_mb <EOL> self . units = units_by_mb <EOL> @ classmethod <EOL> def _dict_to_obj ( cls , capacity_dict ) : <EOL> """<STR_LIT>""" <EOL> units = [ ] <EOL> for key , value in capacity_dict . get ( "<STR_LIT>" ) . iteritems ( ) : <EOL> units . append ( Unit . _dict_to_obj ( { '<STR_LIT>' : key , '<STR_LIT>' : value } ) ) <EOL> return CellCapacity ( capacity_dict . get ( '<STR_LIT>' ) , units ) <EOL> @ classmethod <EOL> def _xml_to_obj ( cls , capacity_element ) : <EOL> """<STR_LIT>""" <EOL> units = [ ] <EOL> for unit in capacity_element . findall ( '<STR_LIT>' ) : <EOL> units . append ( Unit . _dict_to_obj ( unit . attrib ) ) <EOL> return CellCapacity ( capacity_element . attrib . get ( '<STR_LIT>' ) , units ) </s>
