From 1763776ea64c1b3ffdb238c41ef62be689d923a4 Mon Sep 17 00:00:00 2001 From: Fredrik Thulin Date: Mon, 3 May 2021 16:47:39 +0200 Subject: [PATCH] bugfix after change from default None to empty list --- src/pyff/api.py | 1 - src/pyff/builtins.py | 24 +++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/pyff/api.py b/src/pyff/api.py index 29980e24..fb5aa7ba 100644 --- a/src/pyff/api.py +++ b/src/pyff/api.py @@ -300,7 +300,6 @@ def process_handler(request: Request) -> Response: ) r = p.process(request.registry.md, state=state, raise_exceptions=True, scheduler=request.registry.scheduler) - log.debug(f'Plumbing process result: {r}') if r is None: r = [] diff --git a/src/pyff/builtins.py b/src/pyff/builtins.py index d527f81a..803eb0c2 100644 --- a/src/pyff/builtins.py +++ b/src/pyff/builtins.py @@ -13,7 +13,7 @@ from copy import deepcopy from datetime import datetime from distutils.util import strtobool -from typing import Any, Dict, List, Optional +from typing import Any, Dict, Iterable, List, Optional import ipaddr import six @@ -274,10 +274,10 @@ def fork(req: Plumbing.Request, *opts): @deprecated(reason="any pipeline has been replace by other behaviour") @pipe(name='any') -def _any(lst, d): +def _any(lst: Iterable[Any], d: Any) -> Any: for x in lst: if x in d: - if type(d) == dict: + if isinstance(d, dict): return d[x] else: return True @@ -695,19 +695,25 @@ def _select_args(req: Plumbing.Request) -> List[str]: raise ValueError(f'Selection not possible with arg that is not a string: {this}') args += [this] - if args is None and req.state.select: + if not args and req.state.select: args = [req.state.select] log.debug(f'Using req.state.select: {args}') - if args is None: + if not args: args = req.store.collections() log.debug(f'Using req.store.collections: {args}') - if args is None or not args: + if not args: args = req.store.lookup('entities') - log.debug(f'Using req.store.entities: {args}') - if args is None or not args: + if len(args) < 5: + log.debug(f'Using req.store.entities: {args}') + else: + log.debug(f'Using req.store.entities: {args[:4]} (truncated)') + if not args: args = [] - log.info(f'selecting using args: {args}') + if len(args) < 5: + log.info(f'selecting using args: {args}') + else: + log.info(f'selecting using args: {args[:4]} (truncated)') return args