def __init__(self, title): root = ET.Element('HTML') ET.ElementTree.__init__(self, root) head = ET.SubElement(root, 'HEAD') titleTag = ET.SubElement(head, 'TITLE') titleTag.text = title body = ET.SubElement(root, 'BODY')
def getTabTags(menu,activeTab): tabList = menu.keys() if "Main" in tabList: tabList.remove("Main") if "Services" in tabList: tabList.remove("Services") tabList.sort() if "Main" in menu.keys(): tabList.insert(0, "Main") if "Services" in menu.keys(): tabList.insert(1, "Services") tabNum = 0 tags = [] for tab in tabList: if tabNum == 0: if tab == activeTab: li = ET.Element('li', id='active') li.set('class', 'first') a = ET.SubElement(li, 'a', href=menu[tab], id='current') a.text = tab tags.append(li) else: li = ET.Element('li') li.set('class', 'first') a = ET.SubElement(li, 'a', href=menu[tab]) a.text = tab tags.append(li) else: if tab == activeTab: li = ET.Element('li', id='active') a = ET.SubElement(li, 'a', href=menu[tab], id='current') a.text = tab tags.append(li) else: li = ET.Element('li') a = ET.SubElement(li, 'a', href=menu[tab]) a.text = tab tags.append(li) tabNum += 1 return tags