From 9dacc632e7d3adbbf5d44ab9c44632696d4d347c Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 16 Jan 2022 17:17:51 -0800 Subject: [PATCH 1/3] fixed announce list bug --- Makefile | 20 +++-- coverage.xml | 157 +++++++++++++++++++++---------------- tests/test_createTab.py | 2 +- tests/test_infotab.py | 6 +- torrentfileQt/createTab.py | 106 +++++++++++++++++-------- torrentfileQt/infoTab.py | 4 +- torrentfileQt/qss.py | 40 ++++------ 7 files changed, 192 insertions(+), 143 deletions(-) diff --git a/Makefile b/Makefile index 9422e9d..6ecafa4 100644 --- a/Makefile +++ b/Makefile @@ -65,21 +65,19 @@ upgrade: clean ## upgrade all dependencies pip install --upgrade --pre -rrequirements.txt clean-build: ## remove build artifacts - rm -fr build/ - rm -fr dist/ - rm -fr .eggs/ - rm -fr .tox/ - rm -f .coverage - rm -fr htmlcov/ + rm -frv build/ + rm -frv dist/ + rm -frv .eggs/ + rm -frv .tox/ + rm -fv .coverage + rm -frv htmlcov/ rm -rfv */__pycache__ - rm -f corbertura.xml - rm -fr .pytest_cache - rm -rf *.egg-info + rm -fv corbertura.xml + rm -frv .pytest_cache + rm -rfv *.egg-info rm -rfv tests/TESTINGDIR lint: ## run linters on codebase - pip install --upgrade --force-reinstall --pre --no-cache torrentfile - isort torrentfileQt tests pyroma . prospector torrentfileQt prospector tests diff --git a/coverage.xml b/coverage.xml index 1cfb508..82d52af 100644 --- a/coverage.xml +++ b/coverage.xml @@ -1,5 +1,5 @@ - + @@ -458,7 +458,7 @@ - + @@ -767,43 +767,43 @@ - + - + - + - - - - + + + + - + - + + - + - @@ -811,14 +811,14 @@ + - + - @@ -826,9 +826,9 @@ + - @@ -837,9 +837,9 @@ + - @@ -871,19 +871,21 @@ - - - - - - - + + + + + + + + + + - @@ -894,101 +896,119 @@ - + - - + + - + - + + - + - - - + - - - - + + + + + - + + - - - + - + + + + - - - - + - + + - + + - - - + - + + + + - - - - + + - - + - - + + + - + + - - - + + + + + + + + + + + + + + + + + + + + @@ -1424,10 +1444,9 @@ - - - - + + + diff --git a/tests/test_createTab.py b/tests/test_createTab.py index 2cc4998..ea8e58c 100644 --- a/tests/test_createTab.py +++ b/tests/test_createTab.py @@ -96,7 +96,7 @@ def test_create_tab_dir(dir2, wind): "field", [ "announce", - "announce list", + "announce-list", "source", "private", "comment", diff --git a/tests/test_infotab.py b/tests/test_infotab.py index 52b1239..036d32b 100644 --- a/tests/test_infotab.py +++ b/tests/test_infotab.py @@ -49,7 +49,7 @@ def test_infotab_select2(wind, dir2, creator): torrent = creator(path=dir2) del torrent.meta["created by"] del torrent.meta["creation date"] - del torrent.meta["announce list"] + del torrent.meta["announce-list"] outfile, _ = torrent.write() infotab = window.central.infoWidget app.processEvents() @@ -72,7 +72,7 @@ def test_infotab_single(wind, creator, size): torrent = creator(path=tfile) del torrent.meta["created by"] del torrent.meta["creation date"] - del torrent.meta["announce list"] + del torrent.meta["announce-list"] outfile, _ = torrent.write() infotab = window.central.infoWidget app.processEvents() @@ -93,7 +93,7 @@ def test_infotab_nested(wind, creator, dir3): torrent = creator(path=dir3) del torrent.meta["created by"] del torrent.meta["creation date"] - del torrent.meta["announce list"] + del torrent.meta["announce-list"] outfile, _ = torrent.write() infotab = window.central.infoWidget app.processEvents() diff --git a/torrentfileQt/createTab.py b/torrentfileQt/createTab.py index 793619a..06b43f7 100644 --- a/torrentfileQt/createTab.py +++ b/torrentfileQt/createTab.py @@ -22,6 +22,7 @@ User must provide the path to the directory containing the what the .torrent file will be created from. """ +import json import os from pathlib import Path from threading import Thread @@ -62,27 +63,33 @@ def __init__(self, parent=None): self.hlayout2 = QHBoxLayout() self.hlayout3 = QHBoxLayout() self.hlayout0 = QHBoxLayout() + # self.hlayout4 = QHBoxLayout() - self.path_label = QLabel("Torrent Content: ", parent=self) - self.output_label = QLabel("Save Location: ", parent=self) + self.path_label = QLabel("Path: ", parent=self) + self.output_label = QLabel("Save To: ", parent=self) self.version_label = QLabel("Meta Version: ", parent=self) self.comment_label = QLabel("Comment: ", parent=self) - self.announce_label = QLabel("Trackers: ", parent=self) + self.announce_label = QLabel("Tracker URLs: ", parent=self) + # self.profile_label = QLabel("Profile: ", parent=self) + self.web_seed_label = QLabel("Web-seed URLs:") self.source_label = QLabel("Source: ", parent=self) - self.piece_length_label = QLabel("Piece Length: ", parent=self) + self.piece_length_label = QLabel("Piece Size: ", parent=self) self.path_input = QLineEdit(parent=self) self.output_input = QLineEdit(parent=self) self.source_input = QLineEdit(parent=self) self.comment_input = QLineEdit(parent=self) + # self.profile_input = ComboBox.profiles(parent=self) self.announce_input = QPlainTextEdit(parent=self) - self.piece_length = ComboBox(parent=self) + self.web_seed_input = QPlainTextEdit(parent=self) + self.piece_length = ComboBox.piece_length(parent=self) self.private = QCheckBox("Private", parent=self) self.submit_button = SubmitButton("Create Torrent", parent=self) self.browse_dir_button = BrowseDirButton(parent=self) self.browse_file_button = BrowseFileButton(parent=self) self.output_button = OutButton(parent=self) + # self.profile_button = ProfileButton(parent=self) self.v1button = QRadioButton("v1 (default)", parent=self) self.v1button.setChecked(True) @@ -91,17 +98,17 @@ def __init__(self, parent=None): self.spacer1 = QSpacerItem(150, 0) self.spacer2 = QSpacerItem(70, 0) - self.path_label.setAlignment(Qt.AlignmentFlag.AlignLeft) + # self.profile_label.setAlignment(Qt.AlignmentFlag.AlignRight) + self.path_label.setAlignment(Qt.AlignmentFlag.AlignRight) self.path_input.setAlignment(Qt.AlignmentFlag.AlignLeft) - self.output_label.setAlignment(Qt.AlignmentFlag.AlignLeft) + self.output_label.setAlignment(Qt.AlignmentFlag.AlignRight) self.output_input.setAlignment(Qt.AlignmentFlag.AlignLeft) - self.version_label.setAlignment(Qt.AlignmentFlag.AlignLeft) - self.source_label.setAlignment(Qt.AlignmentFlag.AlignLeft) + self.version_label.setAlignment(Qt.AlignmentFlag.AlignRight) + self.source_label.setAlignment(Qt.AlignmentFlag.AlignRight) self.source_input.setAlignment(Qt.AlignmentFlag.AlignLeft) - self.comment_label.setAlignment(Qt.AlignmentFlag.AlignLeft) + self.comment_label.setAlignment(Qt.AlignmentFlag.AlignRight) self.comment_input.setAlignment(Qt.AlignmentFlag.AlignLeft) - self.announce_label.setAlignment(Qt.AlignmentFlag.AlignLeft) - self.piece_length_label.setAlignment(Qt.AlignmentFlag.AlignLeft) + self.piece_length_label.setAlignment(Qt.AlignmentFlag.AlignRight) self.hlayout0.addWidget(self.v1button) self.hlayout0.addWidget(self.v2button) @@ -114,23 +121,29 @@ def __init__(self, parent=None): self.hlayout2.addItem(self.spacer2) self.hlayout3.addWidget(self.output_input) self.hlayout3.addWidget(self.output_button) - - self.layout.addWidget(self.path_label, 0, 0, 2, 1) - self.layout.addWidget(self.path_input, 0, 1, 1, 3) - self.layout.addLayout(self.hlayout1, 1, 1, 1, 3) - self.layout.addWidget(self.version_label, 4, 0, 1, 1) - self.layout.addLayout(self.hlayout0, 4, 1, 1, 3) - self.layout.addWidget(self.piece_length_label, 3, 0, 1, 1) - self.layout.addLayout(self.hlayout2, 3, 1, 1, 3) - self.layout.addWidget(self.output_label, 2, 0, 1, 1) - self.layout.addLayout(self.hlayout3, 2, 1, 1, 3) - self.layout.addWidget(self.source_label, 5, 0, 1, 1) - self.layout.addWidget(self.source_input, 5, 1, 1, 3) - self.layout.addWidget(self.comment_label, 6, 0, 1, 1) - self.layout.addWidget(self.comment_input, 6, 1, 1, 3) - self.layout.addWidget(self.announce_label, 7, 0, 1, 1) - self.layout.addWidget(self.announce_input, 7, 1, 1, 3) - self.layout.addWidget(self.submit_button, 8, 0, 1, 4) + # self.hlayout4.addWidget(self.profile_input) + # self.hlayout4.addWidget(self.profile_button) + + # self.layout.addWidget(self.profile_label,0,0,1,1) + # self.layout.addLayout(self.hlayout4,0,1,1,1) + self.layout.addWidget(self.path_label, 1, 0, 2, 1) + self.layout.addWidget(self.path_input, 1, 1, 1, 3) + self.layout.addLayout(self.hlayout1, 2, 1, 1, 3) + self.layout.addWidget(self.version_label, 5, 0, 1, 1) + self.layout.addLayout(self.hlayout0, 5, 1, 1, 3) + self.layout.addWidget(self.piece_length_label, 4, 0, 1, 1) + self.layout.addLayout(self.hlayout2, 4, 1, 1, 3) + self.layout.addWidget(self.output_label, 3, 0, 1, 1) + self.layout.addLayout(self.hlayout3, 3, 1, 1, 3) + self.layout.addWidget(self.source_label, 9, 0, 1, 1) + self.layout.addWidget(self.source_input, 9, 1, 1, 3) + self.layout.addWidget(self.comment_label, 8, 0, 1, 1) + self.layout.addWidget(self.comment_input, 8, 1, 1, 3) + self.layout.addWidget(self.announce_label, 6, 0, 1, 1) + self.layout.addWidget(self.announce_input, 6, 1, 1, 3) + self.layout.addWidget(self.web_seed_label, 7, 0, 1, 1) + self.layout.addWidget(self.web_seed_input, 7, 1, 1, 3) + self.layout.addWidget(self.submit_button, 10, 0, 1, 4) for i in range(1, self.layout.columnCount()): self.layout.setColumnStretch(i, 1) self.layout.setObjectName("createWidget_formLayout") @@ -321,6 +334,16 @@ def browse(self, path=None): break +class ProfileButton(QPushButton): + """Save the current fields values as a profile.""" + + def __init__(self, parent=None): + """Save current fields as a profile.""" + super().__init__(parent=parent) + self.setText("Save Profile") + + + class BrowseDirButton(QPushButton): """Browse filesystem folders for path.""" @@ -374,10 +397,29 @@ def __init__(self, parent=None): """Constructor for ComboBox.""" super().__init__(parent=parent) self.addItem("") - for exp in range(14, 24): + self.setEditable(False) + self.profile_data = None + + @classmethod + def profiles(cls, parent=None): + """Create a profiles combobox.""" + box = cls(parent=parent) + if os.path.exists(os.path.join(os.getcwd(), "profiles.json")): + with open("profiles.json", "rt") as js: + profs = json.load(js) + box.profile_data = profs + for name in profs: + box.addItem(name) + return box + + @classmethod + def piece_length(cls, parent=None): + """Create a piece_length combobox.""" + box = cls(parent=parent) + for exp in range(14, 26): if exp < 20: item = str((2 ** exp) // (2 ** 10)) + "KB" else: item = str((2 ** exp) // (2 ** 20)) + "MB" - self.addItem(item, 2 ** exp) - self.setEditable(False) + box.addItem(item, 2 ** exp) + return box diff --git a/torrentfileQt/infoTab.py b/torrentfileQt/infoTab.py index eb3c070..f275d7a 100644 --- a/torrentfileQt/infoTab.py +++ b/torrentfileQt/infoTab.py @@ -296,8 +296,8 @@ def selectTorrent(self, path=None): keywords[kw] = "" # extract announce list - if "announce list" in meta: - alst = [url for urlst in meta["announce list"] for url in urlst] + if "announce-list" in meta: + alst = [url for urlst in meta["announce-list"] for url in urlst] keywords["announce"] = alst + [meta["announce"]] else: keywords["announce"] = [meta["announce"]] diff --git a/torrentfileQt/qss.py b/torrentfileQt/qss.py index ab1c378..aea17d8 100644 --- a/torrentfileQt/qss.py +++ b/torrentfileQt/qss.py @@ -17,7 +17,6 @@ # limitations under the License. ############################################################################## """Module for stylesheets.""" -import os stylesheet = ( """ @@ -204,7 +203,7 @@ border-style: outset; border-color: #f51; border-width: 3px; - font-size: 11pt; + font-size: 10pt; color: #e9e7e6; padding-left: 8px; padding-right: 8px; @@ -241,7 +240,7 @@ border-width: 3px; padding-top: 4px; padding-bottom: 4px; - font: 14pt bold; + font: 13pt bold; color: #dedede; background-color: #111; } @@ -266,7 +265,7 @@ background-color: #444; } QToolButton { - font-size: 10pt; + font-size: 9pt; border-style: outset; border-color: #e67e22; border-width: 3px; @@ -284,7 +283,7 @@ } QRadioButton { background-color: transparent; - font-size: 12pt; + font-size: 11pt; border: transparent; padding-top: 2px; margin-top: 2px; @@ -315,7 +314,7 @@ QCheckBox { color: #fff; padding: 4px; - font-size: 12pt; + font-size: 11pt; border-color: transparent; } QCheckBox:disabled { @@ -396,7 +395,7 @@ border-color: #e57e22; border-width: 2px; border-style: ridge; - font-size: 12pt; + font-size: 11pt; selection-background-color: #3a3a3a; selection-color: #FFF; gridline-color: #ac4a02; @@ -407,7 +406,7 @@ } QTableWidget QHeaderView { border: 1px solid #e57e22; - font-size: 12pt; + font-size: 11pt; background-color: black; color: white; } @@ -419,17 +418,14 @@ background-color: black; margin: 2px; } - QMenu::item { padding: 2px 25px 2px 20px; border: 1px solid transparent; } - QMenu::item:selected { border-color: #e57e22; background: #333; } - QMenu::icon:checked { background: gray; border: 1px inset gray; @@ -439,21 +435,18 @@ bottom: 1px; left: 1px; } - QMenu::separator { height: 2px; background: lightblue; margin-left: 10px; margin-right: 5px; } - QMenu::indicator { width: 13px; height: 13px; } - QMenuBar { - font-size: 10pt; + font-size: 9pt; border-bottom: 3px groove #115; background:rgb(30, 30, 30); color: #FFFFFF; @@ -465,7 +458,7 @@ border-right-color: transparent; border-left-color: transparent; border-bottom-color: transparent; - font-size: 10px; + font-size: 9pt; padding: 6px; padding-top: 2px; background: transparent; @@ -491,19 +484,18 @@ padding: 4px; margin-top: 3px; margin-bottom: 3px; - font: 10pt; + font: 9pt; } QLabel { padding: 2px; padding-top: 4px; padding-bottom: 4px; - font-size: 11pt; + font-size: 10pt; font-weight: bold; } QStatusBar { border: 2px groove black; } - QComboBox { border: 2px solid #f73; padding: 1px 1px 1px 3px; @@ -528,12 +520,10 @@ QComboBox QAbstractItemView { border: 1px solid #444; selection-background-color: lightgray; - }""" - + f""" - QComboBox::down-arrow {{ - image: url({os.path.join(os.environ["ASSETS"], "icons", - "down-arrow16.png")}); - }} + } + QComboBox::down-arrow { + image: url("./assets/icons/down-arrow16.png"); + } """ ) From a7c86852181338fb009481671d100807c2403418 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 19 Jan 2022 23:07:49 -0800 Subject: [PATCH 2/3] Added commented blocks --- coverage.xml | 174 +++++++++++++++++-------------------- torrentfileQt/createTab.py | 37 ++++---- 2 files changed, 99 insertions(+), 112 deletions(-) diff --git a/coverage.xml b/coverage.xml index 82d52af..a744d7a 100644 --- a/coverage.xml +++ b/coverage.xml @@ -1,5 +1,5 @@ - + @@ -458,7 +458,7 @@ - + @@ -767,11 +767,10 @@ - + - @@ -792,21 +791,18 @@ - - + - + - - @@ -817,22 +813,20 @@ - + - - + - @@ -840,14 +834,10 @@ + - - - - - @@ -876,139 +866,137 @@ - - - - - - - - - - + + + + + + + + + + + + + + - - + + - - + + - - - - + + + - - + - + - + + - + + + - - - - - - - - - - + + + + + + + + + + - - - - - + + + + + + + - - - - - - - + - + + + + + - - - - - - + + + + - - - - - - - - - - + + + + + - - + + - - - - - + + - - - - - - + + + + + + + + + diff --git a/torrentfileQt/createTab.py b/torrentfileQt/createTab.py index 06b43f7..a0b477d 100644 --- a/torrentfileQt/createTab.py +++ b/torrentfileQt/createTab.py @@ -22,7 +22,7 @@ User must provide the path to the directory containing the what the .torrent file will be created from. """ -import json +# import json import os from pathlib import Path from threading import Thread @@ -334,14 +334,13 @@ def browse(self, path=None): break -class ProfileButton(QPushButton): - """Save the current fields values as a profile.""" - - def __init__(self, parent=None): - """Save current fields as a profile.""" - super().__init__(parent=parent) - self.setText("Save Profile") +# class ProfileButton(QPushButton): +# """Save the current fields values as a profile.""" +# def __init__(self, parent=None): +# """Save current fields as a profile.""" +# super().__init__(parent=parent) +# self.setText("Save Profile") class BrowseDirButton(QPushButton): @@ -400,17 +399,17 @@ def __init__(self, parent=None): self.setEditable(False) self.profile_data = None - @classmethod - def profiles(cls, parent=None): - """Create a profiles combobox.""" - box = cls(parent=parent) - if os.path.exists(os.path.join(os.getcwd(), "profiles.json")): - with open("profiles.json", "rt") as js: - profs = json.load(js) - box.profile_data = profs - for name in profs: - box.addItem(name) - return box + # @classmethod + # def profiles(cls, parent=None): + # """Create a profiles combobox.""" + # box = cls(parent=parent) + # if os.path.exists(os.path.join(os.getcwd(), "profiles.json")): + # with open("profiles.json", "rt") as js: + # profs = json.load(js) + # box.profile_data = profs + # for name in profs: + # box.addItem(name) + # return box @classmethod def piece_length(cls, parent=None): From 2aebfd7f63791a19f480936ddc1ee37750ee501d Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 19 Jan 2022 23:14:43 -0800 Subject: [PATCH 3/3] Added commented blocks --- coverage.xml | 39 +++++++++++++++++++------------------- tests/__init__.py | 1 + torrentfileQt/createTab.py | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/coverage.xml b/coverage.xml index a744d7a..50e7021 100644 --- a/coverage.xml +++ b/coverage.xml @@ -1,5 +1,5 @@ - + @@ -421,44 +421,44 @@ - - - + + - + - + - + - + - - + + - + - + - + - - + + + - + @@ -767,7 +767,7 @@ - + @@ -976,7 +976,6 @@ - @@ -1105,7 +1104,7 @@ - + @@ -1152,7 +1151,7 @@ - + diff --git a/tests/__init__.py b/tests/__init__.py index 14c9b07..444aeed 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -129,6 +129,7 @@ def tempdir(ext="1", files=None): f"dir{ext}/file2.mp4", f"dir{ext}/file3.mp3", f"dir{ext}/file4.zip", + f"dir{ext}/file5.r01", ] paths = [] for path in files: diff --git a/torrentfileQt/createTab.py b/torrentfileQt/createTab.py index a0b477d..13d3508 100644 --- a/torrentfileQt/createTab.py +++ b/torrentfileQt/createTab.py @@ -380,7 +380,7 @@ def browse(self, path=None): return if piece_length < (2 ** 20): val = f"{piece_length//(2**10)}KB" - else: + else: # pragma: no cover val = f"{piece_length//(2**20)}MB" for i in range(self.window.piece_length.count()): if self.window.piece_length.itemText(i) == val: