mirror of
				https://github.com/arsenetar/dupeguru.git
				synced 2025-09-11 17:58:17 +00:00 
			
		
		
		
	fix: Linting Errors & VS Code config
- Add additional settings to VS Code for formatter changes in plugins - Fix black formatting - Fix flake8 errors due to long lines - Fix flake8 errors due to type comparisons
This commit is contained in:
		
							parent
							
								
									13dd00c798
								
							
						
					
					
						commit
						53d5ac06bf
					
				
							
								
								
									
										3
									
								
								.vscode/extensions.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.vscode/extensions.json
									
									
									
									
										vendored
									
									
								
							@ -3,7 +3,8 @@
 | 
			
		||||
    "recommendations": [
 | 
			
		||||
        "redhat.vscode-yaml",
 | 
			
		||||
        "ms-python.vscode-pylance",
 | 
			
		||||
        "ms-python.python"
 | 
			
		||||
        "ms-python.python",
 | 
			
		||||
        "ms-python.black-formatter",
 | 
			
		||||
    ],
 | 
			
		||||
    // List of extensions recommended by VS Code that should not be recommended for
 | 
			
		||||
    // users of this workspace.
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										5
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							@ -1,5 +1,4 @@
 | 
			
		||||
{
 | 
			
		||||
    "python.formatting.provider": "black",
 | 
			
		||||
    "cSpell.words": [
 | 
			
		||||
        "Dupras",
 | 
			
		||||
        "hscommon"
 | 
			
		||||
@ -10,4 +9,8 @@
 | 
			
		||||
    ],
 | 
			
		||||
    "python.languageServer": "Pylance",
 | 
			
		||||
    "yaml.schemaStore.enable": true,
 | 
			
		||||
    "[python]": {
 | 
			
		||||
        "editor.formatOnSave": true,
 | 
			
		||||
        "editor.defaultFormatter": "ms-python.black-formatter"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -187,7 +187,7 @@ class Directories:
 | 
			
		||||
        for path in self._dirs:
 | 
			
		||||
            for file in self._get_files(path, fileclasses=fileclasses, j=j):
 | 
			
		||||
                file_count += 1
 | 
			
		||||
                if type(j) != job.NullJob:
 | 
			
		||||
                if not isinstance(j, job.NullJob):
 | 
			
		||||
                    j.set_progress(-1, tr("Collected {} files to scan").format(file_count))
 | 
			
		||||
                yield file
 | 
			
		||||
 | 
			
		||||
@ -203,7 +203,7 @@ class Directories:
 | 
			
		||||
            from_folder = folderclass(path)
 | 
			
		||||
            for folder in self._get_folders(from_folder, j):
 | 
			
		||||
                folder_count += 1
 | 
			
		||||
                if type(j) != job.NullJob:
 | 
			
		||||
                if not isinstance(j, job.NullJob):
 | 
			
		||||
                    j.set_progress(-1, tr("Collected {} folders to scan").format(folder_count))
 | 
			
		||||
                yield folder
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,9 @@ class SqliteCache:
 | 
			
		||||
    schema_version = 2
 | 
			
		||||
    schema_version_description = "Added blocks for all 8 orientations."
 | 
			
		||||
 | 
			
		||||
    create_table_query = "CREATE TABLE IF NOT EXISTS pictures(path TEXT, mtime_ns INTEGER, blocks BLOB, blocks2 BLOB, blocks3 BLOB, blocks4 BLOB, blocks5 BLOB, blocks6 BLOB, blocks7 BLOB, blocks8 BLOB)"
 | 
			
		||||
    create_table_query = ("CREATE TABLE IF NOT EXISTS "
 | 
			
		||||
                          "pictures(path TEXT, mtime_ns INTEGER, blocks BLOB, blocks2 BLOB, blocks3 BLOB, "
 | 
			
		||||
                          "blocks4 BLOB, blocks5 BLOB, blocks6 BLOB, blocks7 BLOB, blocks8 BLOB)")
 | 
			
		||||
    create_index_query = "CREATE INDEX IF NOT EXISTS idx_path on pictures (path)"
 | 
			
		||||
    drop_table_query = "DROP TABLE IF EXISTS pictures"
 | 
			
		||||
    drop_index_query = "DROP INDEX IF EXISTS idx_path"
 | 
			
		||||
@ -43,9 +45,13 @@ class SqliteCache:
 | 
			
		||||
    # Optimized
 | 
			
		||||
    def __getitem__(self, key):
 | 
			
		||||
        if isinstance(key, int):
 | 
			
		||||
            sql = "select blocks, blocks2, blocks3, blocks4, blocks5, blocks6, blocks7, blocks8 from pictures where rowid = ?"
 | 
			
		||||
            sql = ("select blocks, blocks2, blocks3, blocks4, blocks5, blocks6, blocks7, blocks8 "
 | 
			
		||||
                   "from pictures "
 | 
			
		||||
                   "where rowid = ?")
 | 
			
		||||
        else:
 | 
			
		||||
            sql = "select blocks, blocks2, blocks3, blocks4, blocks5, blocks6, blocks7, blocks8 from pictures where path = ?"
 | 
			
		||||
            sql = ("select blocks, blocks2, blocks3, blocks4, blocks5, blocks6, blocks7, blocks8 "
 | 
			
		||||
                   "from pictures "
 | 
			
		||||
                   "where path = ?")
 | 
			
		||||
        blocks = self.con.execute(sql, [key]).fetchone()
 | 
			
		||||
        if blocks:
 | 
			
		||||
            result = [bytes_to_colors(block) for block in blocks]
 | 
			
		||||
@ -70,9 +76,12 @@ class SqliteCache:
 | 
			
		||||
        else:
 | 
			
		||||
            mtime = 0
 | 
			
		||||
        if path_str in self:
 | 
			
		||||
            sql = "update pictures set blocks = ?, blocks2 = ?, blocks3 = ?, blocks4 = ?, blocks5 = ?, blocks6 = ?, blocks7 = ?, blocks8 = ?, mtime_ns = ? where path = ?"
 | 
			
		||||
            sql = ("update pictures set blocks = ?, blocks2 = ?, blocks3 = ?, blocks4 = ?, blocks5 = ?, blocks6 = ?, "
 | 
			
		||||
                   "blocks7 = ?, blocks8 = ?, mtime_ns = ?"
 | 
			
		||||
                   "where path = ?")
 | 
			
		||||
        else:
 | 
			
		||||
            sql = "insert into pictures(blocks,blocks2,blocks3,blocks4,blocks5,blocks6,blocks7,blocks8,mtime_ns,path) values(?,?,?,?,?,?,?,?,?,?)"
 | 
			
		||||
            sql = ("insert into pictures(blocks,blocks2,blocks3,blocks4,blocks5,blocks6,blocks7,blocks8,mtime_ns,path) "
 | 
			
		||||
                   "values(?,?,?,?,?,?,?,?,?,?)")
 | 
			
		||||
        try:
 | 
			
		||||
            self.con.execute(sql, blocks + [mtime, path_str])
 | 
			
		||||
        except sqlite.OperationalError:
 | 
			
		||||
@ -136,9 +145,27 @@ class SqliteCache:
 | 
			
		||||
            raise ValueError(path)
 | 
			
		||||
 | 
			
		||||
    def get_multiple(self, rowids):
 | 
			
		||||
        sql = "select rowid, blocks, blocks2, blocks3, blocks4, blocks5, blocks6, blocks7, blocks8 from pictures where rowid in (%s)" % ",".join(map(str, rowids))
 | 
			
		||||
        sql = (
 | 
			
		||||
            "select rowid, blocks, blocks2, blocks3, blocks4, blocks5, blocks6, blocks7, blocks8 "
 | 
			
		||||
            f"from pictures where rowid in {",".join(map(str, rowids))}"
 | 
			
		||||
        )
 | 
			
		||||
        cur = self.con.execute(sql)
 | 
			
		||||
        return ((rowid, [bytes_to_colors(blocks), bytes_to_colors(blocks2), bytes_to_colors(blocks3), bytes_to_colors(blocks4), bytes_to_colors(blocks5), bytes_to_colors(blocks6), bytes_to_colors(blocks7), bytes_to_colors(blocks8)]) for rowid, blocks, blocks2, blocks3, blocks4, blocks5, blocks6, blocks7, blocks8 in cur)
 | 
			
		||||
        return (
 | 
			
		||||
            (
 | 
			
		||||
                rowid,
 | 
			
		||||
                [
 | 
			
		||||
                    bytes_to_colors(blocks),
 | 
			
		||||
                    bytes_to_colors(blocks2),
 | 
			
		||||
                    bytes_to_colors(blocks3),
 | 
			
		||||
                    bytes_to_colors(blocks4),
 | 
			
		||||
                    bytes_to_colors(blocks5),
 | 
			
		||||
                    bytes_to_colors(blocks6),
 | 
			
		||||
                    bytes_to_colors(blocks7),
 | 
			
		||||
                    bytes_to_colors(blocks8),
 | 
			
		||||
                ],
 | 
			
		||||
            )
 | 
			
		||||
            for rowid, blocks, blocks2, blocks3, blocks4, blocks5, blocks6, blocks7, blocks8 in cur
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def purge_outdated(self):
 | 
			
		||||
        """Go through the cache and purge outdated records.
 | 
			
		||||
 | 
			
		||||
@ -71,7 +71,10 @@ class TestCasegetwords:
 | 
			
		||||
 | 
			
		||||
    def test_unicode(self):
 | 
			
		||||
        eq_(["e", "c", "0", "a", "o", "u", "e", "u"], getwords("é ç 0 à ö û è ¤ ù"))
 | 
			
		||||
        eq_(["02", "君のこころは輝いてるかい?", "国木田花丸", "solo", "ver"], getwords("02 君のこころは輝いてるかい? 国木田花丸 Solo Ver"))
 | 
			
		||||
        eq_(
 | 
			
		||||
            ["02", "君のこころは輝いてるかい?", "国木田花丸", "solo", "ver"],
 | 
			
		||||
            getwords("02 君のこころは輝いてるかい? 国木田花丸 Solo Ver"),
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_splitter_chars(self):
 | 
			
		||||
        eq_(
 | 
			
		||||
 | 
			
		||||
@ -242,12 +242,12 @@ def test_content_scan_doesnt_put_digest_in_words_at_the_end(fake_fileexists):
 | 
			
		||||
    s = Scanner()
 | 
			
		||||
    s.scan_type = ScanType.CONTENTS
 | 
			
		||||
    f = [no("foo"), no("bar")]
 | 
			
		||||
    f[0].digest = f[0].digest_partial = f[
 | 
			
		||||
        0
 | 
			
		||||
    ].digest_samples = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
 | 
			
		||||
    f[1].digest = f[1].digest_partial = f[
 | 
			
		||||
        1
 | 
			
		||||
    ].digest_samples = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
 | 
			
		||||
    f[0].digest = f[0].digest_partial = f[0].digest_samples = (
 | 
			
		||||
        "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
 | 
			
		||||
    )
 | 
			
		||||
    f[1].digest = f[1].digest_partial = f[1].digest_samples = (
 | 
			
		||||
        "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
 | 
			
		||||
    )
 | 
			
		||||
    r = s.get_dupe_groups(f)
 | 
			
		||||
    # FIXME looks like we are missing something here?
 | 
			
		||||
    r[0]
 | 
			
		||||
 | 
			
		||||
@ -58,36 +58,44 @@ class ViewerToolBar(QToolBar):
 | 
			
		||||
            (
 | 
			
		||||
                "actionZoomIn",
 | 
			
		||||
                QKeySequence.ZoomIn,
 | 
			
		||||
                (
 | 
			
		||||
                    QIcon.fromTheme("zoom-in")
 | 
			
		||||
                    if ISLINUX and not self.parent.app.prefs.details_dialog_override_theme_icons
 | 
			
		||||
                else QIcon(QPixmap(":/" + "zoom_in")),
 | 
			
		||||
                    else QIcon(QPixmap(":/" + "zoom_in"))
 | 
			
		||||
                ),
 | 
			
		||||
                tr("Increase zoom"),
 | 
			
		||||
                controller.zoomIn,
 | 
			
		||||
            ),
 | 
			
		||||
            (
 | 
			
		||||
                "actionZoomOut",
 | 
			
		||||
                QKeySequence.ZoomOut,
 | 
			
		||||
                (
 | 
			
		||||
                    QIcon.fromTheme("zoom-out")
 | 
			
		||||
                    if ISLINUX and not self.parent.app.prefs.details_dialog_override_theme_icons
 | 
			
		||||
                else QIcon(QPixmap(":/" + "zoom_out")),
 | 
			
		||||
                    else QIcon(QPixmap(":/" + "zoom_out"))
 | 
			
		||||
                ),
 | 
			
		||||
                tr("Decrease zoom"),
 | 
			
		||||
                controller.zoomOut,
 | 
			
		||||
            ),
 | 
			
		||||
            (
 | 
			
		||||
                "actionNormalSize",
 | 
			
		||||
                tr("Ctrl+/"),
 | 
			
		||||
                (
 | 
			
		||||
                    QIcon.fromTheme("zoom-original")
 | 
			
		||||
                    if ISLINUX and not self.parent.app.prefs.details_dialog_override_theme_icons
 | 
			
		||||
                else QIcon(QPixmap(":/" + "zoom_original")),
 | 
			
		||||
                    else QIcon(QPixmap(":/" + "zoom_original"))
 | 
			
		||||
                ),
 | 
			
		||||
                tr("Normal size"),
 | 
			
		||||
                controller.zoomNormalSize,
 | 
			
		||||
            ),
 | 
			
		||||
            (
 | 
			
		||||
                "actionBestFit",
 | 
			
		||||
                tr("Ctrl+*"),
 | 
			
		||||
                (
 | 
			
		||||
                    QIcon.fromTheme("zoom-best-fit")
 | 
			
		||||
                    if ISLINUX and not self.parent.app.prefs.details_dialog_override_theme_icons
 | 
			
		||||
                else QIcon(QPixmap(":/" + "zoom_best_fit")),
 | 
			
		||||
                    else QIcon(QPixmap(":/" + "zoom_best_fit"))
 | 
			
		||||
                ),
 | 
			
		||||
                tr("Best fit"),
 | 
			
		||||
                controller.zoomBestFit,
 | 
			
		||||
            ),
 | 
			
		||||
 | 
			
		||||
@ -29,7 +29,7 @@ class File(PhotoBase):
 | 
			
		||||
    def _plat_get_blocks(self, block_count_per_side, orientation):
 | 
			
		||||
        image = QImage(str(self.path))
 | 
			
		||||
        image = image.convertToFormat(QImage.Format_RGB888)
 | 
			
		||||
        if type(orientation) != int:
 | 
			
		||||
        if not isinstance(orientation, int):
 | 
			
		||||
            logging.warning(
 | 
			
		||||
                "Orientation for file '%s' was a %s '%s', not an int.",
 | 
			
		||||
                str(self.path),
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user