Exemple #1
0
	def presentable(self):
		"""a presentable node is something with
			- stones
			- move
			- comment
			- or marks"""
		if util.is_stone(self.name) or util.is_move(self.name):
			return True
		for e in self.extra:
			if util.is_extra(e):
				return True
		return False
Exemple #2
0
	def handle_node(self, prev, node, back=0):
		"Handle a node, like mark, comment, etc. dead stone is not handled here"
		if node.is_root():
			return
		self.emit(QtCore.SIGNAL("newComment(PyQt_PyObject)"), "")
		self.clear_marks()
		added = []
		removed = []
		if back and hasattr(node, 'undo'):
			node.undo()
		# XXX Stone has to be handled before the other properties
		if util.is_stone(node.name):
			added.extend(self.handle_stone(node))
		# When going back, the stone is already there
		elif util.is_move(node.name) and not back:
			removed.extend(self.handle_move(node))
		self.handle_extra(node)
		# Closure magic for undo
		prev.undo = functools.partial(self.attach_undo, node, added, removed)()
		if util.is_move(node.name) and not node.prop == "":  # PASS
			self.refresh_cross(node)
Exemple #3
0
	def build_tree(self):
		while True:
			try:
				current = self.sgf.next_token()

				if not type(current) is str:
					continue
				if util.is_move(current):
					self.on_move(current)
				elif util.is_stone(current):
					self.on_stone(current)
				elif util.is_meta(current):
					self.on_meta(current)
				elif util.is_extra(current):
					self.on_extra(current)
				elif util.is_branch(current):
					self.on_branch(current)
				elif util.is_node(current):
					self.on_node(current)
				else:
					pass
			except IndexError:
				break
		self.reset()