Fix pylint errors

This commit is contained in:
Cédric Leporcq 2021-11-06 16:36:56 +01:00
parent 34c9490580
commit adc738cab3
4 changed files with 11 additions and 10 deletions

View File

@ -133,7 +133,7 @@ class Sqlite:
else: else:
return False return False
def _run_many(self, query): def _run_many(self, query, table_list):
self.cur.executemany(query, table_list) self.cur.executemany(query, table_list)
if self.cur.fetchone()[0] != 1: if self.cur.fetchone()[0] != 1:
return False return False
@ -207,7 +207,7 @@ class Sqlite:
def build_table(self, table, row_data, primary_keys): def build_table(self, table, row_data, primary_keys):
header = self.get_header(row_data) header = self.get_header(row_data)
create_table(table, row_data, primary_keys) return self.create_table(table, row_data, primary_keys)
def build_row(self, table, row_data): def build_row(self, table, row_data):
""" """

View File

@ -6,6 +6,7 @@ import atexit
import json import json
import logging import logging
import os import os
from pathlib import Path
import re import re
import shutil import shutil
import subprocess import subprocess
@ -62,6 +63,7 @@ class _ExifToolProc:
exiftool: optional path to exiftool binary (if not provided, will search path to find it)""" exiftool: optional path to exiftool binary (if not provided, will search path to find it)"""
self.logger = logger.getChild(self.__class__.__name__) self.logger = logger.getChild(self.__class__.__name__)
self._exiftool = exiftool or get_exiftool_path()
if hasattr(self, "_process_running") and self._process_running: if hasattr(self, "_process_running") and self._process_running:
# already running # already running
if exiftool is not None and exiftool != self._exiftool: if exiftool is not None and exiftool != self._exiftool:
@ -72,7 +74,6 @@ class _ExifToolProc:
return return
self._process_running = False self._process_running = False
self._exiftool = exiftool or get_exiftool_path()
self._start_proc() self._start_proc()
@property @property
@ -399,7 +400,7 @@ class ExifToolCaching(ExifTool):
Creates a singleton cached ExifTool instance""" Creates a singleton cached ExifTool instance"""
_singletons = {} _singletons: dict[Path, ExifTool] = {}
def __new__(cls, filepath, exiftool=None, logger=logging.getLogger()): def __new__(cls, filepath, exiftool=None, logger=logging.getLogger()):
"""create new object or return instance of already created singleton""" """create new object or return instance of already created singleton"""

View File

@ -106,7 +106,6 @@ class Images:
def get_images_hashes(self): def get_images_hashes(self):
"""Get image hashes""" """Get image hashes"""
hashes = {}
# Searching for duplicates. # Searching for duplicates.
for image in self.images: for image in self.images:
with img.open(image.img_path) as img: with img.open(image.img_path) as img:
@ -115,7 +114,8 @@ class Images:
def find_duplicates(self, img_path): def find_duplicates(self, img_path):
"""Find duplicates""" """Find duplicates"""
duplicates = [] duplicates = []
for temp_hash in get_images_hashes(): hashes = {}
for temp_hash in self.get_images_hashes():
if temp_hash in hashes: if temp_hash in hashes:
self.logger.info( self.logger.info(
"Duplicate {} \nfound for image {}\n".format( "Duplicate {} \nfound for image {}\n".format(
@ -140,7 +140,7 @@ class Images:
answer = input(f"Do you want to delete these {duplicates} images? Y/n: ") answer = input(f"Do you want to delete these {duplicates} images? Y/n: ")
if answer.strip().lower() == 'y': if answer.strip().lower() == 'y':
self.remove_duplicates(duplicates) self.remove_duplicates(duplicates)
self.logger.info(f'{duplicate} deleted successfully!') self.logger.info('Duplicates images deleted successfully!')
else: else:
self.logger.info("No duplicates found") self.logger.info("No duplicates found")

View File

@ -2,7 +2,7 @@
Media :class:`Media` class to get file metadata Media :class:`Media` class to get file metadata
""" """
from dateutil.parser import parse from dateutil import parser
import inquirer import inquirer
import logging import logging
import mimetypes import mimetypes
@ -166,8 +166,8 @@ class Media:
regex = re.compile(r'(\d{4}):(\d{2}):(\d{2})') regex = re.compile(r'(\d{4}):(\d{2}):(\d{2})')
if re.match(regex, value) is not None: # noqa if re.match(regex, value) is not None: # noqa
value = re.sub(regex, r'\g<1>-\g<2>-\g<3>', value) value = re.sub(regex, r'\g<1>-\g<2>-\g<3>', value)
return parse(value) return parser.parse(value)
except BaseException or dateutil.parser._parser.ParserError as e: except BaseException or parser._parser.ParserError as e:
self.logger.warning(e.args, value) self.logger.warning(e.args, value)
return None return None