Beispiel #1
0
 def input_handler_depth(self, i):
     api.test_input(i, 'number of depths to return must be greater than 0',
                    api.tests.greater_than(0))
     num = api.tree.current_node.number_of_parents
     api.test_input(i, 'number of depths to return must not exceed {}'
                    .format(num), api.tests.less_equal(num))
     return i
Beispiel #2
0
 def input_handler_alias(self, name):
     name = ' '.join(name.strip().lower().split())
     api.test_input(
         name,
         ['command name must start with letter or underscore',
          'invalid character in command name'],
         *api.tests.is_valid_command_name
     )
     return name
Beispiel #3
0
 def input_handler_position(self, i):
     if self.inputs.get('node', None) is None:
         node = api.tree.current_node
     else:
         # in the child node (argument 'in')
         node = self.inputs['node']
     num = len(node.children) + 1
     # +1 because the extra one is the last non-existent index that
     # may be created
     api.test_input(
         i, ['position must be an integer', 'position must be greater '
             'than 0', 'position must not exceed {}'.format(num)],
         *api.tests.is_valid_child_index(num)
     )
     return int(i)
Beispiel #4
0
 def input_handler_node(self, i):
     i = api.evaluate_node_reference(i)
     api.test_input(i, 'node reference must be forward reference',
                    api.tests.is_forward_reference)
     return i
Beispiel #5
0
 def input_handler_node(self, i):
     i = api.evaluate_node_reference(i)
     api.test_input(i, 'input must be node reference',
                    api.is_node)
     return i
Beispiel #6
0
 def input_handler_tag(self, i):
     api.test_input(i, 'tag cannot be empty', api.tests.not_whitespace,
                    bool)
     return i