def parseChecklist(checklistFile):
    log = logging.getLogger("DSEGenerator.checklistParser")
    try:
        checklistDocument = Document(checklistFile)
    except (FileNotFoundError):
        log.error("File '" + checklistFile + "' not Found! " +
                  FileNotFoundError.strerror)
        checklistDocument = None

    if checklistDocument is not None:
        template = readTemplate(checklistDocument)
        if template != const.CHECKLIST_TEMPLATE_INVALID:
            checklistTemplate = Resources.getChecklisteTemplate(template)
            try:
                tree = ET.parse(checklistTemplate)
            except Exception as e:
                log.error("Checklist Template '" + checklistTemplate +
                          "' could not be read! " + str(e))
                tree = None
                checklistObject = None
            except (FileNotFoundError):
                wx.MessageBox(
                    "Error occured when opening Checklist Template! " +
                    FileNotFoundError.strerror,
                    caption="Error occured!")
                log.error("Checklist Template '" + checklistTemplate +
                          "' could not be found! " +
                          FileNotFoundError.strerror)

            if tree != None:
                root = tree.getroot()
                checklistObject = XMLObject()
                checklistObject.setTemplate(checklistTemplate)
                for docs in root:
                    if isInput(docs):
                        for elem in docs:
                            if isWordTypeTable(elem):
                                checklistObject.addElement(
                                    elem.tag,
                                    parseTable(elem, checklistDocument))
                    if isOutput(docs):
                        for elem in docs:
                            checklistObject.addOutputDoc(
                                elem.attrib.get(const.CHECKLIST_ATTRIB_NAME),
                                elem.attrib.get(
                                    const.CHECKLIST_ATTRIB_TEMPLATE),
                                elem.attrib.get(const.CHECKLIST_ATTRIB_COND))
        else:
            log.error(
                "Processing of Template skipped because of invalid Template!")
            checklistObject = None
    else:
        log.error("Processing of Template skipped! Please check Error log!")
        checklistObject = None
    log.debug("finished creation checklistObject: " + str(checklistObject))
    return checklistObject
def parseChecklist(checklistFile):
    log = logging.getLogger("DSEGenerator.checklistParser")
    try:
        checklistDocument = Document(checklistFile)
    except (FileNotFoundError):
        log.error("File '" + checklistFile + "' not Found! " +
                  FileNotFoundError.strerror)
        checklistDocument = None

    if checklistDocument is not None:
        version = readVersion(checklistDocument)
        checklistTemplate = Resources.getChecklisteTemplate(version)
        print("version" + version)
        try:
            tree = ET.parse(checklistTemplate)
        except Exception as e:
            log.error("Checklist Template '" + checklistTemplate +
                      "' could not be read! " + str(e))
            tree = None
            checklistObject = None
        except (FileNotFoundError):
            wx.MessageBox("Error occured when opening Checklist Template! " +
                          FileNotFoundError.strerror,
                          caption="Error occured!")
            log.error("Checklist Template '" + checklistTemplate +
                      "' could not be found! " + FileNotFoundError.strerror)

        if tree != None:
            root = tree.getroot()
            checklistObject = XMLObject()
            checklistObject.xmlVersion = root.attrib.get(
                const.DSEDOC_ATTRIB_VERSION)
            if Resources.validVersions(version, checklistObject.xmlVersion):
                for elem in root:
                    if isWordTypeTable(elem):
                        checklistObject.addElement(
                            elem.tag, parseTable(elem, checklistDocument))

                if const.CHECKLIST_ATTRIB_TITLE in checklistObject.elementList:
                    checklistObject.wordVersion = checklistObject.elementList[
                        const.CHECKLIST_ATTRIB_TITLE][
                            const.CHECKLIST_ATTRIB_VERSION]
            else:
                log.warn("No valid versions! Processing skipped!")
    else:
        log.error("Processing of Template skipped! Please check Error log!")
        checklistObject = None
    log.debug("finished creation checklistObject: " + str(checklistObject))
    return checklistObject