def __str__()

in pachi_py/pachi/tools/sgflib/sgflib.py [0:0]


	def __str__(self):
		""" SGF representation, with proper line breaks between nodes."""
		if len(self):
			s = "(" + str(self[0])				# append the first Node automatically
			l = len(string.split(s, "\n")[-1])	# accounts for line breaks within Nodes
			for n in map(str, self[1:]):
				if l + len(string.split(n, "\n")[0]) > MAX_LINE_LEN:
					s = s + "\n"
					l = 0
				s = s + n
				l = len(string.split(s, "\n")[-1])
			return s + string.join(map(str, [""] + self.variations), "\n") + ")"
		else:
			return ""							# empty GameTree illegal; "()" illegal