<s> r"""<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> __version__ = '<STR_LIT>' <EOL> __all__ = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> ] <EOL> __author__ = '<STR_LIT>' <EOL> from decimal import Decimal <EOL> from . scanner import JSONDecodeError <EOL> from . decoder import JSONDecoder <EOL> from . encoder import JSONEncoder , JSONEncoderForHTML <EOL> def _import_OrderedDict ( ) : <EOL> import collections <EOL> try : <EOL> return collections . OrderedDict <EOL> except AttributeError : <EOL> from . import ordered_dict <EOL> return ordered_dict . OrderedDict <EOL> OrderedDict = _import_OrderedDict ( ) <EOL> def _import_c_make_encoder ( ) : <EOL> try : <EOL> from . _speedups import make_encoder <EOL> return make_encoder <EOL> except ImportError : <EOL> return None <EOL> _default_encoder = JSONEncoder ( <EOL> skipkeys = False , <EOL> ensure_ascii = True , <EOL> check_circular = True , <EOL> allow_nan = True , <EOL> indent = None , <EOL> separators = None , <EOL> encoding = '<STR_LIT:utf-8>' , <EOL> default = None , <EOL> use_decimal = True , <EOL> namedtuple_as_object = True , <EOL> tuple_as_array = True , <EOL> bigint_as_string = False , <EOL> item_sort_key = None , <EOL> for_json = False , <EOL> ignore_nan = False , <EOL> int_as_string_bitcount = None , <EOL> ) <EOL> def dump ( obj , fp , skipkeys = False , ensure_ascii = True , check_circular = True , <EOL> allow_nan = True , cls = None , indent = None , separators = None , <EOL> encoding = '<STR_LIT:utf-8>' , default = None , use_decimal = True , <EOL> namedtuple_as_object = True , tuple_as_array = True , <EOL> bigint_as_string = False , sort_keys = False , item_sort_key = None , <EOL> for_json = False , ignore_nan = False , int_as_string_bitcount = None , ** kw ) : <EOL> """<STR_LIT>""" <EOL> if ( not skipkeys and ensure_ascii and <EOL> check_circular and allow_nan and <EOL> cls is None and indent is None and separators is None and <EOL> encoding == '<STR_LIT:utf-8>' and default is None and use_decimal <EOL> and namedtuple_as_object and tuple_as_array <EOL> and not bigint_as_string and int_as_string_bitcount is None <EOL> and not item_sort_key and not for_json and not ignore_nan and not kw ) : <EOL> iterable = _default_encoder . iterencode ( obj ) <EOL> else : <EOL> if cls is None : <EOL> cls = JSONEncoder <EOL> iterable = cls ( skipkeys = skipkeys , ensure_ascii = ensure_ascii , <EOL> check_circular = check_circular , allow_nan = allow_nan , indent = indent , <EOL> separators = separators , encoding = encoding , <EOL> default = default , use_decimal = use_decimal , <EOL> namedtuple_as_object = namedtuple_as_object , <EOL> tuple_as_array = tuple_as_array , <EOL> bigint_as_string = bigint_as_string , <EOL> sort_keys = sort_keys , <EOL> item_sort_key = item_sort_key , <EOL> for_json = for_json , <EOL> ignore_nan = ignore_nan , <EOL> int_as_string_bitcount = int_as_string_bitcount , <EOL> ** kw ) . iterencode ( obj ) <EOL> for chunk in iterable : <EOL> fp . write ( chunk ) <EOL> def dumps ( obj , skipkeys = False , ensure_ascii = True , check_circular = True , <EOL> allow_nan = True , cls = None , indent = None , separators = None , <EOL> encoding = '<STR_LIT:utf-8>' , default = None , use_decimal = True , <EOL> namedtuple_as_object = True , tuple_as_array = True , <EOL> bigint_as_string = False , sort_keys = False , item_sort_key = None , <EOL> for_json = False , ignore_nan = False , int_as_string_bitcount = None , ** kw ) : <EOL> """<STR_LIT>""" <EOL> if ( <EOL> not skipkeys and ensure_ascii and <EOL> check_circular and allow_nan and <EOL> cls is None and indent is None and separators is None and <EOL> encoding == '<STR_LIT:utf-8>' and default is None and use_decimal <EOL> and namedtuple_as_object and tuple_as_array <EOL> and not bigint_as_string and int_as_string_bitcount is None <EOL> and not sort_keys and not item_sort_key and not for_json <EOL> and not ignore_nan and not kw <EOL> ) : <EOL> return _default_encoder . encode ( obj ) <EOL> if cls is None : <EOL> cls = JSONEncoder <EOL> return cls ( <EOL> skipkeys = skipkeys , ensure_ascii = ensure_ascii , <EOL> check_circular = check_circular , allow_nan = allow_nan , indent = indent , <EOL> separators = separators , encoding = encoding , default = default , <EOL> use_decimal = use_decimal , <EOL> namedtuple_as_object = namedtuple_as_object , <EOL> tuple_as_array = tuple_as_array , <EOL> bigint_as_string = bigint_as_string , <EOL> sort_keys = sort_keys , <EOL> item_sort_key = item_sort_key , <EOL> for_json = for_json , <EOL> ignore_nan = ignore_nan , <EOL> int_as_string_bitcount = int_as_string_bitcount , <EOL> ** kw ) . encode ( obj ) <EOL> _default_decoder = JSONDecoder ( encoding = None , object_hook = None , <EOL> object_pairs_hook = None ) <EOL> def load ( fp , encoding = None , cls = None , object_hook = None , parse_float = None , <EOL> parse_int = None , parse_constant = None , object_pairs_hook = None , <EOL> use_decimal = False , namedtuple_as_object = True , tuple_as_array = True , <EOL> ** kw ) : <EOL> """<STR_LIT>""" <EOL> return loads ( fp . read ( ) , <EOL> encoding = encoding , cls = cls , object_hook = object_hook , <EOL> parse_float = parse_float , parse_int = parse_int , <EOL> parse_constant = parse_constant , object_pairs_hook = object_pairs_hook , <EOL> use_decimal = use_decimal , ** kw ) <EOL> def loads ( s , encoding = None , cls = None , object_hook = None , parse_float = None , <EOL> parse_int = None , parse_constant = None , object_pairs_hook = None , <EOL> use_decimal = False , ** kw ) : <EOL> """<STR_LIT>""" <EOL> if ( cls is None and encoding is None and object_hook is None and <EOL> parse_int is None and parse_float is None and <EOL> parse_constant is None and object_pairs_hook is None <EOL> and not use_decimal and not kw ) : <EOL> return _default_decoder . decode ( s ) <EOL> if cls is None : <EOL> cls = JSONDecoder <EOL> if object_hook is not None : <EOL> kw [ '<STR_LIT>' ] = object_hook <EOL> if object_pairs_hook is not None : <EOL> kw [ '<STR_LIT>' ] = object_pairs_hook <EOL> if parse_float is not None : <EOL> kw [ '<STR_LIT>' ] = parse_float <EOL> if parse_int is not None : <EOL> kw [ '<STR_LIT>' ] = parse_int <EOL> if parse_constant is not None : <EOL> kw [ '<STR_LIT>' ] = parse_constant <EOL> if use_decimal : <EOL> if parse_float is not None : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> kw [ '<STR_LIT>' ] = Decimal <EOL> return cls ( encoding = encoding , ** kw ) . decode ( s ) <EOL> def _toggle_speedups ( enabled ) : <EOL> from . import decoder as dec <EOL> from . import encoder as enc <EOL> from . import scanner as scan <EOL> c_make_encoder = _import_c_make_encoder ( ) <EOL> if enabled : <EOL> dec . scanstring = dec . c_scanstring or dec . py_scanstring <EOL> enc . c_make_encoder = c_make_encoder <EOL> enc . encode_basestring_ascii = ( enc . c_encode_basestring_ascii or <EOL> enc . py_encode_basestring_ascii ) <EOL> scan . make_scanner = scan . c_make_scanner or scan . py_make_scanner <EOL> else : <EOL> dec . scanstring = dec . py_scanstring <EOL> enc . c_make_encoder = None <EOL> enc . encode_basestring_ascii = enc . py_encode_basestring_ascii <EOL> scan . make_scanner = scan . py_make_scanner <EOL> dec . make_scanner = scan . make_scanner <EOL> global _default_decoder <EOL> _default_decoder = JSONDecoder ( <EOL> encoding = None , <EOL> object_hook = None , <EOL> object_pairs_hook = None , <EOL> ) <EOL> global _default_encoder <EOL> _default_encoder = JSONEncoder ( <EOL> skipkeys = False , <EOL> ensure_ascii = True , <EOL> check_circular = True , <EOL> allow_nan = True , <EOL> indent = None , <EOL> separators = None , <EOL> encoding = '<STR_LIT:utf-8>' , <EOL> default = None , <EOL> ) <EOL> def simple_first ( kv ) : <EOL> """<STR_LIT>""" <EOL> return ( isinstance ( kv [ <NUM_LIT:1> ] , ( list , dict , tuple ) ) , kv [ <NUM_LIT:0> ] ) </s>
