comparison urwid_satext/keys.py @ 86:ea5b9a211bbb

added namespace check in keys.ActionMap.set_close_namespaces
author Goffi <goffi@goffi.org>
date Thu, 04 Sep 2014 18:43:39 +0200
parents e0c8274f9b1c
children a0dbf973befa
comparison
equal deleted inserted replaced
85:e0c8274f9b1c 86:ea5b9a211bbb
108 @param always_check (tuple): if not None, these namespaces will be close to every other ones (useful for global namespace) 108 @param always_check (tuple): if not None, these namespaces will be close to every other ones (useful for global namespace)
109 """ 109 """
110 assert isinstance(close_namespaces, tuple) 110 assert isinstance(close_namespaces, tuple)
111 if always_check is not None: 111 if always_check is not None:
112 assert isinstance(always_check, tuple) 112 assert isinstance(always_check, tuple)
113 to_check = reduce(lambda ns1, ns2: ns1.union(ns2), close_namespaces, set(always_check) or set())
114 if not to_check.issubset(self._namespaces_actions):
115 raise ValueError("Unkown namespaces: {}".format(', '.join(to_check.difference(self._namespaces_actions))))
113 self._close_namespaces = close_namespaces 116 self._close_namespaces = close_namespaces
114 self._alway_check_namespaces = always_check 117 self._alway_check_namespaces = always_check
115 118
116 def check_namespaces(self): 119 def check_namespaces(self):
117 """Check that shortcuts are not conflicting in close namespaces""" 120 """Check that shortcuts are not conflicting in close namespaces"""