<s> import six <EOL> from six . moves import filter <EOL> import json <EOL> from cropduster . resizing import Size <EOL> __all__ = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def json_default ( obj ) : <EOL> if six . callable ( getattr ( obj , '<STR_LIT>' , None ) ) : <EOL> dct = obj . __serialize__ ( ) <EOL> module = obj . __module__ <EOL> if module == '<STR_LIT>' : <EOL> module = None <EOL> if isinstance ( obj , type ) : <EOL> name = obj . __name__ <EOL> else : <EOL> name = obj . __class__ . __name__ <EOL> type_name = u'<STR_LIT:.>' . join ( filter ( None , [ module , name ] ) ) <EOL> if type_name == '<STR_LIT>' : <EOL> type_name = '<STR_LIT>' <EOL> dct . update ( { '<STR_LIT>' : type_name } ) <EOL> return dct <EOL> raise TypeError ( "<STR_LIT>" % type ( obj ) . __name__ ) <EOL> def object_hook ( dct ) : <EOL> if dct . get ( '<STR_LIT>' ) in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> return Size ( <EOL> name = dct . get ( '<STR_LIT:name>' ) , <EOL> w = dct . get ( '<STR_LIT:w>' ) , <EOL> h = dct . get ( '<STR_LIT:h>' ) , <EOL> min_w = dct . get ( '<STR_LIT>' ) , <EOL> min_h = dct . get ( '<STR_LIT>' ) , <EOL> max_w = dct . get ( '<STR_LIT>' ) , <EOL> max_h = dct . get ( '<STR_LIT>' ) , <EOL> retina = dct . get ( '<STR_LIT>' ) , <EOL> auto = dct . get ( '<STR_LIT>' ) , <EOL> required = dct . get ( '<STR_LIT>' ) ) <EOL> return dct <EOL> def dumps ( obj , * args , ** kwargs ) : <EOL> kwargs . setdefault ( '<STR_LIT:default>' , json_default ) <EOL> return json . dumps ( obj , * args , ** kwargs ) <EOL> def loads ( s , * args , ** kwargs ) : <EOL> if isinstance ( s , six . binary_type ) : <EOL> s = s . decode ( '<STR_LIT:utf-8>' ) <EOL> kwargs . setdefault ( '<STR_LIT>' , object_hook ) <EOL> return json . loads ( s , * args , ** kwargs ) </s>
