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:
return False
def _run_many(self, query):
def _run_many(self, query, table_list):
self.cur.executemany(query, table_list)
if self.cur.fetchone()[0] != 1:
return False
@ -207,7 +207,7 @@ class Sqlite:
def build_table(self, table, row_data, primary_keys):
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):
"""

View File

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

View File

@ -106,7 +106,6 @@ class Images:
def get_images_hashes(self):
"""Get image hashes"""
hashes = {}
# Searching for duplicates.
for image in self.images:
with img.open(image.img_path) as img:
@ -115,7 +114,8 @@ class Images:
def find_duplicates(self, img_path):
"""Find duplicates"""
duplicates = []
for temp_hash in get_images_hashes():
hashes = {}
for temp_hash in self.get_images_hashes():
if temp_hash in hashes:
self.logger.info(
"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: ")
if answer.strip().lower() == 'y':
self.remove_duplicates(duplicates)
self.logger.info(f'{duplicate} deleted successfully!')
self.logger.info('Duplicates images deleted successfully!')
else:
self.logger.info("No duplicates found")

View File

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