Update json module to jsonutils
1. json is deprecated, should use oslo_serialization.jsonutils instead. 2. cleanup of .keys() from dict_object.keys() *in* operator Change-Id: I09076a781a6fb12697d38b365ffda664be053187
This commit is contained in:
@@ -150,3 +150,5 @@ There are multiple test targets that can be run to validate the code.
|
|||||||
* tox -e pep8 - style guidelines enforcement
|
* tox -e pep8 - style guidelines enforcement
|
||||||
* tox -e py27 - traditional unit testing with python 2.7
|
* tox -e py27 - traditional unit testing with python 2.7
|
||||||
* tox -e py35 - traditional unit testing with python 3.5
|
* tox -e py35 - traditional unit testing with python 3.5
|
||||||
|
* tox -e py36 - traditional unit testing with python 3.6
|
||||||
|
* tox -e py37 - traditional unit testing with python 3.7
|
||||||
|
|||||||
@@ -460,7 +460,7 @@ class Resource(object):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
reprkeys = sorted(k
|
reprkeys = sorted(k
|
||||||
for k in self.__dict__.keys()
|
for k in self.__dict__
|
||||||
if k[0] != '_' and k != 'manager')
|
if k[0] != '_' and k != 'manager')
|
||||||
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
|
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
|
||||||
return "<%s %s>" % (self.__class__.__name__, info)
|
return "<%s %s>" % (self.__class__.__name__, info)
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ def print_dict(d, formatters=None):
|
|||||||
caching=False, print_empty=False)
|
caching=False, print_empty=False)
|
||||||
pt.align = 'l'
|
pt.align = 'l'
|
||||||
|
|
||||||
for field in d.keys():
|
for field in d:
|
||||||
if field in formatters:
|
if field in formatters:
|
||||||
pt.add_row([field, formatters[field](d[field])])
|
pt.add_row([field, formatters[field](d[field])])
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -13,9 +13,10 @@
|
|||||||
|
|
||||||
"""Searchlight v1 Search action implementations"""
|
"""Searchlight v1 Search action implementations"""
|
||||||
|
|
||||||
import json
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
|
|
||||||
@@ -96,10 +97,10 @@ class SearchResource(command.Lister):
|
|||||||
|
|
||||||
if parsed_args.query:
|
if parsed_args.query:
|
||||||
if parsed_args.json:
|
if parsed_args.json:
|
||||||
query = json.loads(parsed_args.query)
|
query = jsonutils.loads(parsed_args.query)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
json.loads(parsed_args.query)
|
jsonutils.loads(parsed_args.query)
|
||||||
print("You should use the --json flag when specifying "
|
print("You should use the --json flag when specifying "
|
||||||
"a JSON object.")
|
"a JSON object.")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class FakeResource(object):
|
|||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
reprkeys = sorted(k for k in self.__dict__.keys() if k[0] != '_' and
|
reprkeys = sorted(k for k in self.__dict__ if k[0] != '_' and
|
||||||
k != 'manager')
|
k != 'manager')
|
||||||
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
|
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
|
||||||
return "<%s %s>" % (self.__class__.__name__, info)
|
return "<%s %s>" % (self.__class__.__name__, info)
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class SearchManager(base.BaseManager):
|
|||||||
# transfer, since the data have been wrapped several times
|
# transfer, since the data have been wrapped several times
|
||||||
# before transfer, and the data overhead is pretty small comparing
|
# before transfer, and the data overhead is pretty small comparing
|
||||||
# to the data payload('_source'), it is done here for simplicity.
|
# to the data payload('_source'), it is done here for simplicity.
|
||||||
if 'simplified' in kwargs.keys() and kwargs['simplified']:
|
if 'simplified' in kwargs and kwargs['simplified']:
|
||||||
resources = [h['_source'] for h in resources.hits['hits']]
|
resources = [h['_source'] for h in resources.hits['hits']]
|
||||||
|
|
||||||
return resources
|
return resources
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ classifier =
|
|||||||
Programming Language :: Python :: 2.7
|
Programming Language :: Python :: 2.7
|
||||||
Programming Language :: Python :: 3
|
Programming Language :: Python :: 3
|
||||||
Programming Language :: Python :: 3.5
|
Programming Language :: Python :: 3.5
|
||||||
|
Programming Language :: Python :: 3.6
|
||||||
|
Programming Language :: Python :: 3.7
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
packages =
|
packages =
|
||||||
|
|||||||
Reference in New Issue
Block a user