Exemple #1
0
	def redirects(self, redirect_node: 'AbstractNode') -> 'AbstractNode':
		"""
		Redirect the child branches of this node to the child branches of the given node
		:type redirect_node: AbstractNode
		:rtype: AbstractNode
		"""
		if self.has_children():
			raise IllegalNodeOperation('Node with children nodes is not allowed to be redirected')
		self._redirect_node = redirect_node
		return self
Exemple #2
0
	def then(self, node: 'AbstractNode') -> 'AbstractNode':
		"""
		Add a child node to this node
		:param node: a child node for new level command
		"""
		if self._redirect_node is not None:
			raise IllegalNodeOperation('Redirected node is not allowed to add child nodes')
		if isinstance(node, Literal):
			for literal in node.literals:
				self._children_literal[literal].append(node)
		else:
			self._children.append(node)
		return self
Exemple #3
0
	def then(self, node: 'ArgumentNode') -> 'ArgumentNode':
		"""
		Add a child node to this node
		:param node: a child node for new level command
		"""
		if self.redirect_node is not None:
			raise IllegalNodeOperation('Redirected node is not allowed to add child nodes')
		if isinstance(node, Literal):
			for literal in node.literals:
				nodes = self.children_literal.get(literal, [])
				nodes.append(node)
				self.children_literal[literal] = nodes
		else:
			self.children.append(node)
		return self
Exemple #4
0
 def suggests(
         self, suggestion: SOURCE_CONTEXT_CALLBACK_STR_COLLECTION
 ) -> 'AbstractNode':
     raise IllegalNodeOperation('Literal node doe not support suggests')
Exemple #5
0
	def suggests(self, suggestion: SUGGESTS_CALLBACK) -> 'AbstractNode':
		raise IllegalNodeOperation('Literal node doe not support suggests')