예제 #1
0
    def __installEric6Doc(self, engine):
        """
        Private method to install/update the eric6 help documentation.
        
        @param engine reference to the help engine (QHelpEngineCore)
        @return flag indicating success (boolean)
        """
        versionKey = "eric6_ide"
        info = engine.customValue(versionKey, "")
        lst = info.split('|')

        dt = QDateTime()
        if len(lst) and lst[0]:
            dt = QDateTime.fromString(lst[0], Qt.ISODate)

        qchFile = ""
        if len(lst) == 2:
            qchFile = lst[1]

        docsPath = QDir(getConfig("ericDocDir") + QDir.separator() + "Help")

        files = docsPath.entryList(["*.qch"])
        if not files:
            engine.setCustomValue(versionKey,
                                  QDateTime().toString(Qt.ISODate) + '|')
            return False

        for f in files:
            if f == "source.qch":
                fi = QFileInfo(docsPath.absolutePath() + QDir.separator() + f)
                namespace = QHelpEngineCore.namespaceName(
                    fi.absoluteFilePath())
                if not namespace:
                    continue

                if (dt.isValid()
                        and namespace in engine.registeredDocumentations()
                        and (fi.lastModified().toString(Qt.ISODate)
                             == dt.toString(Qt.ISODate))
                        and qchFile == fi.absoluteFilePath()):
                    return False

                if namespace in engine.registeredDocumentations():
                    engine.unregisterDocumentation(namespace)

                if not engine.registerDocumentation(fi.absoluteFilePath()):
                    self.errorMessage.emit(
                        self.tr(
                            """<p>The file <b>{0}</b> could not be"""
                            """ registered. <br/>Reason: {1}</p>""").format(
                                fi.absoluteFilePath, engine.error()))
                    return False

                engine.setCustomValue(
                    versionKey,
                    fi.lastModified().toString(Qt.ISODate) + '|' +
                    fi.absoluteFilePath())
                return True

        return False
예제 #2
0
 def __installEric6Doc(self, engine):
     """
     Private method to install/update the eric6 help documentation.
     
     @param engine reference to the help engine (QHelpEngineCore)
     @return flag indicating success (boolean)
     """
     versionKey = "eric6_ide"
     info = engine.customValue(versionKey, "")
     lst = info.split('|')
     
     dt = QDateTime()
     if len(lst) and lst[0]:
         dt = QDateTime.fromString(lst[0], Qt.ISODate)
     
     qchFile = ""
     if len(lst) == 2:
         qchFile = lst[1]
     
     docsPath = QDir(getConfig("ericDocDir") + QDir.separator() + "Help")
     
     files = docsPath.entryList(["*.qch"])
     if not files:
         engine.setCustomValue(
             versionKey, QDateTime().toString(Qt.ISODate) + '|')
         return False
     
     for f in files:
         if f == "source.qch":
             fi = QFileInfo(docsPath.absolutePath() + QDir.separator() + f)
             if dt.isValid() and \
                fi.lastModified().toString(Qt.ISODate) == \
                 dt.toString(Qt.ISODate) and \
                qchFile == fi.absoluteFilePath():
                 return False
             
             namespace = QHelpEngineCore.namespaceName(
                 fi.absoluteFilePath())
             if not namespace:
                 continue
             
             if namespace in engine.registeredDocumentations():
                 engine.unregisterDocumentation(namespace)
             
             if not engine.registerDocumentation(fi.absoluteFilePath()):
                 self.errorMessage.emit(
                     self.tr(
                         """<p>The file <b>{0}</b> could not be"""
                         """ registered. <br/>Reason: {1}</p>""")
                     .format(fi.absoluteFilePath, engine.error())
                 )
                 return False
             
             engine.setCustomValue(
                 versionKey,
                 fi.lastModified().toString(Qt.ISODate) + '|' +
                 fi.absoluteFilePath())
             return True
     
     return False
예제 #3
0
    def __insertFlashCookie(self, path):
        """
        Private method to insert a Flash cookie into the cache.
        
        @param path Flash cookies path
        @type str
        """
        solFile = QFile(path)
        if not solFile.open(QFile.ReadOnly):
            return

        dataStr = ""
        data = bytes(solFile.readAll())
        if data:
            try:
                reader = FlashCookieReader()
                reader.setBytes(data)
                reader.parse()
                dataStr = reader.toString()
            except FlashCookieReaderError as err:
                dataStr = err.msg

        solFileInfo = QFileInfo(solFile)

        cookie = FlashCookie()
        cookie.contents = dataStr
        cookie.name = solFileInfo.fileName()
        cookie.path = solFileInfo.canonicalPath()
        cookie.size = int(solFile.size())
        cookie.lastModified = solFileInfo.lastModified()
        cookie.origin = self.__extractOriginFrom(path)

        self.__flashCookies.append(cookie)
예제 #4
0
    def loadFile(self, filename=None):
        self.logger.info('loading ACL file %s' % filename)
        if filename is not None:
            f = QFile(filename)

            if not f.open(QIODevice.ReadOnly | QIODevice.Text):
                self.logger.error('error opening ACL file %s for read' %
                                  filename)
                return False

            bytes = f.readAll()

            if bytes.isEmpty():
                self.logger.error('unabled to read from ACL file %s' %
                                  filename)
                f.close()
                return False

            f.close()

            info = QFileInfo(filename)
            modified = int(info.lastModified().toMSecsSinceEpoch() / 1000)

            return self.parseJSON(doc=str(bytes),
                                  save=False,
                                  date=modified,
                                  status='loaded_from_file')

        return False
예제 #5
0
 def __insertFlashCookie(self, path):
     """
     Private method to insert a Flash cookie into the cache.
     
     @param path Flash cookies path
     @type str
     """
     solFile = QFile(path)
     if not solFile.open(QFile.ReadOnly):
         return
     
     dataStr = ""
     data = bytes(solFile.readAll())
     if data:
         try:
             reader = FlashCookieReader()
             reader.setBytes(data)
             reader.parse()
             dataStr = reader.toString()
         except FlashCookieReaderError as err:
             dataStr = err.msg
     
     solFileInfo = QFileInfo(solFile)
     
     cookie = FlashCookie()
     cookie.contents = dataStr
     cookie.name = solFileInfo.fileName()
     cookie.path = solFileInfo.canonicalPath()
     cookie.size = int(solFile.size())
     cookie.lastModified = solFileInfo.lastModified()
     cookie.origin = self.__extractOriginFrom(path)
     
     self.__flashCookies.append(cookie)
예제 #6
0
    def startSearch(self, query):
        print("search started..", query)
        filters = QDir.Files
        nameFilters = ["*.cpp"]
        iterator = QDirIterator("/home/alexanderb", nameFilters, filters,
                                QDirIterator.Subdirectories)
        while (iterator.hasNext()):
            filePath = iterator.next()
            fileInfo = QFileInfo(filePath)
            currentFile = QFile(filePath)
            currentFile.open(QFile.ReadOnly | QFile.Text)
            fileContents = currentFile.readAll().data().decode('utf8',
                                                               errors='ignore')
            if (fileContents.find(query) != -1):
                qtwItem = QTreeWidgetItem()
                qtwItem.setText(0, fileInfo.fileName())
                qtwItem.setText(1, fileInfo.suffix())
                qtwItem.setText(2, str(fileInfo.size() / 1024))
                qtwItem.setText(3,
                                fileInfo.lastModified().toString("MM/dd/yyyy"))
                qtwItem.setText(4, fileInfo.created().toString("MM/dd/yyyy"))
                qtwItem.setText(5, str("...here is the content..."))
                qtwItem.setText(6, filePath)
                self.qtwItems.append(qtwItem)

                self.match_found.emit(qtwItem)

        self.finished.emit()
예제 #7
0
 def GetFile(self, typeOfFile, suff):
     options = QFileDialog.Options()
     fileName, _ = QFileDialog.getOpenFileName(
         self,
         "Open {} File".format(typeOfFile),
         "",
         "{}".format(suff),
         options=options)
     if fileName:
         if typeOfFile == "any":
             myCipher.fileToBeSigned = fileName
             f = QFileInfo(fileName)
             n = f.fileName()
             file_info = "Informations about the file:\n \n"
             file_info += "Name: " + n + "\n"
             p = f.filePath()
             file_info += "Path: " + p + "\n"
             suf = f.suffix()
             file_info += "Suffix: " + suf + "\n"
             size = f.size()
             file_info += "Size (in bytes): " + str(size) + "\n"
             lastModify = f.lastModified().toPyDateTime()
             file_info += "Date of last change: " + str(lastModify)
             self.fileInfo.setText(file_info)
         elif typeOfFile == "Signed":
             myCipher.userFile = fileName
         elif typeOfFile == "Private key":
             myCipher.privPath = fileName
             with open(fileName, "r") as f:
                 f.seek(4)
                 base64Text = f.readline()
                 decodedBase64D = self.decodeFromBase64(base64Text)
                 myCipher.d = int(decodedBase64D, 10)
                 base64Text2 = f.readline()
                 decodedBase64N = self.decodeFromBase64(base64Text2)
                 myCipher.n = int(decodedBase64N, 10)
         elif typeOfFile == "Public key":
             myCipher.pubPath = fileName
             with open(fileName, "r") as f:
                 f.seek(4)
                 base64Text = f.readline()
                 decodedBase64E = self.decodeFromBase64(base64Text)
                 myCipher.e = int(decodedBase64E, 10)
                 base64Text2 = f.readline()
                 decodedBase64N = self.decodeFromBase64(base64Text2)
                 myCipher.n = int(decodedBase64N, 10)
         elif typeOfFile == "Zip":
             myCipher.zipPath = fileName
             with zipfile.ZipFile(fileName, "r") as z:
                 z.extractall("Extracted_files")
         elif typeOfFile == "Sign":
             myCipher.fileToBeVerified = fileName
             with open(fileName, "r") as f:
                 f.seek(13)
                 base64Text = f.readline()
                 decodedBase64 = self.decodeFromBase64(base64Text)
                 myCipher.toVerifyMessage = list(decodedBase64)
    def start_search(self, query, search_directory):
        self.keep_searching = True
        print("search started..", query)
        filters = QDir.Files

        nameFilters = [
            "*.cpp", "*.txt", "*.pdf", "*.doc", "*.docx", "*.xlsx", "*.xls",
            "*.ppt", "*.pptx"
        ]

        iterator = QDirIterator(search_directory, nameFilters, filters,
                                QDirIterator.Subdirectories)
        while (iterator.hasNext()):
            QApplication.processEvents()
            if (self.keep_searching):
                file_path = iterator.next()
                if (os.access(file_path, os.R_OK)):
                    try:
                        file_info = QFileInfo(file_path)
                        file_contents = parser.from_file(file_path)
                    except:
                        continue

                    if (file_contents['status'] == 200
                            and 'content' in file_contents.keys()
                            and file_contents['content'] is not None):
                        found_index = file_contents['content'].find(query)
                        if (found_index != -1):
                            snippet = file_contents['content'].strip().replace(
                                '\n', ' ').replace('\r', '')
                            snippet_index = snippet.find(query)

                            qtw_item = QTreeWidgetItem()
                            qtw_item.setText(0, file_info.fileName())
                            qtw_item.setText(1, file_info.suffix())
                            qtw_item.setText(2, str(file_info.size() / 1024))
                            qtw_item.setText(
                                3,
                                file_info.lastModified().toString(
                                    "MM/dd/yyyy"))
                            qtw_item.setText(
                                4,
                                file_info.created().toString("MM/dd/yyyy"))
                            qtw_item.setText(
                                5,
                                str(snippet)[snippet_index - 5:snippet_index +
                                             10])
                            qtw_item.setText(6, file_path)
                            self.qtw_items.append(qtw_item)

                            self.match_found.emit(qtw_item)
        self.finished.emit()
예제 #9
0
    def ImageSelectedEvent(self, path):
        def HumanSize(size, decimal_places):
            for unit in ['', 'KB', 'MB', 'GB', 'TB']:
                if size < 1024.0:
                    break
                size /= 1024.0
            return f"{size:.{decimal_places}f} {unit}"

        finfo = QFileInfo(path)
        self.imagePathBox.setText(finfo.absoluteFilePath())
        self.imageFileSizeBox.setText(HumanSize(finfo.size(), 3))
        date = finfo.lastModified().toString('yyyy-dd-MM hh:mm:ss')
        self.imageModifyTimeBox.setText(date)
        self.currentSelectPic = finfo
예제 #10
0
    def prepareAPIs(self, ondemand=False, rawList=None):
        """
        Public method to prepare the APIs if necessary.
        
        @keyparam ondemand flag indicating a requested preparation (boolean)
        @keyparam rawList list of raw API files (list of strings)
        """
        if self.__apis is None or self.__inPreparation:
            return

        needsPreparation = False
        if ondemand:
            needsPreparation = True
        else:
            # check, if a new preparation is necessary
            preparedAPIs = self.__preparedName()
            if preparedAPIs:
                preparedAPIsInfo = QFileInfo(preparedAPIs)
                if not preparedAPIsInfo.exists():
                    needsPreparation = True
                else:
                    preparedAPIsTime = preparedAPIsInfo.lastModified()
                    apifiles = sorted(
                        Preferences.getEditorAPI(self.__language,
                                                 self.__projectType))
                    if self.__apifiles != apifiles:
                        needsPreparation = True
                    for apifile in apifiles:
                        if (QFileInfo(apifile).lastModified() >
                                preparedAPIsTime):
                            needsPreparation = True
                            break

        if needsPreparation:
            # do the preparation
            self.__apis.clear()
            if rawList:
                apifiles = rawList
            else:
                apifiles = Preferences.getEditorAPI(self.__language,
                                                    self.__projectType)
            for apifile in apifiles:
                self.__apis.load(apifile)
            self.__apis.prepare()
            self.__apifiles = apifiles
예제 #11
0
 def prepareAPIs(self, ondemand=False, rawList=None):
     """
     Public method to prepare the APIs if necessary.
     
     @keyparam ondemand flag indicating a requested preparation (boolean)
     @keyparam rawList list of raw API files (list of strings)
     """
     if self.__apis is None or self.__inPreparation:
         return
     
     needsPreparation = False
     if ondemand:
         needsPreparation = True
     else:
         # check, if a new preparation is necessary
         preparedAPIs = self.__defaultPreparedName()
         if preparedAPIs:
             preparedAPIsInfo = QFileInfo(preparedAPIs)
             if not preparedAPIsInfo.exists():
                 needsPreparation = True
             else:
                 preparedAPIsTime = preparedAPIsInfo.lastModified()
                 apifiles = sorted(
                     Preferences.getEditorAPI(self.__language))
                 if self.__apifiles != apifiles:
                     needsPreparation = True
                 for apifile in apifiles:
                     if QFileInfo(apifile).lastModified() > \
                             preparedAPIsTime:
                         needsPreparation = True
                         break
     
     if needsPreparation:
         # do the preparation
         self.__apis.clear()
         if rawList:
             apifiles = rawList
         else:
             apifiles = Preferences.getEditorAPI(self.__language)
         for apifile in apifiles:
             self.__apis.load(apifile)
         self.__apis.prepare()
         self.__apifiles = apifiles
예제 #12
0
 def getOneSongInfo(self, songPath: str):
     """ 获取一首歌的信息 """
     tag = TinyTag.get(songPath)
     fileInfo = QFileInfo(songPath)
     # 获取标签信息
     suffix = "." + fileInfo.suffix()
     songName = tag.title if tag.title and tag.title.strip(
     ) else fileInfo.baseName()
     songer = tag.artist if tag.artist and tag.artist.strip() else "未知艺术家"
     album = tag.album if tag.album and tag.album.strip() else "未知专辑"
     tracknumber = str(tag.track) if tag.track else "0"
     tcon = tag.genre if tag.genre else "未知流派"
     duration = f"{int(tag.duration//60)}:{int(tag.duration%60):02}"
     album_list = adjustAlbumName(album)
     # 调整曲目序号
     tracknumber = self.__adjustTrackNumber(tracknumber)
     # 获取年份
     if tag.year and tag.year[0] != "0":
         year = tag.year[:4] + "年"
     else:
         tag = File(songPath)
         key_dict = {".m4a": "©day", ".mp3": "TDRC", ".flac": "year"}
         year = (str(tag.get(key_dict[suffix])[0])[:4] +
                 "年" if tag.get(key_dict[suffix]) else "未知年份")
     # 获取时间戳
     createTime = fileInfo.birthTime().toString(Qt.ISODate)
     modifiedTime = fileInfo.lastModified().toString(Qt.ISODate)
     songInfo = {
         "songPath": songPath,
         "songer": songer,
         "songName": songName,
         "album": album_list[0],  # album为原专辑名
         "modifiedAlbum": album_list[-1],  # modifiedAlbum为修改后的专辑名
         "tcon": tcon,
         "year": year,
         "tracknumber": tracknumber,
         "duration": duration,
         "suffix": suffix,
         "createTime": createTime,
         "modifiedTime": modifiedTime,
     }
     return songInfo
예제 #13
0
    def addFilesToExplorer(self,
                           fileName,
                           fileType,
                           scaler,
                           extensionTag,
                           isVideo=True):
        if fileName:
            info = QFileInfo(fileName)
            if info.baseName() == self.importedVideo and isVideo:
                QMessageBox.critical(self,
                                     "Error",
                                     "Video already exist",
                                     buttons=QMessageBox.Ok)
            elif info.baseName() == self.importedCSV and not isVideo:
                QMessageBox.critical(self,
                                     "Error",
                                     "CSV file already exist",
                                     buttons=QMessageBox.Ok)
            else:
                if (isVideo):
                    self.removeItemFromTable("video")
                    self.importedVideoPath = QUrl.fromLocalFile(fileName)
                    self.importedVideo = info.baseName()
                    cap = cv2.VideoCapture(r'{}'.format(
                        self.importedVideoPath.toString()))
                    fps = cap.get(cv2.CAP_PROP_FPS
                                  )  # OpenCV2 version 2 used "CV_CAP_PROP_FPS"
                    frame_count = cap.get(cv2.CAP_PROP_FRAME_COUNT)
                    self.durationChanged(int(frame_count / fps))
                    self.statusBar().showMessage('Status: Video/Image added')
                else:
                    self.removeItemFromTable("csv")
                    self.importedCSVPath = info.absoluteFilePath()
                    self.readCSV(info.absoluteFilePath(), info.baseName())
                    self.statusBar().showMessage('Status: CSV File added')

                size = str(info.size() / scaler) + extensionTag
                last_modified = info.lastModified().toString()[4:10]
                self.addItemToTable(
                    self.explorerView,
                    [info.baseName(), size, fileType, last_modified])
예제 #14
0
    def set_data(self, _file):
        ff = QFileInfo(_file)
        self.short_title(ff.fileName())
        self.ui.lsize.setText(naturalsize(ff.size(), format="%.1f "))

        if ff.isDir():
            self.ui.litems.show()
            self.ui.label_3.show()
            self.ui.litems.setText(str(len(glob(_file + "/*"))))
        else:
            self.ui.label_3.hide()
            self.ui.litems.hide()

        self.ui.lcreated.setText(ff.created().toString())
        self.ui.lmodified.setText(ff.lastModified().toString())
        self.ui.laccessed.setText(ff.lastRead().toString())
        self.ui.luser.setText(ff.owner())
        self.ui.luid.setText(str(ff.ownerId()))
        self.ui.lgroup.setText(str(ff.group()))
        self.ui.lgid.setText(str(ff.groupId()))
        self.ui.lpath.setText(ff.path())
예제 #15
0
    def updateDetails(self, path):
        """
        Updates the elements in the right menu based on arguments
        :param path: path of the file
        :return: nothing
        """
        info = QFileInfo(path)

        bullet = html.unescape("&#8226;")

        value: str = bullet + " File not saved!"
        # Get the file info and update all the respective fields
        if info is not None and path is not None:
            value = ""
            i_s = "<i>"
            i_e = "</i>"
            br = "<br>"

            size = info.size()
            units = ['Bytes', 'KB', 'MB', 'GB']
            unit = 0
            while len(str(round(size, 0))) > 3:
                size /= 1000
                unit += 1

            value += bullet + " Name: " + i_s + info.fileName() + i_e + br
            value += bullet + " Path: " + i_s + info.path() + i_e + br
            value += bullet + " Size: " + i_s + str(size) + " " + units[unit] + i_e + br
            value += bullet + " Owner: " + i_s + (str(info.owner())) + i_e + br
            value += bullet + " Viewed: " + i_s + \
                     (info.lastRead().toString(self.format_time)) + i_e + br
            value += bullet + " Modified: " + i_s + \
                     (info.lastModified().toString(self.format_time)) + i_e

        self.col_metadata_contents.setText(value)
        # Update the summary from file
        self.updateSummary()
예제 #16
0
 def on_btnInfo_lastModified_clicked(self):
     self.__showBtnInfo(self.sender())
     fileInfo = QFileInfo(self.ui.editFile.text())
     dt = fileInfo.lastModified()  # QDateTime
     text = dt.toString("yyyy-MM-dd hh:mm:ss")
     self.ui.textEdit.appendPlainText(text + "\n")
예제 #17
0
    def __installQtDoc(self, name, version, engine):
        """
        Private method to install/update a Qt help document.
        
        @param name name of the Qt help document (string)
        @param version Qt version of the help documens (integer)
        @param engine reference to the help engine (QHelpEngineCore)
        @return flag indicating success (boolean)
        """
        versionKey = "qt_version_{0}@@{1}".format(version, name)
        info = engine.customValue(versionKey, "")
        lst = info.split("|")

        dt = QDateTime()
        if len(lst) and lst[0]:
            dt = QDateTime.fromString(lst[0], Qt.ISODate)

        qchFile = ""
        if len(lst) == 2:
            qchFile = lst[1]

        if version == 4:
            docsPath = QDir(QLibraryInfo.location(QLibraryInfo.DocumentationPath) + QDir.separator() + "qch")
        elif version == 5:
            docsPath = QDir(QLibraryInfo.location(QLibraryInfo.DocumentationPath))
        else:
            # unsupported Qt version
            return False

        files = docsPath.entryList(["*.qch"])
        if not files:
            engine.setCustomValue(versionKey, QDateTime().toString(Qt.ISODate) + "|")
            return False

        for f in files:
            if f.startswith(name):
                fi = QFileInfo(docsPath.absolutePath() + QDir.separator() + f)
                namespace = QHelpEngineCore.namespaceName(fi.absoluteFilePath())
                if not namespace:
                    continue

                if (
                    dt.isValid()
                    and namespace in engine.registeredDocumentations()
                    and fi.lastModified().toString(Qt.ISODate) == dt.toString(Qt.ISODate)
                    and qchFile == fi.absoluteFilePath()
                ):
                    return False

                if namespace in engine.registeredDocumentations():
                    engine.unregisterDocumentation(namespace)

                if not engine.registerDocumentation(fi.absoluteFilePath()):
                    self.errorMessage.emit(
                        self.tr(
                            """<p>The file <b>{0}</b> could not be""" """ registered. <br/>Reason: {1}</p>"""
                        ).format(fi.absoluteFilePath, engine.error())
                    )
                    return False

                engine.setCustomValue(versionKey, fi.lastModified().toString(Qt.ISODate) + "|" + fi.absoluteFilePath())
                return True

        return False
예제 #18
0
    def __installQtDoc(self, name, version, engine):
        """
        Private method to install/update a Qt help document.
        
        @param name name of the Qt help document (string)
        @param version Qt version of the help documens (integer)
        @param engine reference to the help engine (QHelpEngineCore)
        @return flag indicating success (boolean)
        """
        versionKey = "qt_version_{0}@@{1}".format(version, name)
        info = engine.customValue(versionKey, "")
        lst = info.split('|')

        dt = QDateTime()
        if len(lst) and lst[0]:
            dt = QDateTime.fromString(lst[0], Qt.ISODate)

        qchFile = ""
        if len(lst) == 2:
            qchFile = lst[1]

        if version == 4:
            docsPath = QDir(
                QLibraryInfo.location(QLibraryInfo.DocumentationPath) +
                QDir.separator() + "qch")
        elif version == 5:
            docsPath = QLibraryInfo.location(QLibraryInfo.DocumentationPath)
            if (not os.path.isdir(docsPath)
                    or len(QDir(docsPath).entryList(["*.qch"])) == 0):
                # Qt installer is a bit buggy; it's missing a symbolic link
                docsPathList = QDir.fromNativeSeparators(docsPath).split("/")
                docsPath = os.sep.join(
                    docsPathList[:-3] +
                    ["Docs", "Qt-{0}.{1}".format(*qVersionTuple())])
            docsPath = QDir(docsPath)
        else:
            # unsupported Qt version
            return False

        files = docsPath.entryList(["*.qch"])
        if not files:
            engine.setCustomValue(versionKey,
                                  QDateTime().toString(Qt.ISODate) + '|')
            return False

        for f in files:
            if f.startswith(name + "."):
                fi = QFileInfo(docsPath.absolutePath() + QDir.separator() + f)
                namespace = QHelpEngineCore.namespaceName(
                    fi.absoluteFilePath())
                if not namespace:
                    continue

                if (dt.isValid()
                        and namespace in engine.registeredDocumentations()
                        and (fi.lastModified().toString(Qt.ISODate)
                             == dt.toString(Qt.ISODate))
                        and qchFile == fi.absoluteFilePath()):
                    return False

                if namespace in engine.registeredDocumentations():
                    engine.unregisterDocumentation(namespace)

                if not engine.registerDocumentation(fi.absoluteFilePath()):
                    self.errorMessage.emit(
                        self.tr(
                            """<p>The file <b>{0}</b> could not be"""
                            """ registered. <br/>Reason: {1}</p>""").format(
                                fi.absoluteFilePath, engine.error()))
                    return False

                engine.setCustomValue(
                    versionKey,
                    fi.lastModified().toString(Qt.ISODate) + '|' +
                    fi.absoluteFilePath())
                return True

        return False