def make_selector(value): '''Create a selector callable from the supplied value. Args: value: If is a callable, then returned unchanged. If a string is used then create an attribute selector. If in an integer is used then create a key selector. Returns: A callable selector based on the supplied value. Raises: ValueError: If a selector cannot be created from the value. ''' if is_callable(value): return value if is_string(value): return a_(value) raise ValueError("Unable to create callable selector from '{0}'".format(value))
def make_selector(value): """Create a selector callable from the supplied value. Args: value: If is a callable, then returned unchanged. If a string is used then create an attribute selector. If in an integer is used then create a key selector. Returns: A callable selector based on the supplied value. Raises: ValueError: If a selector cannot be created from the value. """ if is_callable(value): return value if is_string(value): return a_(value) raise ValueError("Unable to create callable selector from '{0}'".format(value))
def test_k_result_is_callable(self): foo_selector = k_('foo') self.assertTrue(is_callable(foo_selector))
def generate(func, initial): if not is_callable(func): raise TypeError("func is not callable in call to generate().") return query(_generate_result(func, initial))