<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> import datetime <EOL> import yaml <EOL> from yaml . constructor import ConstructorError <EOL> from yaml . scanner import ScannerError <EOL> from salt . serializers import DeserializationError , SerializationError <EOL> import salt . ext . six as six <EOL> from salt . utils . odict import OrderedDict <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> available = True <EOL> BaseLoader = getattr ( yaml , '<STR_LIT>' , yaml . SafeLoader ) <EOL> BaseDumper = getattr ( yaml , '<STR_LIT>' , yaml . SafeDumper ) <EOL> ERROR_MAP = { <EOL> ( "<STR_LIT>" <EOL> "<STR_LIT>" ) : '<STR_LIT>' <EOL> } <EOL> def deserialize ( stream_or_string , ** options ) : <EOL> '''<STR_LIT>''' <EOL> options . setdefault ( '<STR_LIT>' , BaseLoader ) <EOL> try : <EOL> return yaml . load ( stream_or_string , ** options ) <EOL> except ScannerError as error : <EOL> err_type = ERROR_MAP . get ( error . problem , '<STR_LIT>' ) <EOL> line_num = error . problem_mark . line + <NUM_LIT:1> <EOL> raise DeserializationError ( err_type , <EOL> line_num , <EOL> error . problem_mark . buffer ) <EOL> except ConstructorError as error : <EOL> raise DeserializationError ( error ) <EOL> except Exception as error : <EOL> raise DeserializationError ( error ) <EOL> def serialize ( obj , ** options ) : <EOL> '''<STR_LIT>''' <EOL> options . setdefault ( '<STR_LIT>' , Dumper ) <EOL> try : <EOL> response = yaml . dump ( obj , ** options ) <EOL> if response . endswith ( '<STR_LIT>' ) : <EOL> return response [ : - <NUM_LIT:5> ] <EOL> if response . endswith ( '<STR_LIT:\n>' ) : <EOL> return response [ : - <NUM_LIT:1> ] <EOL> return response <EOL> except Exception as error : <EOL> raise SerializationError ( error ) <EOL> class Loader ( BaseLoader ) : <EOL> '''<STR_LIT>''' <EOL> pass <EOL> Loader . add_multi_constructor ( '<STR_LIT>' , Loader . construct_yaml_null ) <EOL> Loader . add_multi_constructor ( '<STR_LIT>' , Loader . construct_yaml_bool ) <EOL> Loader . add_multi_constructor ( '<STR_LIT>' , Loader . construct_yaml_int ) <EOL> Loader . add_multi_constructor ( '<STR_LIT>' , Loader . construct_yaml_float ) <EOL> Loader . add_multi_constructor ( '<STR_LIT>' , Loader . construct_yaml_binary ) <EOL> Loader . add_multi_constructor ( '<STR_LIT>' , Loader . construct_yaml_timestamp ) <EOL> Loader . add_multi_constructor ( '<STR_LIT>' , Loader . construct_yaml_omap ) <EOL> Loader . add_multi_constructor ( '<STR_LIT>' , Loader . construct_yaml_pairs ) <EOL> Loader . add_multi_constructor ( '<STR_LIT>' , Loader . construct_yaml_set ) <EOL> Loader . add_multi_constructor ( '<STR_LIT>' , Loader . construct_yaml_str ) <EOL> Loader . add_multi_constructor ( '<STR_LIT>' , Loader . construct_yaml_seq ) <EOL> Loader . add_multi_constructor ( '<STR_LIT>' , Loader . construct_yaml_map ) <EOL> Loader . add_multi_constructor ( None , Loader . construct_undefined ) <EOL> class Dumper ( BaseDumper ) : <EOL> '''<STR_LIT>''' <EOL> pass <EOL> Dumper . add_multi_representer ( type ( None ) , Dumper . represent_none ) <EOL> Dumper . add_multi_representer ( str , Dumper . represent_str ) <EOL> if six . PY2 : <EOL> Dumper . add_multi_representer ( six . text_type , Dumper . represent_unicode ) <EOL> Dumper . add_multi_representer ( int , Dumper . represent_long ) <EOL> Dumper . add_multi_representer ( bool , Dumper . represent_bool ) <EOL> Dumper . add_multi_representer ( int , Dumper . represent_int ) <EOL> Dumper . add_multi_representer ( float , Dumper . represent_float ) <EOL> Dumper . add_multi_representer ( list , Dumper . represent_list ) <EOL> Dumper . add_multi_representer ( tuple , Dumper . represent_list ) <EOL> Dumper . add_multi_representer ( dict , Dumper . represent_dict ) <EOL> Dumper . add_multi_representer ( set , Dumper . represent_set ) <EOL> Dumper . add_multi_representer ( datetime . date , Dumper . represent_date ) <EOL> Dumper . add_multi_representer ( datetime . datetime , Dumper . represent_datetime ) <EOL> Dumper . add_multi_representer ( None , Dumper . represent_undefined ) <EOL> Dumper . add_multi_representer ( OrderedDict , Dumper . represent_dict ) </s>
