From f77799678c6132f6a8db16faa2f9c72771c017f3 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 5 Jun 2013 04:42:54 +0200 Subject: hostinfo: _match and _match_key are now private functions --- bin/hostinfo | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/hostinfo b/bin/hostinfo index 444bae7..f1453e9 100755 --- a/bin/hostinfo +++ b/bin/hostinfo @@ -19,7 +19,7 @@ def _get_data(path): stream = file(path, 'r') return yaml.load(stream) -def match_key(data, keys): +def _match_key(data, keys): if data is None: return None @@ -30,19 +30,19 @@ def match_key(data, keys): rest = keys[1:] if key == 'addresses' and 'addresses' in data: - return match_key(utils.group_by(data['addresses'], 'interface'), rest) + return _match_key(utils.group_by(data['addresses'], 'interface'), rest) if key == 'ports' and 'ports' in data: - return match_key(utils.group_by(data['ports'], 'process', 'UNKNOWN'), rest) + return _match_key(utils.group_by(data['ports'], 'process', 'UNKNOWN'), rest) if isinstance(data, dict): if key in data: - return match_key(data[key], rest) + return _match_key(data[key], rest) return None if isinstance(data, list): for elem in data: - result = match_key(elem, keys) + result = _match_key(elem, keys) if result is not None: return result return None @@ -52,10 +52,10 @@ def match_key(data, keys): return None -def match(host, search_key, search_value, negate): +def _match(host, search_key, search_value, negate): search_keys = search_key.split('.') - result = match_key(host, search_keys) + result = _match_key(host, search_keys) if search_value is None: if negate: if result is not None: @@ -106,7 +106,7 @@ def print_search(basepath, flags, search, filter_key=None): search_key, search_value, negate = _parse_search(search) for host in hosts['hosts']: data = _get_data(os.path.join(basepath, host)) - key, result = match(data, search_key, search_value, negate) + key, result = _match(data, search_key, search_value, negate) if result is not None: if flags.only_names: print(_get_label(host)) -- cgit v1.2.3-1-g7c22