[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2023-04-17 21:08:37 +00:00
parent a113179e48
commit 8d8e171b81

View file

@ -1,13 +1,15 @@
import os
from multiprocessing import Pool, cpu_count
from itertools import repeat
from fnmatch import fnmatch
from itertools import repeat
from multiprocessing import cpu_count
from multiprocessing import Pool
from modules import util
logger = util.logger
_config = None
class RemoveOrphaned:
def __init__(self, qbit_manager):
self.qbt = qbit_manager
@ -49,7 +51,6 @@ class RemoveOrphaned:
if self.orphaned_dir not in path
]
# Get an updated list of torrents
logger.print_line("Removing torrent files from orphans", self.config.loglevel)
torrent_list = self.qbt.get_torrents({"sort": "added_on"})
@ -70,10 +71,7 @@ class RemoveOrphaned:
for exclude_pattern in self.config.orphaned["exclude_patterns"]
]
excluded_orphan_files = [
file
for file in orphaned_files
for exclude_pattern in exclude_patterns
if fnmatch(file, exclude_pattern)
file for file in orphaned_files for exclude_pattern in exclude_patterns if fnmatch(file, exclude_pattern)
]
orphaned_files = set(orphaned_files) - set(excluded_orphan_files)
@ -103,7 +101,7 @@ class RemoveOrphaned:
# Delete empty directories after moving orphan files
logger.info("Cleaning up any empty directories...")
if not self.config.dry_run:
with Pool(processes = cpu_count()) as pool:
with Pool(processes=cpu_count()) as pool:
orphaned_parent_path = set(pool.map(move_orphan, orphaned_files))
logger.print_line("Removing orphan dirs", self.config.loglevel)
@ -111,6 +109,7 @@ class RemoveOrphaned:
else:
logger.print_line("No Orphaned Files found.", self.config.loglevel)
def move_orphan(file):
src = file.replace(_config.root_dir, _config.remote_dir) # Could be optimized to only run when root != remote
dest = os.path.join(_config.orphaned_dir, file.replace(_config.root_dir, ""))