Fix pep8, docs, requirements issues in jsonutils and tests
Fixes pep8 issues in jsonutils and tests, fixes documentation build issues, brings the version of hacking in line with openstack/requirements. Change-Id: I207c5d632f6c879613496d61931dc4817d5b74d0
This commit is contained in:
parent
f7ba3df3b7
commit
f3aa93cb19
@ -88,7 +88,6 @@ def to_primitive(value, convert_instances=False, convert_datetime=True,
|
|||||||
track the depth of the object inspections and don't go too deep.
|
track the depth of the object inspections and don't go too deep.
|
||||||
|
|
||||||
Therefore, convert_instances=True is lossy ... be aware.
|
Therefore, convert_instances=True is lossy ... be aware.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# handle obvious types first - order of basic types determined by running
|
# handle obvious types first - order of basic types determined by running
|
||||||
# full tests on nova project, resulting in the following counts:
|
# full tests on nova project, resulting in the following counts:
|
||||||
@ -175,9 +174,10 @@ JSONDecoder = json.JSONDecoder
|
|||||||
|
|
||||||
def dumps(obj, default=to_primitive, **kwargs):
|
def dumps(obj, default=to_primitive, **kwargs):
|
||||||
"""Serialize ``obj`` to a JSON formatted ``str``.
|
"""Serialize ``obj`` to a JSON formatted ``str``.
|
||||||
|
|
||||||
:param obj: object to be serialized
|
:param obj: object to be serialized
|
||||||
:param default: function that returns a serializable version of an object
|
:param default: function that returns a serializable version of an object
|
||||||
:param kwargs: extra named parameters, please see documentation
|
:param kwargs: extra named parameters, please see documentation \
|
||||||
of `json.dumps <https://docs.python.org/2/library/json.html#basic-usage>`_
|
of `json.dumps <https://docs.python.org/2/library/json.html#basic-usage>`_
|
||||||
:returns: json formatted string
|
:returns: json formatted string
|
||||||
"""
|
"""
|
||||||
@ -188,11 +188,12 @@ def dumps(obj, default=to_primitive, **kwargs):
|
|||||||
|
|
||||||
def dump(obj, fp, *args, **kwargs):
|
def dump(obj, fp, *args, **kwargs):
|
||||||
"""Serialize ``obj`` as a JSON formatted stream to ``fp``
|
"""Serialize ``obj`` as a JSON formatted stream to ``fp``
|
||||||
|
|
||||||
:param obj: object to be serialized
|
:param obj: object to be serialized
|
||||||
:param fp: a ``.write()``-supporting file-like object
|
:param fp: a ``.write()``-supporting file-like object
|
||||||
:param args: extra arguments, please see documentation
|
:param args: extra arguments, please see documentation \
|
||||||
of `json.dump <https://docs.python.org/2/library/json.html#basic-usage>`_
|
of `json.dump <https://docs.python.org/2/library/json.html#basic-usage>`_
|
||||||
:param kwargs: extra named parameters, please see documentation
|
:param kwargs: extra named parameters, please see documentation \
|
||||||
of `json.dump <https://docs.python.org/2/library/json.html#basic-usage>`_
|
of `json.dump <https://docs.python.org/2/library/json.html#basic-usage>`_
|
||||||
"""
|
"""
|
||||||
if is_simplejson:
|
if is_simplejson:
|
||||||
@ -202,9 +203,10 @@ def dump(obj, fp, *args, **kwargs):
|
|||||||
|
|
||||||
def loads(s, encoding='utf-8', **kwargs):
|
def loads(s, encoding='utf-8', **kwargs):
|
||||||
"""Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a JSON
|
"""Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a JSON
|
||||||
|
|
||||||
:param s: string to deserialize
|
:param s: string to deserialize
|
||||||
:param encoding: encoding used to interpret the string
|
:param encoding: encoding used to interpret the string
|
||||||
:param kwargs: extra named parameters, please see documentation
|
:param kwargs: extra named parameters, please see documentation \
|
||||||
of `json.loads <https://docs.python.org/2/library/json.html#basic-usage>`_
|
of `json.loads <https://docs.python.org/2/library/json.html#basic-usage>`_
|
||||||
:returns: python object
|
:returns: python object
|
||||||
"""
|
"""
|
||||||
@ -212,11 +214,11 @@ def loads(s, encoding='utf-8', **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def load(fp, encoding='utf-8', **kwargs):
|
def load(fp, encoding='utf-8', **kwargs):
|
||||||
"""Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
|
"""Deserialize ``fp`` to a Python object.
|
||||||
a JSON document) to a Python object.
|
|
||||||
:param fp: a ``.write()``-supporting file-like object
|
:param fp: a ``.read()`` -supporting file-like object
|
||||||
:param encoding: encoding used to interpret the string
|
:param encoding: encoding used to interpret the string
|
||||||
:param kwargs: extra named parameters, please see documentation
|
:param kwargs: extra named parameters, please see documentation \
|
||||||
of `json.loads <https://docs.python.org/2/library/json.html#basic-usage>`_
|
of `json.loads <https://docs.python.org/2/library/json.html#basic-usage>`_
|
||||||
:returns: python object
|
:returns: python object
|
||||||
"""
|
"""
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# The order of packages is significant, because pip processes them in the order
|
# The order of packages is significant, because pip processes them in the order
|
||||||
# of appearance. Changing the order has an impact on the overall integration
|
# of appearance. Changing the order has an impact on the overall integration
|
||||||
# process, which may cause wedges in the gate later.
|
# process, which may cause wedges in the gate later.
|
||||||
hacking>=0.5.6,<0.8
|
hacking>=0.9.2,<0.10
|
||||||
mock>=1.0
|
mock>=1.0
|
||||||
netaddr>=0.7.12
|
netaddr>=0.7.12
|
||||||
|
|
||||||
|
@ -19,12 +19,12 @@ import json
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
import netaddr
|
import netaddr
|
||||||
from oslo.i18n import fixture
|
|
||||||
from oslotest import base as test_base
|
from oslotest import base as test_base
|
||||||
import simplejson
|
import simplejson
|
||||||
import six
|
import six
|
||||||
import six.moves.xmlrpc_client as xmlrpclib
|
import six.moves.xmlrpc_client as xmlrpclib
|
||||||
|
|
||||||
|
from oslo.i18n import fixture
|
||||||
from oslo.serialization import jsonutils
|
from oslo.serialization import jsonutils
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user