home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_611 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  2.6 KB  |  63 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __version__ = '1.9'
  5. __all__ = [
  6.     'dump',
  7.     'dumps',
  8.     'load',
  9.     'loads',
  10.     'JSONDecoder',
  11.     'JSONEncoder']
  12. __author__ = 'Bob Ippolito <bob@redivi.com>'
  13. from decoder import JSONDecoder
  14. from encoder import JSONEncoder
  15. _default_encoder = JSONEncoder(skipkeys = False, ensure_ascii = True, check_circular = True, allow_nan = True, indent = None, separators = None, encoding = 'utf-8', default = None)
  16.  
  17. def dump(obj, fp, skipkeys = False, ensure_ascii = True, check_circular = True, allow_nan = True, cls = None, indent = None, separators = None, encoding = 'utf-8', default = None, **kw):
  18.     if skipkeys is False and ensure_ascii is True and check_circular is True and allow_nan is True and cls is None and indent is None and separators is None and encoding == 'utf-8' and default is None and not kw:
  19.         iterable = _default_encoder.iterencode(obj)
  20.     elif cls is None:
  21.         cls = JSONEncoder
  22.     
  23.     iterable = cls(skipkeys = skipkeys, ensure_ascii = ensure_ascii, check_circular = check_circular, allow_nan = allow_nan, indent = indent, separators = separators, encoding = encoding, default = default, **kw).iterencode(obj)
  24.     for chunk in iterable:
  25.         fp.write(chunk)
  26.     
  27.  
  28.  
  29. def dumps(obj, skipkeys = False, ensure_ascii = True, check_circular = True, allow_nan = True, cls = None, indent = None, separators = None, encoding = 'utf-8', default = None, **kw):
  30.     if skipkeys is False and ensure_ascii is True and check_circular is True and allow_nan is True and cls is None and indent is None and separators is None and encoding == 'utf-8' and default is None and not kw:
  31.         return _default_encoder.encode(obj)
  32.     if cls is None:
  33.         cls = JSONEncoder
  34.     
  35.     return cls(skipkeys = skipkeys, ensure_ascii = ensure_ascii, check_circular = check_circular, allow_nan = allow_nan, indent = indent, separators = separators, encoding = encoding, default = default, **kw).encode(obj)
  36.  
  37. _default_decoder = JSONDecoder(encoding = None, object_hook = None)
  38.  
  39. def load(fp, encoding = None, cls = None, object_hook = None, parse_float = None, parse_int = None, parse_constant = None, **kw):
  40.     return loads(fp.read(), encoding = encoding, cls = cls, object_hook = object_hook, parse_float = parse_float, parse_int = parse_int, parse_constant = parse_constant, **kw)
  41.  
  42.  
  43. def loads(s, encoding = None, cls = None, object_hook = None, parse_float = None, parse_int = None, parse_constant = None, **kw):
  44.     if cls is None and encoding is None and object_hook is None and parse_int is None and parse_float is None and parse_constant is None and not kw:
  45.         return _default_decoder.decode(s)
  46.     if cls is None:
  47.         cls = JSONDecoder
  48.     
  49.     if object_hook is not None:
  50.         kw['object_hook'] = object_hook
  51.     
  52.     if parse_float is not None:
  53.         kw['parse_float'] = parse_float
  54.     
  55.     if parse_int is not None:
  56.         kw['parse_int'] = parse_int
  57.     
  58.     if parse_constant is not None:
  59.         kw['parse_constant'] = parse_constant
  60.     
  61.     return cls(encoding = encoding, **kw).decode(s)
  62.  
  63.