1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-22 06:37:17 +00:00

Format files with black

- Format all files with black
- Update tox.ini flake8 arguments to be compatible
- Add black to requirements-extra.txt
- Reduce ignored flake8 rules and fix a few violations
This commit is contained in:
2019-12-31 20:16:27 -06:00
parent 359d6498f7
commit 7ba8aa3514
141 changed files with 5241 additions and 3648 deletions

View File

@@ -6,7 +6,7 @@
# which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html
from ._block_qt import getblocks # NOQA
from ._block_qt import getblocks # NOQA
# Converted to C
# def getblock(image):

View File

@@ -6,13 +6,20 @@
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QVBoxLayout, QAbstractItemView, QHBoxLayout, QLabel, QSizePolicy
from PyQt5.QtWidgets import (
QVBoxLayout,
QAbstractItemView,
QHBoxLayout,
QLabel,
QSizePolicy,
)
from hscommon.trans import trget
from ..details_dialog import DetailsDialog as DetailsDialogBase
from ..details_table import DetailsTable
tr = trget('ui')
tr = trget("ui")
class DetailsDialog(DetailsDialogBase):
def __init__(self, parent, app):
@@ -33,7 +40,9 @@ class DetailsDialog(DetailsDialogBase):
sizePolicy = QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.selectedImage.sizePolicy().hasHeightForWidth())
sizePolicy.setHeightForWidth(
self.selectedImage.sizePolicy().hasHeightForWidth()
)
self.selectedImage.setSizePolicy(sizePolicy)
self.selectedImage.setScaledContents(False)
self.selectedImage.setAlignment(Qt.AlignCenter)
@@ -42,7 +51,9 @@ class DetailsDialog(DetailsDialogBase):
sizePolicy = QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.referenceImage.sizePolicy().hasHeightForWidth())
sizePolicy.setHeightForWidth(
self.referenceImage.sizePolicy().hasHeightForWidth()
)
self.referenceImage.setSizePolicy(sizePolicy)
self.referenceImage.setAlignment(Qt.AlignCenter)
self.horizontalLayout.addWidget(self.referenceImage)
@@ -77,18 +88,22 @@ class DetailsDialog(DetailsDialogBase):
def _updateImages(self):
if self.selectedPixmap is not None:
target_size = self.selectedImage.size()
scaledPixmap = self.selectedPixmap.scaled(target_size, Qt.KeepAspectRatio, Qt.SmoothTransformation)
scaledPixmap = self.selectedPixmap.scaled(
target_size, Qt.KeepAspectRatio, Qt.SmoothTransformation
)
self.selectedImage.setPixmap(scaledPixmap)
else:
self.selectedImage.setPixmap(QPixmap())
if self.referencePixmap is not None:
target_size = self.referenceImage.size()
scaledPixmap = self.referencePixmap.scaled(target_size, Qt.KeepAspectRatio, Qt.SmoothTransformation)
scaledPixmap = self.referencePixmap.scaled(
target_size, Qt.KeepAspectRatio, Qt.SmoothTransformation
)
self.referenceImage.setPixmap(scaledPixmap)
else:
self.referenceImage.setPixmap(QPixmap())
#--- Override
# --- Override
def resizeEvent(self, event):
self._updateImages()
@@ -101,4 +116,3 @@ class DetailsDialog(DetailsDialogBase):
DetailsDialogBase.refresh(self)
if self.isVisible():
self._update()

View File

@@ -12,6 +12,7 @@ from core.pe.photo import Photo as PhotoBase
from .block import getblocks
class File(PhotoBase):
def _plat_get_dimensions(self):
try:
@@ -53,4 +54,3 @@ class File(PhotoBase):
t.rotate(270)
image = image.transformed(t)
return getblocks(image, block_count_per_side)

View File

@@ -12,23 +12,33 @@ from core.app import AppMode
from ..preferences_dialog import PreferencesDialogBase
tr = trget('ui')
tr = trget("ui")
class PreferencesDialog(PreferencesDialogBase):
def _setupPreferenceWidgets(self):
self._setupFilterHardnessBox()
self.widgetsVLayout.addLayout(self.filterHardnessHLayout)
self._setupAddCheckbox('matchScaledBox', tr("Match pictures of different dimensions"))
self._setupAddCheckbox(
"matchScaledBox", tr("Match pictures of different dimensions")
)
self.widgetsVLayout.addWidget(self.matchScaledBox)
self._setupAddCheckbox('mixFileKindBox', tr("Can mix file kind"))
self._setupAddCheckbox("mixFileKindBox", tr("Can mix file kind"))
self.widgetsVLayout.addWidget(self.mixFileKindBox)
self._setupAddCheckbox('useRegexpBox', tr("Use regular expressions when filtering"))
self._setupAddCheckbox(
"useRegexpBox", tr("Use regular expressions when filtering")
)
self.widgetsVLayout.addWidget(self.useRegexpBox)
self._setupAddCheckbox('removeEmptyFoldersBox', tr("Remove empty folders on delete or move"))
self._setupAddCheckbox(
"removeEmptyFoldersBox", tr("Remove empty folders on delete or move")
)
self.widgetsVLayout.addWidget(self.removeEmptyFoldersBox)
self._setupAddCheckbox('ignoreHardlinkMatches', tr("Ignore duplicates hardlinking to the same file"))
self._setupAddCheckbox(
"ignoreHardlinkMatches",
tr("Ignore duplicates hardlinking to the same file"),
)
self.widgetsVLayout.addWidget(self.ignoreHardlinkMatches)
self._setupAddCheckbox('debugModeBox', tr("Debug mode (restart required)"))
self._setupAddCheckbox("debugModeBox", tr("Debug mode (restart required)"))
self.widgetsVLayout.addWidget(self.debugModeBox)
self.widgetsVLayout.addWidget(QLabel(tr("Picture cache mode:")))
self.cacheTypeRadio = RadioBox(self, items=["Sqlite", "Shelve"], spread=False)
@@ -37,7 +47,9 @@ class PreferencesDialog(PreferencesDialogBase):
def _load(self, prefs, setchecked):
setchecked(self.matchScaledBox, prefs.match_scaled)
self.cacheTypeRadio.selected_index = 1 if prefs.picture_cache_type == 'shelve' else 0
self.cacheTypeRadio.selected_index = (
1 if prefs.picture_cache_type == "shelve" else 0
)
# Update UI state based on selected scan type
scan_type = prefs.get_scan_type(AppMode.Picture)
@@ -46,5 +58,6 @@ class PreferencesDialog(PreferencesDialogBase):
def _save(self, prefs, ischecked):
prefs.match_scaled = ischecked(self.matchScaledBox)
prefs.picture_cache_type = 'shelve' if self.cacheTypeRadio.selected_index == 1 else 'sqlite'
prefs.picture_cache_type = (
"shelve" if self.cacheTypeRadio.selected_index == 1 else "sqlite"
)

View File

@@ -7,17 +7,17 @@
from qtlib.column import Column
from ..results_model import ResultsModel as ResultsModelBase
class ResultsModel(ResultsModelBase):
COLUMNS = [
Column('marked', defaultWidth=30),
Column('name', defaultWidth=200),
Column('folder_path', defaultWidth=180),
Column('size', defaultWidth=60),
Column('extension', defaultWidth=40),
Column('dimensions', defaultWidth=100),
Column('exif_timestamp', defaultWidth=120),
Column('mtime', defaultWidth=120),
Column('percentage', defaultWidth=60),
Column('dupe_count', defaultWidth=80),
Column("marked", defaultWidth=30),
Column("name", defaultWidth=200),
Column("folder_path", defaultWidth=180),
Column("size", defaultWidth=60),
Column("extension", defaultWidth=40),
Column("dimensions", defaultWidth=100),
Column("exif_timestamp", defaultWidth=120),
Column("mtime", defaultWidth=120),
Column("percentage", defaultWidth=60),
Column("dupe_count", defaultWidth=80),
]