Utilities to encode and decode Base64.
New in version 1.10.
Decode a Base64 encoded string.
Parameters: | encoded – bytes or text Base64 encoded string to be decoded |
---|---|
Returns: | decoded bytes string (bytes) |
Use decode_as_text() to get the decoded string as text.
Decode a Base64 encoded string.
Decode the Base64 string and then decode the result from encoding (UTF-8 by default).
Parameters: | encoded – bytes or text Base64 encoded string to be decoded |
---|---|
Returns: | decoded text string (bytes) |
Use decode_as_bytes() to get the decoded string as bytes.
Encode a string using Base64.
If s is a text string, first encode it to encoding (UTF-8 by default).
Parameters: |
|
---|---|
Returns: | Base64 encoded byte string (bytes) |
Use encode_as_text() to get the Base64 encoded string as text.
Encode a string using Base64.
If s is a text string, first encode it to encoding (UTF-8 by default).
Parameters: |
|
---|---|
Returns: | Base64 encoded text string (Unicode) |
Use encode_as_bytes() to get the Base64 encoded string as bytes.
JSON related utilities.
This module provides a few things:
Serialize obj as a JSON formatted stream to fp
Parameters: |
|
---|
Changed in version 1.3: The default parameter now uses to_primitive() by default.
Serialize obj to a JSON formatted bytes.
Parameters: |
|
---|---|
Returns: | json formatted string |
New in version 1.10.
Serialize obj to a JSON formatted str.
Parameters: |
|
---|---|
Returns: | json formatted string |
Use dump_as_bytes() to ensure that the result type is bytes on Python 2 and Python 3.
Deserialize fp to a Python object.
Parameters: |
|
---|---|
Returns: | python object |
Deserialize s (a str or unicode instance containing a JSON
Parameters: |
|
---|---|
Returns: | python object |
Convert a complex object into primitives.
Handy for JSON serialization. We can optionally handle instances, but since this is a recursive function, we could have cyclical data structures.
To handle cyclical data structures we could track the actual objects visited in a set, but not all objects are hashable. Instead we just track the depth of the object inspections and don’t go too deep.
Therefore, convert_instances=True is lossy ... be aware.
Changed in version 1.3: Support UUID encoding.
Changed in version 1.6: Dictionary keys are now also encoded.
MessagePack related utilities.
This module provides a few things:
New in version 1.3.
Registry of type specific msgpack handlers extensions.
See: https://github.com/msgpack/msgpack/blob/master/spec.md#formats-ext
Do note that due to the current limitations in the msgpack python library we can not currently dump/load a tuple without converting it to a list.
This may be fixed in: https://github.com/msgpack/msgpack-python/pull/100
New in version 1.5.
Deep copy the given registry (and its handlers).
Get the handler for the given numeric identity (or none).
Match the registries handlers to the given object (or none).
Applications can assign 0 to 127 to store application (or library) specific type handlers; see above ranges for what is reserved by this library and what is not.
Applications can assign 0 to 127 to store application (or library) specific type handlers; see above ranges for what is reserved by this library and what is not.
These ranges are always reserved for use by applications building their own type specific handlers (the meaning of extensions in this range will typically vary depending on application).
Register a extension handler to handle its associated type.
These ranges are always reserved for use by oslo.serialization and its own add-ons extensions (these extensions are meant to be generally applicable to all of python).
Small and/or simple immutable integer/float interval class.
Interval checking is inclusive of the min/max boundaries.
Default, read-only/frozen registry that will be used when none is provided.
This registry has msgpack extensions for the following:
New in version 1.5.
Serialize obj as a messagepack formatted stream to fp.
Changed in version 1.5: Added registry parameter.
Serialize obj to a messagepack formatted str.
Changed in version 1.5: Added registry parameter.
Deserialize fp into a Python object.
Changed in version 1.5: Added registry parameter.
Deserialize s messagepack str into a Python object.
Changed in version 1.5: Added registry parameter.