From 957366cd72daf0ca5ffe8d53ce87063ffc9f9b33 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 5 Jun 2013 03:29:48 +0200 Subject: Printer: add force argument to force to print at least an empty entry If you execute a search with negative matching the result could contain hosts without the field. Under normal circumstances the entry is not printed, because the filter_key does not exists. To get all the matching entries an new force mode is added to print at lease an empty entry. --- bin/hostinfo | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/hostinfo b/bin/hostinfo index 4a48e2b..0a36f67 100755 --- a/bin/hostinfo +++ b/bin/hostinfo @@ -97,12 +97,14 @@ def print_search(basepath, flags, search, filter_key=None): p = printer.Printer(data, flags) if filter_key is not None or flags.details: - p.info(filter_key, label=_get_label(host), maxlength=max(length)) + p.info(filter_key, label=_get_label(host), + maxlength=max(length), force=True) else: if key is None: print(_get_label(host)) else: - p.info(key, label=_get_label(host), maxlength=max(length)) + p.info(key, label=_get_label(host), + maxlength=max(length), force=True) def print_info(path, flags, key=None): data = _get_data(path) -- cgit v1.2.3-1-g7c22