def parseNode()

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


	def parseNode(self):
		""" Called when ";" encountered (& is consumed). Parses and returns one
			'Node', which can be empty. Raises 'NodePropertyParseError' if no
			property values are extracted. Raises 'EndOfDataParseError' if the
			end of 'self.data' is reached before the end of the node (i.e., the
			start of the next node, the start of a variation, or the end of the
			enclosing game tree)."""
		n = Node()
		while self.index < self.datalen:
			match = self.reNodeContents.match(self.data, self.index)
			if match:
				self.index = match.end()
				pvlist = self.parsePropertyValue()
				if pvlist:
					n.addProperty(n.makeProperty(match.group(1), pvlist))
				else:
					raise NodePropertyParseError
			else:										# reached end of Node
				return n
		raise EndOfDataParseError