summaryrefslogtreecommitdiffstats
path: root/filter_manager.py
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2014-09-02 23:30:21 +0200
committerJan Pokorný <jpokorny@redhat.com>2014-09-02 23:31:11 +0200
commit53c5c50bb69de718893ca8eee41ca0a48dd00fda (patch)
treea1cfd0dfad41b07b19849b9547c6276c6d32729e /filter_manager.py
parentdfe813291aa08e60cc5174be72580daefe8cbe7e (diff)
downloadclufter-53c5c50bb69de718893ca8eee41ca0a48dd00fda.tar.gz
clufter-53c5c50bb69de718893ca8eee41ca0a48dd00fda.tar.xz
clufter-53c5c50bb69de718893ca8eee41ca0a48dd00fda.zip
filter{,_manager}: filter responsible for resolving self
... against the passed formats Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'filter_manager.py')
-rw-r--r--filter_manager.py36
1 files changed, 5 insertions, 31 deletions
diff --git a/filter_manager.py b/filter_manager.py
index f7a5d64..18dfd51 100644
--- a/filter_manager.py
+++ b/filter_manager.py
@@ -11,10 +11,6 @@ from .error import ClufterError
from .filter import filters
from .format import CompositeFormat
from .plugin_registry import PluginManager
-from .utils import tuplist
-from .utils_func import apply_preserving_depth, \
- apply_aggregation_preserving_depth, \
- apply_intercalate
log = logging.getLogger(__name__)
@@ -45,33 +41,11 @@ class FilterManager(PluginManager):
return composite_onthefly
for flt_name, flt_cls in filters.items():
- res_input = [flt_cls.in_format, flt_cls.out_format]
- res_output = apply_preserving_depth(formats.get)(res_input)
- if apply_aggregation_preserving_depth(all)(res_output):
- log.debug("Resolve at `{0}' filter: `{1}' -> {2}"
- .format(flt_name, repr(res_input), repr(res_output)))
- # capture composite formats if present; when running
- # into composite format, we replace in-situ the whole iterable
- # with as-of-now resolved formats with lazily pulled
- # CompositeFormat passing it these formats along the standard
- # business (as opposed to on-the-fly class creation when it
- # probably won't be ever instantiated anyway);
- # extra lambda wrapping so as to surely make a closure around
- # ("remember correctly") the current value of res_output
- res_output = tuple(
- get_composite_onthefly(o) if tuplist(o) else o
- for o in res_output
- )
- filters[flt_name] = flt_cls(*res_output)
- continue
- # drop the filter if cannot resolve any of the formats
- res_input = apply_intercalate(res_input)
- map(lambda (i, x): log.warning("Resolve at `{0}' filter:"
- " `{1}' (#{2}) format fail"
- .format(flt_name, res_input[i], i)),
- filter(lambda (i, x): not(x),
- enumerate(apply_intercalate(res_output))))
- filters.pop(flt_name)
+ ret = flt_cls(formats)
+ if ret is not None:
+ filters[flt_name] = ret
+ else:
+ filters.pop(flt_name)
return filters
@property