def __init__(self, method, *args): self.method = method self.args = args # Check arguments try: inspect.getcallargs(self.construct, *args) except TypeError as e: raise InvalidFilterSpecError(e) # Call construct try: self.construct(*args) except ValueError as e: raise InvalidFilterSpecError(e)
def operations(self): # Search for operations self._search_for_operations() # Build list of operation objects operations = [] for op_spec in self.spec.split('|'): op_spec_parts = op_spec.split('-') if op_spec_parts[0] not in self._registered_operations: raise InvalidFilterSpecError("Unrecognised operation: %s" % op_spec_parts[0]) op_class = self._registered_operations[op_spec_parts[0]] operations.append(op_class(*op_spec_parts)) return operations