def setTitle(template, title, chapterNumber):
 if (numberer.getNumberSections() and chapterNumber):
  titleNode = dom.Text()
  titleNode.ownerDocument = template.ownerDocument
  titleNode.data = ('%s. ' % (chapterNumber,))
  title.insert(0, titleNode)
 for nodeList in (domhelpers.findNodesNamed(template, 'title'), domhelpers.findElementsWithAttribute(template, 'class', 'title')):
  if nodeList:
   for titleNode in title:
    nodeList[0].appendChild(titleNode.cloneNode(True))

def setTitle ( template , title , chapterNumber ) : if ( numberer . getNumberSections ( ) and chapterNumber ) : titleNode = dom . Text ( ) titleNode . ownerDocument = template . ownerDocument titleNode . data = ( '%s. ' % ( chapterNumber , ) ) title . insert ( 0 , titleNode ) for nodeList in ( domhelpers . findNodesNamed ( template , 'title' ) , domhelpers . findElementsWithAttribute ( template , 'class' , 'title' ) ) : if nodeList : for titleNode in title : nodeList [ 0 ] . appendChild ( titleNode . cloneNode ( True ) )
add title and chapter number information to the template document .