Module Expr Str Import alias Import alias Import alias Import alias Assign NameStore NameLoad TryExcept body Import alias handlers ExceptHandler type NameLoad body TryExcept body Import alias identifier handlers ExceptHandler type NameLoad body Assign NameStore NameLoad Import alias identifier ImportFrom alias alias alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias alias alias Assign NameStore Dict Str Str Str Str Str Str AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr FunctionDef arguments args NameParam defaults vararg kwarg body Expr Str If UnaryOpNot NameLoad body Raise Call NameLoad Str Return Call AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults vararg kwarg body Expr Str If UnaryOpNot NameLoad body Raise Call NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr Str NameLoad Assign SubscriptStore NameLoad Index Str Lambda arguments args NameParam defaults Call NameLoad NameLoad NameLoad Return Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str ImportFrom alias If BoolOpOr Call NameLoad NameLoad Str Call NameLoad NameLoad Str body Return Call NameLoad GeneratorExp TupleLoad NameLoad Call NameLoad NameLoad comprehension TupleStore NameStore NameStore Call AttributeLoad NameLoad attr orelse If BoolOpAnd Call NameLoad NameLoad Str UnaryOpNot Call NameLoad NameLoad NameLoad UnaryOpNot Call NameLoad NameLoad NameLoad body Return Call NameLoad GeneratorExp Call NameLoad NameLoad comprehension NameStore NameLoad TryExcept body Return Call NameLoad NameLoad handlers ExceptHandler type NameLoad body Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body If CompareIn Str NameLoad body Return Call NameLoad Call NameLoad SubscriptLoad NameLoad Index Str If CompareIn Str NameLoad body Return Call NameLoad SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str Call AttributeLoad NameLoad attr Str NameLoad If CompareIn Str NameLoad body Assign NameStore BinOpDiv Call NameLoad SubscriptLoad NameLoad Index Str Num Return BinOpAdd NameLoad Call AttributeLoad NameLoad attr keyword NameLoad If CompareIn Str NameLoad body Assign NameStore Num For NameStore Call AttributeLoad NameLoad attr Str Str body AugAssignBitOr NameStore Call AttributeLoad NameLoad attr NameLoad Num If NameLoad body Return Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str NameLoad orelse Return Call NameLoad SubscriptLoad NameLoad Index Str NameLoad If CompareIn Str NameLoad body Return Call NameLoad If CompareIn Str NameLoad body Return Call NameLoad If CompareIn Str NameLoad body If Call NameLoad SubscriptLoad NameLoad Index Str NameLoad body Assign SubscriptStore NameLoad Index Str BinOpMod Str SubscriptLoad NameLoad Index Str Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Str Num If CompareGtE NameLoad Num body Assign NameStore Call NameLoad SubscriptLoad SubscriptLoad NameLoad Index Str Slice Num Num Return Call NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad SubscriptLoad NameLoad Index Str attr NameLoad If CompareIn Str NameLoad body Return Call NameLoad SubscriptLoad NameLoad Index Str Call AttributeLoad NameLoad attr Str If BoolOpAnd Call AttributeLoad NameLoad attr CompareIn Str NameLoad body Return Call AttributeLoad AttributeLoad NameLoad attr attr SubscriptLoad NameLoad Index Str Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body If Call NameLoad NameLoad NameLoad body Return Dict Str Call NameLoad NameLoad If Call NameLoad NameLoad NameLoad body Return Call NameLoad Call AttributeLoad NameLoad attr If Call NameLoad NameLoad AttributeLoad NameLoad attr body If CompareIsNot Call AttributeLoad NameLoad attr NameLoad body Assign NameStore BinOpSub NameLoad Call AttributeLoad NameLoad attr Assign NameStore Call NameLoad BinOpAdd BinOpMult Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Num BinOpDiv AttributeLoad NameLoad attr Num Return Dict Str NameLoad If Call NameLoad NameLoad TupleLoad NameLoad NameLoad body Assign NameStore Str If BinOpBitAnd AttributeLoad NameLoad attr AttributeLoad NameLoad attr body AugAssignAdd NameStore Str If BinOpBitAnd AttributeLoad NameLoad attr AttributeLoad NameLoad attr body AugAssignAdd NameStore Str If BinOpBitAnd AttributeLoad NameLoad attr AttributeLoad NameLoad attr body AugAssignAdd NameStore Str If BinOpBitAnd AttributeLoad NameLoad attr AttributeLoad NameLoad attr body AugAssignAdd NameStore Str If BinOpBitAnd AttributeLoad NameLoad attr AttributeLoad NameLoad attr body AugAssignAdd NameStore Str If BinOpBitAnd AttributeLoad NameLoad attr AttributeLoad NameLoad attr body AugAssignAdd NameStore Str If Call NameLoad AttributeLoad NameLoad attr NameLoad body Assign NameStore AttributeLoad NameLoad attr orelse Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str Return Call NameLoad ListLoad TupleLoad Str NameLoad TupleLoad Str NameLoad If Call NameLoad NameLoad NameLoad body Return Dict Str Num If Call NameLoad NameLoad NameLoad body Return Dict Str Num If Call NameLoad NameLoad NameLoad body Return Call NameLoad ListLoad TupleLoad Str AttributeLoad NameLoad attr TupleLoad Str AttributeLoad NameLoad attr If Call NameLoad NameLoad NameLoad body Return Call NameLoad ListLoad TupleLoad Str Call NameLoad NameLoad TupleLoad Str AttributeLoad NameLoad attr If Call NameLoad NameLoad NameLoad body Return Call NameLoad ListLoad TupleLoad Str Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr TupleLoad Str BinOpMod Str AttributeLoad NameLoad attr If BoolOpAnd NameLoad Call NameLoad NameLoad NameLoad body Return Call NameLoad ListLoad TupleLoad Str Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr TupleLoad Str Str If BoolOpAnd Call AttributeLoad NameLoad attr Call NameLoad NameLoad AttributeLoad AttributeLoad NameLoad attr attr body Return Dict Str AttributeLoad NameLoad attr Raise Call NameLoad BinOpMod Str NameLoad decorator_list
N/A N/A Tools for using Python's :mod:`json` module with BSON documents.

This module provides two helper methods `dumps` and `loads` that wrap the
native :mod:`json` methods and provide explicit BSON conversion to and from
json.  This allows for specialized encoding and decoding of BSON documents
into `Mongo Extended JSON
<http://www.mongodb.org/display/DOCS/Mongo+Extended+JSON>`_'s *Strict*
mode.  This lets you encode / decode BSON documents to JSON even when
they use special BSON types.

Example usage (serialization):

.. doctest::

   >>> from openmdao.lib.casehandlers.pymongo_bson import Binary, Code
   >>> from openmdao.lib.casehandlers.pymongo_bson.json_util import dumps
   >>> dumps([{'foo': [1, 2]},
   ...        {'bar': {'hello': 'world'}},
   ...        {'code': Code("function x() { return 1; }")},
   ...        {'bin': Binary("")}])
   '[{"foo": [1, 2]}, {"bar": {"hello": "world"}}, {"code": {"$code": "function x() { return 1; }", "$scope": {}}}, {"bin": {"$binary": "AQIDBA==", "$type": "00"}}]'

Example usage (deserialization):

.. doctest::

   >>> from openmdao.lib.casehandlers.pymongo_bson.json_util import loads
   >>> loads('[{"foo": [1, 2]}, {"bar": {"hello": "world"}}, {"code": {"$scope": {}, "$code": "function x() { return 1; }"}}, {"bin": {"$type": "00", "$binary": "AQIDBA=="}}]')
   [{u'foo': [1, 2]}, {u'bar': {u'hello': u'world'}}, {u'code': Code('function x() { return 1; }', {})}, {u'bin': Binary('...', 0)}]

Alternatively, you can manually pass the `default` to :func:`json.dumps`.
It won't handle :class:`~bson.binary.Binary` and :class:`~bson.code.Code`
instances (as they are extended strings you can't provide custom defaults),
but it will be faster as there is less recursion.

.. versionchanged:: 2.7
   Preserves order when rendering SON, Timestamp, Code, Binary, and DBRef
   instances. (But not in Python 2.4.)

.. versionchanged:: 2.3
   Added dumps and loads helpers to automatically handle conversion to and
   from json and supports :class:`~bson.binary.Binary` and
   :class:`~bson.code.Code`

.. versionchanged:: 1.9
   Handle :class:`uuid.UUID` instances, whenever possible.

.. versionchanged:: 1.8
   Handle timezone aware datetime instances on encode, decode to
   timezone aware datetime instances.

.. versionchanged:: 1.8
   Added support for encoding/decoding :class:`~bson.max_key.MaxKey`
   and :class:`~bson.min_key.MinKey`, and for encoding
   :class:`~bson.timestamp.Timestamp`.

.. versionchanged:: 1.2
   Added support for encoding/decoding datetimes and regular expressions.
 N/A base64 N/A calendar N/A datetime N/A re N/A json_lib True N/A N/A N/A json N/A N/A N/A ImportError N/A N/A N/A N/A simplejson json N/A N/A N/A ImportError N/A N/A json_lib False N/A openmdao.lib.casehandlers.pymongo_bson bson openmdao.lib.casehandlers.pymongo_bson EPOCH_AWARE RE_TYPE SON openmdao.lib.casehandlers.pymongo_bson.binary Binary openmdao.lib.casehandlers.pymongo_bson.code Code openmdao.lib.casehandlers.pymongo_bson.dbref DBRef openmdao.lib.casehandlers.pymongo_bson.max_key MaxKey openmdao.lib.casehandlers.pymongo_bson.min_key MinKey openmdao.lib.casehandlers.pymongo_bson.objectid ObjectId openmdao.lib.casehandlers.pymongo_bson.regex Regex openmdao.lib.casehandlers.pymongo_bson.timestamp Timestamp openmdao.lib.casehandlers.pymongo_bson.py3compat PY3 binary_type string_types N/A _RE_OPT_TABLE N/A i l m s u x N/A re I N/A re L N/A re M N/A re S N/A re U N/A re X dumps N/A N/A obj N/A args kwargs N/A N/A Helper function that wraps :class:`json.dumps`.

    Recursive function that handles all BSON types including
    :class:`~bson.binary.Binary` and :class:`~bson.code.Code`.

    .. versionchanged:: 2.7
       Preserves order when rendering SON, Timestamp, Code, Binary, and DBRef
       instances. (But not in Python 2.4.)
     N/A N/A json_lib N/A N/A N/A Exception No json library available N/A N/A N/A json dumps N/A _json_convert obj args kwargs N/A loads N/A N/A s N/A args kwargs N/A N/A Helper function that wraps :class:`json.loads`.

    Automatically passes the object_hook for BSON type conversion.

    :Parameters:
      - `compile_re` (optional): if ``False``, don't attempt to compile BSON
        regular expressions into Python regular expressions. Return instances
        of :class:`~bson.bsonregex.BSONRegex` instead.

    .. versionchanged:: 2.7
       Added ``compile_re`` option.
     N/A N/A json_lib N/A N/A N/A Exception No json library available N/A compile_re N/A N/A kwargs pop compile_re True N/A N/A kwargs N/A object_hook N/A N/A N/A dct N/A N/A object_hook dct compile_re N/A N/A N/A json loads s args kwargs N/A _json_convert N/A N/A obj N/A N/A N/A Recursive helper method that converts BSON types so they can be
    converted into json.
     numpy ndarray N/A N/A N/A hasattr obj iteritems N/A hasattr obj items N/A N/A N/A SON N/A N/A k N/A _json_convert v N/A N/A k v N/A N/A obj iteritems N/A N/A N/A N/A hasattr obj __iter__ N/A N/A isinstance obj string_types N/A N/A isinstance obj ndarray N/A N/A N/A list N/A N/A _json_convert v N/A v obj N/A N/A N/A N/A default obj N/A N/A N/A TypeError N/A N/A obj N/A object_hook N/A N/A dct compile_re N/A True N/A N/A N/A $oid dct N/A N/A N/A ObjectId N/A str N/A dct N/A $oid N/A N/A $ref dct N/A N/A N/A DBRef N/A dct N/A $ref N/A dct N/A $id N/A N/A dct get $db None N/A N/A $date dct N/A N/A secs N/A N/A float N/A dct N/A $date 1000.0 N/A N/A EPOCH_AWARE N/A N/A datetime timedelta seconds secs N/A N/A $regex dct N/A N/A flags 0 N/A opt N/A N/A dct get $options N/A N/A flags N/A N/A _RE_OPT_TABLE get opt 0 N/A compile_re N/A N/A N/A N/A re compile N/A dct N/A $regex flags N/A N/A N/A Regex N/A dct N/A $regex flags N/A N/A $minKey dct N/A N/A N/A MinKey N/A N/A $maxKey dct N/A N/A N/A MaxKey N/A N/A $binary dct N/A N/A N/A isinstance N/A dct N/A $type int N/A N/A N/A dct N/A $type N/A %02x N/A dct N/A $type N/A subtype N/A int N/A dct N/A $type 16 N/A N/A subtype 4294967168 N/A N/A subtype N/A int N/A N/A dct N/A $type N/A 6 16 N/A N/A Binary N/A N/A base64 b64decode N/A N/A N/A dct N/A $binary encode subtype N/A N/A $code dct N/A N/A N/A Code N/A dct N/A $code N/A N/A dct get $scope N/A N/A N/A N/A bson has_uuid N/A $uuid dct N/A N/A N/A N/A N/A bson uuid UUID N/A dct N/A $uuid N/A dct N/A default N/A N/A obj N/A N/A N/A N/A isinstance obj ObjectId N/A N/A N/A $oid N/A str obj N/A N/A isinstance obj DBRef N/A N/A N/A _json_convert N/A N/A obj as_doc N/A N/A isinstance obj N/A datetime datetime N/A N/A N/A N/A N/A obj utcoffset None N/A N/A obj N/A obj N/A N/A obj utcoffset N/A millis N/A int N/A N/A N/A N/A calendar timegm N/A N/A obj timetuple 1000 N/A N/A obj microsecond 1000 N/A N/A $date millis N/A N/A isinstance obj N/A RE_TYPE Regex N/A N/A flags N/A N/A N/A obj flags N/A re IGNORECASE N/A N/A flags i N/A N/A N/A obj flags N/A re LOCALE N/A N/A flags l N/A N/A N/A obj flags N/A re MULTILINE N/A N/A flags m N/A N/A N/A obj flags N/A re DOTALL N/A N/A flags s N/A N/A N/A obj flags N/A re UNICODE N/A N/A flags u N/A N/A N/A obj flags N/A re VERBOSE N/A N/A flags x N/A N/A isinstance N/A obj pattern unicode N/A N/A pattern N/A obj pattern N/A N/A pattern N/A N/A N/A obj pattern decode utf-8 N/A N/A SON N/A N/A $regex pattern N/A $options flags N/A N/A isinstance obj MinKey N/A N/A N/A $minKey 1 N/A N/A isinstance obj MaxKey N/A N/A N/A $maxKey 1 N/A N/A isinstance obj Timestamp N/A N/A N/A SON N/A N/A t N/A obj time N/A i N/A obj inc N/A N/A isinstance obj Code N/A N/A N/A SON N/A N/A $code N/A str obj N/A $scope N/A obj scope N/A N/A isinstance obj Binary N/A N/A N/A SON N/A N/A $binary N/A N/A N/A N/A base64 b64encode obj decode N/A $type N/A %02x N/A obj subtype N/A N/A PY3 N/A isinstance obj binary_type N/A N/A N/A SON N/A N/A $binary N/A N/A N/A N/A base64 b64encode obj decode N/A $type 00 N/A N/A N/A N/A bson has_uuid N/A isinstance obj N/A N/A bson uuid UUID N/A N/A N/A $uuid N/A obj hex N/A N/A TypeError N/A %r is not JSON serializable obj N/A