diff --git a/Makefile b/Makefile index bc04140..c7a619b 100644 --- a/Makefile +++ b/Makefile @@ -78,7 +78,7 @@ clean-build: ## remove build artifacts rm -rfv tests/TESTINGDIR lint: ## run linters on codebase - pip install --upgrade --force-reinstall --pre torrentfile + pip install --upgrade --force-reinstall --pre --no-cache torrentfile isort torrentfileQt tests pyroma . prospector torrentfileQt diff --git a/coverage.xml b/coverage.xml index 5a119fc..00f17ec 100644 --- a/coverage.xml +++ b/coverage.xml @@ -1,5 +1,5 @@ - + diff --git a/torrentfileQt/checkTab.py b/torrentfileQt/checkTab.py index 30af7ee..ed64208 100644 --- a/torrentfileQt/checkTab.py +++ b/torrentfileQt/checkTab.py @@ -21,28 +21,17 @@ import logging import os import re -from collections.abc import Sequence +# from collections.abc import Sequence from pathlib import Path from PySide6.QtCore import Qt, Signal from PySide6.QtGui import QIcon, QTextOption -from PySide6.QtWidgets import ( - QFileDialog, - QFormLayout, - QHBoxLayout, - QLabel, - QLineEdit, - QPlainTextEdit, - QProgressBar, - QPushButton, - QSplitter, - QToolButton, - QTreeWidget, - QTreeWidgetItem, - QVBoxLayout, - QWidget, -) -from torrentfile.progress import CheckerClass +from PySide6.QtWidgets import (QFileDialog, QFormLayout, QHBoxLayout, QLabel, + QLineEdit, QPlainTextEdit, QProgressBar, + QPushButton, QSplitter, QToolButton, + QTreeWidget, QTreeWidgetItem, QVBoxLayout, + QWidget) +from torrentfile.recheck import Checker def _conf(): @@ -150,7 +139,7 @@ def submit(self): metafile = fileInput.text() content = searchInput.text() if os.path.exists(metafile): - CheckerClass.register_callback(textEdit.callback) + Checker.register_callback(textEdit.callback) logging.debug("Registering Callback, setting root") tree.reChecking.emit(metafile, content) @@ -214,7 +203,8 @@ class BrowseFolders(QToolButton): def __init__(self, parent=None): """Construct a BrowseFolders Button Widget.""" super().__init__(parent=parent) - self.window = parent + self.window = parent.window + self.widget = parent self.setCursor(Qt.CursorShape.PointingHandCursor) self.mode = None self.clicked.connect(self.browse) @@ -236,12 +226,13 @@ def browse(self, path=None): if not path: # pragma: no cover mode = self.modes[self.mode] path = mode["func"](parent=self, **mode["kwargs"]) - if isinstance(path, Sequence): + if not isinstance(path, str): path, _ = path + if path: path = os.path.normpath(path) - self.parent().searchInput.clear() - self.parent().searchInput.setText(path) + self.widget.searchInput.clear() + self.widget.searchInput.setText(path) class LogTextEdit(QPlainTextEdit): @@ -354,7 +345,7 @@ def __init__(self, parent=None): super().__init__(parent=parent) self.window = parent.window self.setColumnCount(3) - self.setIndentation(10) + self.setIndentation(15) self.item = self.invisibleRootItem() self.item.setExpanded(True) header = self.header() @@ -446,7 +437,7 @@ def __init__(self, metafile, content, tree): self.metafile = metafile self.content = content self.tree = tree - self.checker = CheckerClass(metafile, content) + self.checker = Checker(metafile, content) self.root = os.path.dirname(self.checker.root) self.fileinfo = self.checker.fileinfo self.pathlist = self.checker.paths @@ -454,12 +445,12 @@ def __init__(self, metafile, content, tree): def addTreeWidgets(self): """Add tree widgets items to tree widget.""" - for path in self.pathlist: - if path == self.root: + for _, val in self.fileinfo.items(): + if val["path"] == self.root: relpath = os.path.dirname(self.root) # pragma: no cover else: - relpath = os.path.relpath(path, self.root) - length = self.fileinfo[path]["length"] + relpath = os.path.relpath(val["path"], self.root) + length = val["length"] self.tree.addPathChild.emit(relpath, length) def iter_hashes(self): diff --git a/torrentfileQt/createTab.py b/torrentfileQt/createTab.py index 1d08b71..a0a7179 100644 --- a/torrentfileQt/createTab.py +++ b/torrentfileQt/createTab.py @@ -28,21 +28,10 @@ from pathlib import Path from PySide6.QtCore import Qt -from PySide6.QtWidgets import ( - QCheckBox, - QComboBox, - QFileDialog, - QGridLayout, - QHBoxLayout, - QLabel, - QLineEdit, - QPlainTextEdit, - QPushButton, - QRadioButton, - QSpacerItem, - QToolButton, - QWidget, -) +from PySide6.QtWidgets import (QCheckBox, QComboBox, QFileDialog, QGridLayout, + QHBoxLayout, QLabel, QLineEdit, QPlainTextEdit, + QPushButton, QRadioButton, QSpacerItem, + QToolButton, QWidget) from torrentfile.utils import path_piece_length from torrentfileQt.qss import pushButtonEdit @@ -74,8 +63,8 @@ def __init__(self, parent=None): self.hlayout3 = QHBoxLayout() self.hlayout0 = QHBoxLayout() - self.path_label = QLabel("Path: ", parent=self) - self.output_label = QLabel("Save Path: ", parent=self) + self.path_label = QLabel("Torrent Content: ", parent=self) + self.output_label = QLabel("Save Location: ", parent=self) self.version_label = QLabel("Meta Version: ", parent=self) self.comment_label = QLabel("Comment: ", parent=self) self.announce_label = QLabel("Trackers: ", parent=self) diff --git a/torrentfileQt/editorTab.py b/torrentfileQt/editorTab.py index 0fdbecf..be27b16 100644 --- a/torrentfileQt/editorTab.py +++ b/torrentfileQt/editorTab.py @@ -23,18 +23,9 @@ import pyben from PySide6.QtCore import Qt, Signal -from PySide6.QtWidgets import ( - QFileDialog, - QHBoxLayout, - QLabel, - QLineEdit, - QPushButton, - QTableWidget, - QTableWidgetItem, - QToolButton, - QVBoxLayout, - QWidget, -) +from PySide6.QtWidgets import (QFileDialog, QHBoxLayout, QLabel, QLineEdit, + QPushButton, QTableWidget, QTableWidgetItem, + QToolButton, QVBoxLayout, QWidget) class EditorWidget(QWidget): diff --git a/torrentfileQt/infoTab.py b/torrentfileQt/infoTab.py index 428602f..eb3c070 100644 --- a/torrentfileQt/infoTab.py +++ b/torrentfileQt/infoTab.py @@ -27,16 +27,9 @@ import pyben from PySide6.QtCore import Qt, Signal from PySide6.QtGui import QIcon -from PySide6.QtWidgets import ( - QFileDialog, - QGridLayout, - QLabel, - QLineEdit, - QPushButton, - QTreeWidget, - QTreeWidgetItem, - QWidget, -) +from PySide6.QtWidgets import (QFileDialog, QGridLayout, QLabel, QLineEdit, + QPushButton, QTreeWidget, QTreeWidgetItem, + QWidget) from torrentfileQt.qss import infoLineEdit diff --git a/torrentfileQt/qss.py b/torrentfileQt/qss.py index 30c01ee..ab1c378 100644 --- a/torrentfileQt/qss.py +++ b/torrentfileQt/qss.py @@ -19,10 +19,6 @@ """Module for stylesheets.""" import os -arrow = os.path.join(os.environ["ASSETS"], "icons", "down-arrow16.png").replace( - "\\", "/" -) - stylesheet = ( """ * { @@ -535,7 +531,8 @@ }""" + f""" QComboBox::down-arrow {{ - image: url({arrow}); + image: url({os.path.join(os.environ["ASSETS"], "icons", + "down-arrow16.png")}); }} """ ) diff --git a/torrentfileQt/window.py b/torrentfileQt/window.py index e16d07c..82ac3f1 100644 --- a/torrentfileQt/window.py +++ b/torrentfileQt/window.py @@ -22,7 +22,8 @@ import sys from PySide6.QtGui import QIcon -from PySide6.QtWidgets import QApplication, QMainWindow, QTabWidget, QVBoxLayout +from PySide6.QtWidgets import (QApplication, QMainWindow, QTabWidget, + QVBoxLayout) from torrentfileQt.checkTab import CheckWidget from torrentfileQt.createTab import CreateWidget