(self, header, elements, sort=True)
Adds information formatted as list element
Adds information formatted as list element
Adds information formatted as list element
def lister(self, header, elements, sort=True):
        '''
        Adds information formatted as list element
        '''
        lstElem = self.__doc.createElement(LST_ELEM_NAME)
        lstElem.setAttributeNode(self._createAttribute(TYPE_ATTR, header))
        if elements:
            if sort:
                try:
                    elements = set(elements)
                    elements = list(elements)
                    elements.sort(key=lambda x: x.lower())
                except:
                    pass

            for element in elements:
                memberElem = self.__doc.createElement(MEMBER_ELEM)
                lstElem.appendChild(memberElem)
                if isinstance(element, basestring):
                    memberElem.setAttributeNode(self._createAttribute(TYPE_ATTR, "string"))
                    memberElem.appendChild(self._createTextNode(element))
                elif isinstance(element, (list, tuple, set)):
                    memberElem.setAttributeNode(self._createAttribute(TYPE_ATTR, "list"))
                    for e in element:
                        memberElemStr = self.__doc.createElement(MEMBER_ELEM)
                        memberElemStr.setAttributeNode(self._createAttribute(TYPE_ATTR, "string"))
                        memberElemStr.appendChild(self._createTextNode(getUnicode(e)))
                        memberElem.appendChild(memberElemStr)
        listsElem = self._getRootChild(LSTS_ELEM_NAME)
        if not(listsElem):
            listsElem = self.__doc.createElement(LSTS_ELEM_NAME)
            self._addToRoot(listsElem)
        listsElem.appendChild(lstElem)
def lister ( self , header , elements , sort = True ) : lstElem = self . __doc . createElement ( LST_ELEM_NAME ) lstElem . setAttributeNode ( self . _createAttribute ( TYPE_ATTR , header ) ) if elements : if sort : try : elements = set ( elements ) elements = list ( elements ) elements . sort ( key = lambda x : x . lower ( ) ) except : pass for element in elements : memberElem = self . __doc . createElement ( MEMBER_ELEM ) lstElem . appendChild ( memberElem ) if isinstance ( element , basestring ) : memberElem . setAttributeNode ( self . _createAttribute ( TYPE_ATTR , "string" ) ) memberElem . appendChild ( self . _createTextNode ( element ) ) elif isinstance ( element , ( list , tuple , set ) ) : memberElem . setAttributeNode ( self . _createAttribute ( TYPE_ATTR , "list" ) ) for e in element : memberElemStr = self . __doc . createElement ( MEMBER_ELEM ) memberElemStr . setAttributeNode ( self . _createAttribute ( TYPE_ATTR , "string" ) ) memberElemStr . appendChild ( self . _createTextNode ( getUnicode ( e ) ) ) memberElem . appendChild ( memberElemStr ) listsElem = self . _getRootChild ( LSTS_ELEM_NAME ) if not ( listsElem ) : listsElem = self . __doc . createElement ( LSTS_ELEM_NAME ) self . _addToRoot ( listsElem ) listsElem . appendChild ( lstElem )