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:
parent
1be720f91d
commit
5793232f25
|
@ -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 py27 - traditional unit testing with python 2.7
|
||||
* 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):
|
||||
reprkeys = sorted(k
|
||||
for k in self.__dict__.keys()
|
||||
for k in self.__dict__
|
||||
if k[0] != '_' and k != 'manager')
|
||||
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
|
||||
return "<%s %s>" % (self.__class__.__name__, info)
|
||||
|
|
|
@ -96,7 +96,7 @@ def print_dict(d, formatters=None):
|
|||
caching=False, print_empty=False)
|
||||
pt.align = 'l'
|
||||
|
||||
for field in d.keys():
|
||||
for field in d:
|
||||
if field in formatters:
|
||||
pt.add_row([field, formatters[field](d[field])])
|
||||
else:
|
||||
|
|
|
@ -13,9 +13,10 @@
|
|||
|
||||
"""Searchlight v1 Search action implementations"""
|
||||
|
||||
import json
|
||||
import logging
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils
|
||||
|
||||
|
@ -96,10 +97,10 @@ class SearchResource(command.Lister):
|
|||
|
||||
if parsed_args.query:
|
||||
if parsed_args.json:
|
||||
query = json.loads(parsed_args.query)
|
||||
query = jsonutils.loads(parsed_args.query)
|
||||
else:
|
||||
try:
|
||||
json.loads(parsed_args.query)
|
||||
jsonutils.loads(parsed_args.query)
|
||||
print("You should use the --json flag when specifying "
|
||||
"a JSON object.")
|
||||
exit(1)
|
||||
|
|
|
@ -61,7 +61,7 @@ class FakeResource(object):
|
|||
setattr(self, k, v)
|
||||
|
||||
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')
|
||||
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
|
||||
return "<%s %s>" % (self.__class__.__name__, info)
|
||||
|
|
|
@ -52,7 +52,7 @@ class SearchManager(base.BaseManager):
|
|||
# transfer, since the data have been wrapped several times
|
||||
# before transfer, and the data overhead is pretty small comparing
|
||||
# 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']]
|
||||
|
||||
return resources
|
||||
|
|
Loading…
Reference in New Issue