<s> import abc <EOL> import six <EOL> @ six . add_metaclass ( abc . ABCMeta ) <EOL> class Serializable ( object ) : <EOL> @ abc . abstractmethod <EOL> def to_dict ( self ) : <EOL> pass <EOL> @ classmethod <EOL> def from_dict ( cls , data ) : <EOL> return cls ( ** data ) <EOL> class DictWrapperObject ( object ) : <EOL> def __init__ ( self , data ) : <EOL> for k , v in six . iteritems ( data ) : <EOL> if isinstance ( v , ( list , tuple ) ) : <EOL> setattr ( self , k , [ DictWrapperObject ( i ) if isinstance ( i , dict ) <EOL> else i for i in v ] ) <EOL> else : <EOL> setattr ( self , k , DictWrapperObject ( v ) if isinstance ( v , dict ) <EOL> else v ) </s>
