pylint warnings fixed

This commit is contained in:
Fabio Manganiello 2019-07-13 15:49:38 +02:00
parent 8b2c6d333e
commit 07dbe57641

View file

@ -30,7 +30,6 @@ class Procedure(object):
for req in requests: for req in requests:
req.backend = self.backend req.backend = self.backend
@classmethod @classmethod
def build(cls, name, _async, requests, args=None, backend=None, id=None, procedure_class=None, **kwargs): def build(cls, name, _async, requests, args=None, backend=None, id=None, procedure_class=None, **kwargs):
reqs = [] reqs = []
@ -68,7 +67,7 @@ class Procedure(object):
# Check if this request is an if-else # Check if this request is an if-else
if len(request_config.keys()) >= 1: if len(request_config.keys()) >= 1:
key = list(request_config.keys())[0] key = list(request_config.keys())[0]
m = re.match('\s*(if)\s+\$\{(.*)\}\s*', key) m = re.match('\s*(if)\s+\${(.*)}\s*', key)
if m: if m:
if_count += 1 if_count += 1
@ -109,12 +108,13 @@ class Procedure(object):
request = Request.build(request_config) request = Request.build(request_config)
reqs.append(request) reqs.append(request)
for pending_if in if_config.queue: pending_if = if_config.get()
while pending_if:
reqs.append(IfProcedure.build(**pending_if)) reqs.append(IfProcedure.build(**pending_if))
pending_if = if_config.get()
return procedure_class(name=name, _async=_async, requests=reqs, args=args, backend=backend, **kwargs) return procedure_class(name=name, _async=_async, requests=reqs, args=args, backend=backend, **kwargs)
def execute(self, n_tries=1, **context): def execute(self, n_tries=1, **context):
""" """
Execute the requests in the procedure Execute the requests in the procedure
@ -123,7 +123,7 @@ class Procedure(object):
""" """
if self.args: if self.args:
args = self.args.copy() args = self.args.copy()
for (k,v) in args.items(): for k, v in args.items():
v = Request.expand_value_from_context(v, **context) v = Request.expand_value_from_context(v, **context)
args[k] = v args[k] = v
context[k] = v context[k] = v
@ -138,12 +138,13 @@ class Procedure(object):
if token: if token:
request.token = token request.token = token
context['_async'] = self._async; context['n_tries'] = n_tries context['_async'] = self._async
context['n_tries'] = n_tries
response = request.execute(**context) response = request.execute(**context)
if not self._async and response: if not self._async and response:
if isinstance(response.output, dict): if isinstance(response.output, dict):
for (k,v) in response.output.items(): for k, v in response.output.items():
context[k] = v context[k] = v
context['output'] = response.output context['output'] = response.output
@ -178,14 +179,13 @@ class LoopProcedure(Procedure):
context = {} context = {}
def __init__(self, name, iterator_name, iterable, requests, _async=False, args=None, backend=None, **kwargs): def __init__(self, name, iterator_name, iterable, requests, _async=False, args=None, backend=None):
super(). __init__(name=name, _async=_async, requests=requests, args=args, backend=backend, **kwargs) super(). __init__(name=name, _async=_async, requests=requests, args=args, backend=backend)
self.iterator_name = iterator_name self.iterator_name = iterator_name
self.iterable = iterable self.iterable = iterable
self.requests = requests self.requests = requests
def execute(self, _async=None, **context): def execute(self, _async=None, **context):
iterable = Request.expand_value_from_context(self.iterable, **context) iterable = Request.expand_value_from_context(self.iterable, **context)
response = Response() response = Response()
@ -197,6 +197,7 @@ class LoopProcedure(Procedure):
return response return response
# noinspection PyBroadException
class IfProcedure(Procedure): class IfProcedure(Procedure):
""" """
Models an if-else construct. Models an if-else construct.
@ -278,4 +279,3 @@ class IfProcedure(Procedure):
# vim:sw=4:ts=4:et: # vim:sw=4:ts=4:et: