def numberDocument(document, chapterNumber):
 i = 1
 for node in domhelpers.findNodesNamed(document, 'h2'):
  label = dom.Text()
  label.data = ('%s.%d ' % (chapterNumber, i))
  node.insertBefore(label, node.firstChild)
  i += 1

def numberDocument ( document , chapterNumber ) : i = 1 for node in domhelpers . findNodesNamed ( document , 'h2' ) : label = dom . Text ( ) label . data = ( '%s.%d ' % ( chapterNumber , i ) ) node . insertBefore ( label , node . firstChild ) i += 1
number the sections of the given document .