예제 #1
0
 def rechKeyWord(self):
     kWToTest = self.listKeyWord()
     klen = len(kWToTest)
     print("liste à tester", kWToTest)
     n = self.ui.tableWidget.rowCount()
     for cv in range(0, n):
         nomCV = self.ui.tableWidget.item(cv, 0).text()
         currentTable = self.ui.tableWidget.item(cv, 0).toolTip()
         cvATester = QUrl.fromLocalFile(currentTable)
         cvATestPath = QUrl.toLocalFile(cvATester)
         text = parser.from_file(cvATestPath)
         cvTransfText = text['content']
         cvAcompare = cvTransfText.lower()
         cptKw = 0
         # listCV = {"nom", }
         for k in range(0, klen):
             if kWToTest[k] in cvAcompare:
                 cptKw += 1
                 # listCV.append(currentTable)
                 print("Trouvé")
             else:
                 print("pas trouvé")
         if self.ui.tWResults.rowCount() == 0:
             self.ui.tWResults.insertRow(0)
             self.ui.tWResults.setItem(0, 0, QTableWidgetItem(nomCV))
             self.ui.tWResults.setItem(0, 1, QTableWidgetItem(str(cptKw)))
         else:
             lgTable = self.ui.tWResults.rowCount()
             print(lgTable)
             self.ui.tWResults.insertRow(lgTable)
             self.ui.tWResults.setItem(lgTable, 0, QTableWidgetItem(nomCV))
             self.ui.tWResults.setItem(lgTable, 1,
                                       QTableWidgetItem(str(cptKw)))
예제 #2
0
    def add(self, url: QUrl, position: int = -1) -> bool:

        if not url.isValid():
            return False

        media_info = MediaInfo.parse(url.toLocalFile())
        track = media_info.tracks[0]
        if track.title is None:
            title = url.fileName()
        else:
            title = track.title

        if track.duration is None:
            duration_str = '--:--'
        else:
            duration = int(float(track.duration) / 1000)
            totalTime = QTime((duration / 3600) % 60, (duration / 60) % 60,
                              (duration % 60), (duration * 1000) % 1000)

            format = 'hh:mm:ss' if duration > 3600 else 'mm:ss'
            duration_str = totalTime.toString(format)

        if position >= self.rowCount() or position < 0:
            position = self.rowCount()

        self.beginInsertRows(QModelIndex(), position, position + 1)

        media_info = {'url': url, 'title': title, 'duration': duration_str}
        self.item_list.insert(position, media_info)

        self.endInsertRows()
        self.rowCount_changed.emit(self.rowCount())
        return True
예제 #3
0
 def rechKeyWord(self):
     self.ui.tWResults.setRowCount(0)
     kWToTest = self.listKeyWord()
     klen = len(kWToTest)
     n = self.ui.tableWidget.rowCount()
     for cv in range(0, n):
         nomCV = self.ui.tableWidget.item(cv, 0).text()
         currentTable = self.ui.tableWidget.item(cv, 0).toolTip()
         cvATester = QUrl.fromLocalFile(currentTable)
         cvATestPath = QUrl.toLocalFile(cvATester)
         text = parser.from_file(cvATestPath)
         cvTransfText = text['content']
         cvAcompare = cvTransfText.lower()
         cptKw = 0
         for k in range(0, klen):
             kWSearch = kWToTest[k]
             # (r'{}\[^a-z]'.format(kWSearch))
             if re.search(r'\W{}\W'.format(kWSearch), cvAcompare) != None:
                 # if kWSearch in cvAcompare:
                 cptKw += 1
         if cptKw != 0:
             if self.ui.tWResults.rowCount() == 0:
                 self.ui.tWResults.insertRow(0)
                 self.ui.tWResults.setItem(0, 0, QTableWidgetItem(nomCV))
                 self.ui.tWResults.setItem(0, 1,
                                           QTableWidgetItem(str(cptKw)))
             else:
                 lgTable = self.ui.tWResults.rowCount()
                 self.ui.tWResults.insertRow(lgTable)
                 self.ui.tWResults.setItem(lgTable, 0,
                                           QTableWidgetItem(nomCV))
                 self.ui.tWResults.setItem(lgTable, 1,
                                           QTableWidgetItem(str(cptKw)))
     self.ui.tWResults.sortItems(1, order=Qt.DescendingOrder)
예제 #4
0
 def openState(self, fileUrl: QUrl):
     f = open(fileUrl.toLocalFile(), "r")
     stateDict = json.load(f)
     f.close()
     retList = [None, None]
     print(stateDict["template"])
     print(stateDict["values"])
     return [stateDict["template"], stateDict["values"]]
예제 #5
0
 def handleUrlPath(self, path: str) -> str:
     url = QUrl(path)
     pathOk = ""
     if url.isLocalFile():
         pathOk = QDir.toNativeSeparators(url.toLocalFile())
     else:
         pathOk = path
     return pathOk
예제 #6
0
    def openModel(self, path):
        qDebug(f'CanvasHandler::openModel(): {path}')
        qurl = QUrl(path) # don't use fromLocalFile (it will add file:/// as prefix)
        localFilePath = None
        if (qurl.isLocalFile()):
		    # Remove the "file:///" if present
            localFilePath = qurl.toLocalFile()
        else:
            localFilePath = qurl
        self.__m_vtkFboItem.addModelFromFile(localFilePath)
예제 #7
0
 def saveState(self, templateText: str, valuesText: str, fileURL: QUrl):
     #print("the save state has been called \n"+templateText+" \n"+valuesText+"\n \n "+fileURL.toString())
     print("printing the path: " + fileURL.path())
     f = open(fileURL.toLocalFile(), "w")
     stateDict = {
         "name": "unknown",
         "template": templateText,
         "values": valuesText
     }
     json.dump(stateDict, f)
     f.close()
예제 #8
0
 def set_url(self, url: QUrl):
     if not url.isValid():
         return
     if mediainfo is None:
         return
     media_info = MediaInfo.parse(url.toLocalFile())
     for track in media_info.tracks:
         if track.track_type == 'Audio' or track.track_type == 'Video':
             duration = track.duration / 1000
             print(duration)
             print('{0} | {1:.0f}:{2:.0f}'.format(track.Title, duration / 60, duration % 60))
예제 #9
0
파일: app.py 프로젝트: cullen-beta/stm32pio
    def addProjectByPath(self, path: QUrl):
        """
        Create, append and save in QSettings a new ProjectListItem instance with a given QUrl path (typically sent from
        the QML GUI).

        Args:
            path: QUrl path to the project folder (absolute by default)
        """
        self.beginInsertRows(QModelIndex(), self.rowCount(), self.rowCount())
        project = ProjectListItem(project_args=[path.toLocalFile()],
                                  parent=self)
        self.projects.append(project)

        settings.beginGroup('app')
        settings.beginWriteArray('projects')
        settings.setArrayIndex(len(self.projects) - 1)
        settings.setValue('path', path.toLocalFile())
        settings.endArray()
        settings.endGroup()

        self.endInsertRows()
예제 #10
0
 def requestImage(self, url, size, requestedSize):
     url = QUrl(url)
     image = QImage(url.toLocalFile())
     width, height = image.width(), image.height()
     if size:
         size.setWidth(width)
         size.setHeight(height)
     if requestedSize.width() > 0:
         width = requestedSize.width()
     if requestedSize.height() > 0:
         height = requestedSize.height()
     return image.scaled(min(width, THUMBNAIL_SIZE),
                         min(height, THUMBNAIL_SIZE), Qt.KeepAspectRatio)
예제 #11
0
파일: scans2pdfgui.py 프로젝트: Unrud/djpdf
 def requestImage(self, url, size, requestedSize):
     url = QUrl(url)
     image = QImage(url.toLocalFile())
     width, height = image.width(), image.height()
     if size:
         size.setWidth(width)
         size.setHeight(height)
     if requestedSize.width() > 0:
         width = requestedSize.width()
     if requestedSize.height() > 0:
         height = requestedSize.height()
     return image.scaled(min(width, THUMBNAIL_SIZE),
                         min(height, THUMBNAIL_SIZE), Qt.KeepAspectRatio)
예제 #12
0
    def update_selected_path(self, uri: QUrl):
        path = uri.toLocalFile()

        if not os.path.isdir(path):
            self.drop_label.setText("Drop directory instead of files")
            return

        self.directory_path = path

        max_label_length = 40

        if len(path) > max_label_length:
            path = path[:max_label_length] + '...'

        self.drop_label.setText(path)
        self.calculate_button.setEnabled(True)
        self.drop_label.setToolTip(self.directory_path)
예제 #13
0
파일: list.py 프로젝트: ussserrr/stm32pio
 def addProjectsByPaths(self, paths: List[str]):
     """QUrl path (typically is sent from the QML GUI)"""
     if len(paths):
         for path_str in paths:  # convert to strings
             path_qurl = QUrl(path_str)
             if path_qurl.isEmpty():
                 module_logger.warning(f"Given path is empty: {path_str}")
                 continue
             elif path_qurl.isLocalFile():  # file://...
                 path: str = path_qurl.toLocalFile()
             elif path_qurl.isRelative():  # this means that the path string is not starting with 'file://' prefix
                 path: str = path_str  # just use a source string
             else:
                 module_logger.error(f"Incorrect path: {path_str}")
                 continue
             self.addListItem(path)
         self.saveInSettings()  # save after all
     else:
         module_logger.warning("No paths were given")