Skip to content

Commit

Permalink
generate report regarding sidecar files
Browse files Browse the repository at this point in the history
  • Loading branch information
qlyoung committed Nov 17, 2023
1 parent 4fdbaed commit 04789d0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/phockup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from src.date import Date
from src.exif import Exif
from pprint import pprint

logger = logging.getLogger('phockup')
ignored_files = ('.DS_Store', 'Thumbs.db')
Expand Down Expand Up @@ -45,6 +46,8 @@ def __init__(self, input_dir, output_dir, **args):
if output_dir.endswith(os.path.sep):
output_dir = output_dir[:-1]

self.skipped_for_later = set()
self.handled_as_sidecar = set()
self.input_dir = input_dir
self.output_dir = output_dir
self.output_prefix = args.get('output_prefix' or None)
Expand Down Expand Up @@ -113,6 +116,12 @@ def print_action_report(self, run_time):
logger.info(f"Would have moved {self.files_moved} files.")
else:
logger.info(f"Moved {self.files_moved} files.")
logger.info(f"Files ignored as sidecars ({len(self.skipped_for_later)}):")
pprint(self.skipped_for_later)
logger.info(f"Files processed as sidecars ({len(self.handled_as_sidecar)}):")
pprint(self.handled_as_sidecar)
logger.info("Files ignored as sidecars and not handled as sidecars:")
pprint(list(self.skipped_for_later - self.handled_as_sidecar))

def check_directories(self):
"""
Expand Down Expand Up @@ -258,6 +267,7 @@ def process_file(self, filename):
If file is a sidecar skip it so process_sidecars method can handle it
"""
if any([filename.lower().endswith(sc_ext) for sc_ext in self.sidecar_extensions]):
self.skipped_for_later.add(filename)
return None

progress = f'{filename}'
Expand Down Expand Up @@ -384,6 +394,7 @@ def process_sidecars(self, original_filename, file_name, suffix, output):

# Perform the move
for original, target in sidecars:
self.handled_as_sidecar.add(original)
sidecar_path = os.path.sep.join([output, target])
logger.info(f"{original} => {sidecar_path}")

Expand Down

0 comments on commit 04789d0

Please sign in to comment.