From 568d1b36a631df33317dc00f27126b507c90bf51 Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Wed, 6 Jan 2021 06:56:26 -0800 Subject: [PATCH] Refactored ExportResults --- osxphotos/__main__.py | 18 +- osxphotos/photoinfo/_photoinfo_export.py | 260 +++++++++-------------- tests/search_info_test_data_10_15_7.json | 2 +- tests/test_exportresults.py | 9 +- 4 files changed, 115 insertions(+), 174 deletions(-) diff --git a/osxphotos/__main__.py b/osxphotos/__main__.py index 7f125c62..4938a7a9 100644 --- a/osxphotos/__main__.py +++ b/osxphotos/__main__.py @@ -2321,6 +2321,8 @@ def export( # but was missing on --update doesn't get deleted # (better to have old version than none) + results.missing + # include files that have error in case they exist from previous export + + [r[0] for r in results.error] + [str(pathlib.Path(export_db_path).resolve())] ) click.echo(f"Cleaning up {dest}") @@ -3046,6 +3048,14 @@ def export_photo( ), err=True, ) + for error_ in export_results.error: + click.echo( + click.style( + f"Error exporting photo, file {error_[0]}: {error_[1]}", + fg=CLI_COLOR_ERROR, + ), + err=True, + ) except Exception as e: click.echo( @@ -3056,7 +3066,7 @@ def export_photo( err=True, ) results.error.append( - str(pathlib.Path(dest) / original_filename) + (str(pathlib.Path(dest) / original_filename), e) ) else: verbose_(f"Skipping original version of {photo.original_filename}") @@ -3165,7 +3175,7 @@ def export_photo( ), err=True, ) - results.error.append(str(pathlib.Path(dest) / edited_filename)) + results.error.append((str(pathlib.Path(dest) / edited_filename),e)) if verbose: if update: @@ -3369,7 +3379,7 @@ def write_export_report(report_file, results): "sidecar_json": 0, "sidecar_exiftool": 0, "missing": 0, - "error": 0, + "error": "", "exiftool_warning": "", "exiftool_error": "", "extended_attributes_written": 0, @@ -3427,7 +3437,7 @@ def write_export_report(report_file, results): all_results[result]["missing"] = 1 for result in results.error: - all_results[result]["error"] = 1 + all_results[result[0]]["error"] = result[1] for result in results.exiftool_warning: all_results[result[0]]["exiftool_warning"] = result[1] diff --git a/osxphotos/photoinfo/_photoinfo_export.py b/osxphotos/photoinfo/_photoinfo_export.py index b86d3662..26964401 100644 --- a/osxphotos/photoinfo/_photoinfo_export.py +++ b/osxphotos/photoinfo/_photoinfo_export.py @@ -52,6 +52,12 @@ from ..photokit import ( from ..utils import dd_to_dms_str, findfiles, noop +class ExportError(Exception): + """ error during export """ + + pass + + class ExportResults: """ holds export results for export2 """ @@ -72,7 +78,6 @@ class ExportResults: sidecar_xmp_skipped=None, missing=None, error=None, - error_str=None, exiftool_warning=None, exiftool_error=None, xattr_written=None, @@ -93,7 +98,6 @@ class ExportResults: self.sidecar_xmp_skipped = sidecar_xmp_skipped or [] self.missing = missing or [] self.error = error or [] - self.error_str = error_str or [] self.exiftool_warning = exiftool_warning or [] self.exiftool_error = exiftool_error or [] self.xattr_written = xattr_written or [] @@ -116,10 +120,10 @@ class ExportResults: + self.sidecar_xmp_written + self.sidecar_xmp_skipped + self.missing - + self.error ) files += [x[0] for x in self.exiftool_warning] files += [x[0] for x in self.exiftool_error] + files += [x[0] for x in self.error] files = list(set(files)) return files @@ -140,7 +144,6 @@ class ExportResults: self.sidecar_xmp_skipped += other.sidecar_xmp_skipped self.missing += other.missing self.error += other.error - self.error_str += other.error_str self.exiftool_warning += other.exiftool_warning self.exiftool_error += other.exiftool_error return self @@ -163,7 +166,6 @@ class ExportResults: + f",sidecar_xmp_skipped={self.sidecar_xmp_skipped}" + f",missing={self.missing}" + f",error={self.error}" - + f",error_str={self.error_str}" + f",exiftool_warning={self.exiftool_warning}" + f",exiftool_error={self.exiftool_error}" + ")" @@ -192,56 +194,33 @@ def _export_photo_uuid_applescript( ): """Export photo to dest path using applescript to control Photos If photo is a live photo, exports both the photo and associated .mov file - uuid: UUID of photo to export - dest: destination path to export to - filestem: (string) if provided, exported filename will be named stem.ext - where ext is extension of the file exported by photos (e.g. .jpeg, .mov, etc) - If not provided, file will be named with whatever name Photos uses - If filestem.ext exists, it wil be overwritten - original: (boolean) if True, export original image; default = True - edited: (boolean) if True, export edited photo; default = False - If photo not edited and edited=True, will still export the original image - caller must verify image has been edited - *Note*: must be called with either edited or original but not both, - will raise error if called with both edited and original = True - live_photo: (boolean) if True, export associated .mov live photo; default = False - timeout: timeout value in seconds; export will fail if applescript run time exceeds timeout - burst: (boolean) set to True if file is a burst image to avoid Photos export error - dry_run: (boolean) set to True to run in "dry run" mode which will download file but not actually copy to destination + + Args: + uuid: UUID of photo to export + dest: destination path to export to + filestem: (string) if provided, exported filename will be named stem.ext + where ext is extension of the file exported by photos (e.g. .jpeg, .mov, etc) + If not provided, file will be named with whatever name Photos uses + If filestem.ext exists, it wil be overwritten + original: (boolean) if True, export original image; default = True + edited: (boolean) if True, export edited photo; default = False + If photo not edited and edited=True, will still export the original image + caller must verify image has been edited + *Note*: must be called with either edited or original but not both, + will raise error if called with both edited and original = True + live_photo: (boolean) if True, export associated .mov live photo; default = False + timeout: timeout value in seconds; export will fail if applescript run time exceeds timeout + burst: (boolean) set to True if file is a burst image to avoid Photos export error + dry_run: (boolean) set to True to run in "dry run" mode which will download file but not actually copy to destination + Returns: list of paths to exported file(s) or None if export failed + + Raises: ExportError if error during export + Note: For Live Photos, if edited=True, will export a jpeg but not the movie, even if photo has not been edited. This is due to how Photos Applescript interface works. """ - # setup the applescript to do the export - # export_scpt = AppleScript( - # """ - # on export_by_uuid(theUUID, thePath, original, edited, theTimeOut) - # tell application "Photos" - # set thePath to thePath - # set theItem to media item id theUUID - # set theFilename to filename of theItem - # set itemList to {theItem} - - # if original then - # with timeout of theTimeOut seconds - # export itemList to POSIX file thePath with using originals - # end timeout - # end if - - # if edited then - # with timeout of theTimeOut seconds - # export itemList to POSIX file thePath - # end timeout - # end if - - # return theFilename - # end tell - - # end export_by_uuid - # """ - # ) - dest = pathlib.Path(dest) if not dest.is_dir(): raise ValueError(f"dest {dest} must be a directory") @@ -257,12 +236,8 @@ def _export_photo_uuid_applescript( photo = photoscript.Photo(uuid) filename = photo.filename exported_files = photo.export(tmpdir.name, original=original, timeout=timeout) - # filename = export_scpt.call( - # "export_by_uuid", uuid, tmpdir.name, original, edited, timeout - # ) except Exception as e: - logging.warning(f"Error exporting uuid {uuid}: {e}") - return None + raise ExportError(e) if exported_files and filename: # need to find actual filename as sometimes Photos renames JPG to jpeg on export @@ -531,6 +506,7 @@ def export2( "sidecar_xmp_skipped", "missing", "error", + "error_str", "exiftool_warning", "exiftool_error", @@ -557,24 +533,6 @@ def export2( # e.g. name will be filename_edited.jpg edited_identifier = "_edited" - # list of all files exported during this call to export - exported_files = [] - - # list of new files during update - update_new_files = [] - - # list of files that were updated - update_updated_files = [] - - # list of all files skipped because they do not need to be updated (for use with update=True) - update_skipped_files = [] - - # list of all files with utime touched (touch_file = True) - touched_files = [] - - # list of all files convereted to jpeg - converted_to_jpeg_files = [] - # check edited and raise exception trying to export edited version of # photo that hasn't been edited if edited and not self.hasadjustments: @@ -649,6 +607,7 @@ def export2( f"destination exists ({dest}); overwrite={overwrite}, increment={increment}" ) + all_results = ExportResults() if not use_photos_export: # find the source file on disk and export # get path to source file and verify it's not None and is valid file @@ -742,12 +701,7 @@ def export2( jpeg_quality=jpeg_quality, ignore_signature=ignore_signature, ) - exported_files = results.exported - update_new_files = results.new - update_updated_files = results.updated - update_skipped_files = results.skipped - touched_files = results.touched - converted_to_jpeg_files = results.converted_to_jpeg + all_results += results # copy live photo associated .mov if requested if live_photo and self.live_photo: @@ -768,12 +722,7 @@ def export2( fileutil=fileutil, ignore_signature=ignore_signature, ) - exported_files.extend(results.exported) - update_new_files.extend(results.new) - update_updated_files.extend(results.updated) - update_skipped_files.extend(results.skipped) - touched_files.extend(results.touched) - converted_to_jpeg_files.extend(results.converted_to_jpeg) + all_results += results # copy associated RAW image if requested if raw_photo and self.has_raw: @@ -795,15 +744,9 @@ def export2( jpeg_quality=jpeg_quality, ignore_signature=ignore_signature, ) - exported_files.extend(results.exported) - update_new_files.extend(results.new) - update_updated_files.extend(results.updated) - update_skipped_files.extend(results.skipped) - touched_files.extend(results.touched) - converted_to_jpeg_files.extend(results.converted_to_jpeg) + all_results += results else: # use_photo_export - exported = [] # export live_photo .mov file? live_photo = True if live_photo and self.live_photo else False if edited or self.shared: @@ -833,26 +776,31 @@ def export2( photo = [p for p in bursts if p.uuid.startswith(self.uuid)] photo = photo[0] if photo else None if not photo: - errors.append(dest) - logging.warning(f"PhotoKitFetchFailed exception exporting photo {self.uuid}: {e}") + all_results.error.append((str(dest), f"PhotoKitFetchFailed exception exporting photo {self.uuid}: {e}")) if photo: - exported = photo.export( - dest.parent, dest.name, version=PHOTOS_VERSION_CURRENT - ) - else: - exported = [] + try: + exported = photo.export( + dest.parent, dest.name, version=PHOTOS_VERSION_CURRENT + ) + all_results.exported.extend(exported) + except Exception as e: + all_results.error.append((str(dest), e)) else: - exported = _export_photo_uuid_applescript( - self.uuid, - dest.parent, - filestem=filestem, - original=False, - edited=True, - live_photo=live_photo, - timeout=timeout, - burst=self.burst, - dry_run=dry_run, - ) + try: + exported = _export_photo_uuid_applescript( + self.uuid, + dest.parent, + filestem=filestem, + original=False, + edited=True, + live_photo=live_photo, + timeout=timeout, + burst=self.burst, + dry_run=dry_run, + ) + all_results.exported.extend(exported) + except ExportError as e: + all_results.error.append((str(dest), e)) else: # export original version and not edited filestem = dest.stem @@ -871,13 +819,16 @@ def export2( photo = [p for p in bursts if p.uuid.startswith(self.uuid)] photo = photo[0] if photo else None if photo: - exported = photo.export( + try: + exported = photo.export( dest.parent, dest.name, version=PHOTOS_VERSION_ORIGINAL - ) - else: - exported = [] + ) + all_results.exported.extend(exported) + except Exception as e: + all_results.error.append((str(dest), e)) else: - exported = _export_photo_uuid_applescript( + try: + exported = _export_photo_uuid_applescript( self.uuid, dest.parent, filestem=filestem, @@ -887,21 +838,21 @@ def export2( timeout=timeout, burst=self.burst, dry_run=dry_run, - ) - if exported: + ) + all_results.exported.extend(exported) + except ExportError as e: + all_results.error.append((str(dest), e)) + if all_results.exported: if touch_file: - for exported_file in exported: - touched_files.append(exported_file) + for exported_file in all_results.exported: + all_results.touched.append(exported_file) ts = int(self.date.timestamp()) fileutil.utime(exported_file, (ts, ts)) - exported_files.extend(exported) if update: - update_new_files.extend(exported) + all_results.new.extend(all_results.exported) - else: - logging.warning( - f"Error exporting photo {self.uuid} to {dest} with use_photos_export" - ) + # else: + # all_results.error.append((str(dest), f"Error exporting photo {self.uuid} to {dest} with use_photos_export")) # export metadata sidecars = [] @@ -1013,15 +964,10 @@ def export2( # if exiftool, write the metadata if update: - exif_files = update_new_files + update_updated_files + update_skipped_files + exif_files = all_results.new + all_results.updated + all_results.skipped else: - exif_files = exported_files + exif_files = all_results.exported - exif_files_updated = [] - exiftool_warning = [] - exiftool_error = [] - errors = [] - error_strs = [] # TODO: remove duplicative code from below if exiftool and update and exif_files: for exported_file in exif_files: @@ -1060,10 +1006,10 @@ def export2( merge_exif_persons=merge_exif_persons, ) if warning_: - exiftool_warning.append((exported_file, warning_)) + all_results.exiftool_warning.append((exported_file, warning_)) if error_: - exiftool_error.append((exported_file, error_)) - errors.append(exported_file) + all_results.exiftool_error.append((exported_file, error_)) + all_results.error.append((exported_file, error_)) export_db.set_exifdata_for_file( exported_file, @@ -1080,7 +1026,7 @@ def export2( export_db.set_stat_exif_for_file( exported_file, fileutil.file_sig(exported_file) ) - exif_files_updated.append(exported_file) + all_results.exif_updated.append(exported_file) else: verbose(f"Skipped up to date exiftool metadata for {exported_file}") elif exiftool and exif_files: @@ -1099,10 +1045,10 @@ def export2( merge_exif_persons=merge_exif_persons, ) if warning_: - exiftool_warning.append((exported_file, warning_)) + all_results.exiftool_warning.append((exported_file, warning_)) if error_: - exiftool_error.append((exported_file, error_)) - errors.append(exported_file) + all_results.exiftool_error.append((exported_file, error_)) + all_results.error.append((exported_file, error_)) export_db.set_exifdata_for_file( exported_file, @@ -1119,37 +1065,25 @@ def export2( export_db.set_stat_exif_for_file( exported_file, fileutil.file_sig(exported_file) ) - exif_files_updated.append(exported_file) + all_results.exif_updated.append(exported_file) if touch_file: - for exif_file in exif_files_updated: + for exif_file in all_results.exif_updated: verbose(f"Updating file modification time for {exif_file}") - touched_files.append(exif_file) + all_results.touched.append(exif_file) ts = int(self.date.timestamp()) fileutil.utime(exif_file, (ts, ts)) - touched_files = list(set(touched_files)) + all_results.touched = list(set(all_results.touched)) - results = ExportResults( - exported=exported_files, - new=update_new_files, - updated=update_updated_files, - skipped=update_skipped_files, - exif_updated=exif_files_updated, - touched=touched_files, - converted_to_jpeg=converted_to_jpeg_files, - sidecar_json_written=sidecar_json_files_written, - sidecar_json_skipped=sidecar_json_files_skipped, - sidecar_exiftool_written=sidecar_exiftool_files_written, - sidecar_exiftool_skipped=sidecar_exiftool_files_skipped, - sidecar_xmp_written=sidecar_xmp_files_written, - sidecar_xmp_skipped=sidecar_xmp_files_skipped, - error=errors, - error_str=error_strs, - exiftool_error=exiftool_error, - exiftool_warning=exiftool_warning, - ) - return results + all_results.sidecar_json_written = sidecar_json_files_written + all_results.sidecar_json_skipped = sidecar_json_files_skipped + all_results.sidecar_exiftool_written = sidecar_exiftool_files_written + all_results.sidecar_exiftool_skipped = sidecar_exiftool_files_skipped + all_results.sidecar_xmp_written = sidecar_xmp_files_written + all_results.sidecar_xmp_skipped = sidecar_xmp_files_skipped + + return all_results def _export_photo( diff --git a/tests/search_info_test_data_10_15_7.json b/tests/search_info_test_data_10_15_7.json index bcf0f070..09e272b2 100644 --- a/tests/search_info_test_data_10_15_7.json +++ b/tests/search_info_test_data_10_15_7.json @@ -1 +1 @@ -{"UUID_SEARCH_INFO": {"C8EAF50A-D891-4E0C-8086-C417E1284153": {"labels": ["Butter", "Food"], "place_names": ["Durham Bulls Athletic Park"], "streets": ["Blackwell St"], "neighborhoods": ["American Tobacco District", "Downtown Durham"], "city": "Durham", "locality_names": ["Durham"], "state": "North Carolina", "state_abbreviation": "NC", "country": "United States", "bodies_of_water": [], "month": "October", "year": "2018", "holidays": [], "activities": ["Entertainment", "Travel", "Dining", "Dinner", "Trip"], "season": "Fall", "venues": ["Pie Pusher's", "The Pinhook", "Luna Rotisserie and Empanadas", "Copa"], "venue_types": ["Nightlife", "Cocktail Bar", "Pizza", "Restaurant", "Bar", "Tapas & Small Plates", "Food", "Empanadas", "Chicken Wings", "Arts & Entertainment", "Latin American", "Cuban", "Music Venue"], "media_types": []}, "71DFB4C3-E868-4BE4-906E-D96BD8692D7E": {"labels": ["Desert", "Sky", "Sunset Sunrise", "Outdoor", "Land"], "place_names": ["Royal Palms State Beach"], "streets": [], "neighborhoods": ["San Pedro"], "city": "Los Angeles", "locality_names": [], "state": "California", "state_abbreviation": "", "country": "United States", "bodies_of_water": ["Catalina Channel"], "month": "November", "year": "2017", "holidays": [], "activities": ["Beach Activity", "Activity"], "season": "Fall", "venues": [], "venue_types": [], "media_types": ["Live Photos"]}, "2C151013-5BBA-4D00-B70F-1C9420418B86": {"labels": ["Forest", "Vegetation", "Bench", "Land", "Furniture", "Water", "Water Body", "Outdoor", "People"], "place_names": [], "streets": [], "neighborhoods": [], "city": "", "locality_names": [], "state": "", "state_abbreviation": "", "country": "", "bodies_of_water": [], "month": "December", "year": "2014", "holidays": ["Christmas Day"], "activities": ["Celebration", "Holiday"], "season": "Winter", "venues": [], "venue_types": [], "media_types": []}}, "UUID_SEARCH_INFO_NORMALIZED": {"C8EAF50A-D891-4E0C-8086-C417E1284153": {"labels": ["butter", "food"], "place_names": ["durham bulls athletic park"], "streets": ["blackwell st"], "neighborhoods": ["american tobacco district", "downtown durham"], "city": "durham", "locality_names": ["durham"], "state": "north carolina", "state_abbreviation": "nc", "country": "united states", "bodies_of_water": [], "month": "october", "year": "2018", "holidays": [], "activities": ["entertainment", "travel", "dining", "dinner", "trip"], "season": "fall", "venues": ["pie pusher's", "the pinhook", "luna rotisserie and empanadas", "copa"], "venue_types": ["nightlife", "cocktail bar", "pizza", "restaurant", "bar", "tapas & small plates", "food", "empanadas", "chicken wings", "arts & entertainment", "latin american", "cuban", "music venue"], "media_types": []}, "71DFB4C3-E868-4BE4-906E-D96BD8692D7E": {"labels": ["desert", "sky", "sunset sunrise", "outdoor", "land"], "place_names": ["royal palms state beach"], "streets": [], "neighborhoods": ["san pedro"], "city": "los angeles", "locality_names": [], "state": "california", "state_abbreviation": "", "country": "united states", "bodies_of_water": ["catalina channel"], "month": "november", "year": "2017", "holidays": [], "activities": ["beach activity", "activity"], "season": "fall", "venues": [], "venue_types": [], "media_types": ["live photos"]}, "2C151013-5BBA-4D00-B70F-1C9420418B86": {"labels": ["forest", "vegetation", "bench", "land", "furniture", "water", "water body", "outdoor", "people"], "place_names": [], "streets": [], "neighborhoods": [], "city": "", "locality_names": [], "state": "", "state_abbreviation": "", "country": "", "bodies_of_water": [], "month": "december", "year": "2014", "holidays": ["christmas day"], "activities": ["celebration", "holiday"], "season": "winter", "venues": [], "venue_types": [], "media_types": []}}, "UUID_SEARCH_INFO_ALL": {"C8EAF50A-D891-4E0C-8086-C417E1284153": ["Butter", "Food", "Durham Bulls Athletic Park", "Blackwell St", "American Tobacco District", "Downtown Durham", "Durham", "Entertainment", "Travel", "Dining", "Dinner", "Trip", "Pie Pusher's", "The Pinhook", "Luna Rotisserie and Empanadas", "Copa", "Nightlife", "Cocktail Bar", "Pizza", "Restaurant", "Bar", "Tapas & Small Plates", "Food", "Empanadas", "Chicken Wings", "Arts & Entertainment", "Latin American", "Cuban", "Music Venue", "Durham", "North Carolina", "NC", "United States", "October", "2018", "Fall"], "71DFB4C3-E868-4BE4-906E-D96BD8692D7E": ["Desert", "Sky", "Sunset Sunrise", "Outdoor", "Land", "Royal Palms State Beach", "San Pedro", "Catalina Channel", "Beach Activity", "Activity", "Live Photos", "Los Angeles", "California", "United States", "November", "2017", "Fall"], "2C151013-5BBA-4D00-B70F-1C9420418B86": ["Forest", "Vegetation", "Bench", "Land", "Furniture", "Water", "Water Body", "Outdoor", "People", "Christmas Day", "Celebration", "Holiday", "December", "2014", "Winter"]}, "UUID_SEARCH_INFO_ALL_NORMALIZED": {"C8EAF50A-D891-4E0C-8086-C417E1284153": ["butter", "food", "durham bulls athletic park", "blackwell st", "american tobacco district", "downtown durham", "durham", "entertainment", "travel", "dining", "dinner", "trip", "pie pusher's", "the pinhook", "luna rotisserie and empanadas", "copa", "nightlife", "cocktail bar", "pizza", "restaurant", "bar", "tapas & small plates", "food", "empanadas", "chicken wings", "arts & entertainment", "latin american", "cuban", "music venue", "durham", "north carolina", "nc", "united states", "october", "2018", "fall"], "71DFB4C3-E868-4BE4-906E-D96BD8692D7E": ["desert", "sky", "sunset sunrise", "outdoor", "land", "royal palms state beach", "san pedro", "catalina channel", "beach activity", "activity", "live photos", "los angeles", "california", "united states", "november", "2017", "fall"], "2C151013-5BBA-4D00-B70F-1C9420418B86": ["forest", "vegetation", "bench", "land", "furniture", "water", "water body", "outdoor", "people", "christmas day", "celebration", "holiday", "december", "2014", "winter"]}} +{"UUID_SEARCH_INFO": {"C8EAF50A-D891-4E0C-8086-C417E1284153": {"labels": ["Food", "Butter"], "place_names": ["Durham Bulls Athletic Park"], "streets": ["Blackwell St"], "neighborhoods": ["American Tobacco District", "Downtown Durham"], "city": "Durham", "locality_names": ["Durham"], "state": "North Carolina", "state_abbreviation": "NC", "country": "United States", "bodies_of_water": [], "month": "October", "year": "2018", "holidays": [], "activities": ["Dinner", "Travel", "Entertainment", "Dining", "Trip"], "season": "Fall", "venues": ["Luna Rotisserie and Empanadas", "Copa", "Pie Pusher's", "The Pinhook"], "venue_types": [], "media_types": []}, "71DFB4C3-E868-4BE4-906E-D96BD8692D7E": {"labels": ["Desert", "Land", "Sky", "Sunset Sunrise", "Outdoor"], "place_names": ["Royal Palms State Beach"], "streets": [], "neighborhoods": ["San Pedro"], "city": "Los Angeles", "locality_names": [], "state": "California", "state_abbreviation": "", "country": "United States", "bodies_of_water": ["Catalina Channel"], "month": "November", "year": "2017", "holidays": [], "activities": ["Beach Activity", "Activity"], "season": "Fall", "venues": [], "venue_types": [], "media_types": ["Live Photos"]}, "2C151013-5BBA-4D00-B70F-1C9420418B86": {"labels": ["Bench", "Furniture", "Water Body", "Land", "People", "Water", "Plant", "Outdoor", "Vegetation", "Forest"], "place_names": [], "streets": [], "neighborhoods": [], "city": "", "locality_names": [], "state": "", "state_abbreviation": "", "country": "", "bodies_of_water": [], "month": "December", "year": "2014", "holidays": ["Christmas Day"], "activities": ["Celebration", "Holiday"], "season": "Winter", "venues": [], "venue_types": [], "media_types": []}}, "UUID_SEARCH_INFO_NORMALIZED": {"C8EAF50A-D891-4E0C-8086-C417E1284153": {"labels": ["food", "butter"], "place_names": ["durham bulls athletic park"], "streets": ["blackwell st"], "neighborhoods": ["american tobacco district", "downtown durham"], "city": "durham", "locality_names": ["durham"], "state": "north carolina", "state_abbreviation": "nc", "country": "united states", "bodies_of_water": [], "month": "october", "year": "2018", "holidays": [], "activities": ["dinner", "travel", "entertainment", "dining", "trip"], "season": "fall", "venues": ["luna rotisserie and empanadas", "copa", "pie pusher's", "the pinhook"], "venue_types": [], "media_types": []}, "71DFB4C3-E868-4BE4-906E-D96BD8692D7E": {"labels": ["desert", "land", "sky", "sunset sunrise", "outdoor"], "place_names": ["royal palms state beach"], "streets": [], "neighborhoods": ["san pedro"], "city": "los angeles", "locality_names": [], "state": "california", "state_abbreviation": "", "country": "united states", "bodies_of_water": ["catalina channel"], "month": "november", "year": "2017", "holidays": [], "activities": ["beach activity", "activity"], "season": "fall", "venues": [], "venue_types": [], "media_types": ["live photos"]}, "2C151013-5BBA-4D00-B70F-1C9420418B86": {"labels": ["bench", "furniture", "water body", "land", "people", "water", "plant", "outdoor", "vegetation", "forest"], "place_names": [], "streets": [], "neighborhoods": [], "city": "", "locality_names": [], "state": "", "state_abbreviation": "", "country": "", "bodies_of_water": [], "month": "december", "year": "2014", "holidays": ["christmas day"], "activities": ["celebration", "holiday"], "season": "winter", "venues": [], "venue_types": [], "media_types": []}}, "UUID_SEARCH_INFO_ALL": {"C8EAF50A-D891-4E0C-8086-C417E1284153": ["Food", "Butter", "Durham Bulls Athletic Park", "Blackwell St", "American Tobacco District", "Downtown Durham", "Durham", "Dinner", "Travel", "Entertainment", "Dining", "Trip", "Luna Rotisserie and Empanadas", "Copa", "Pie Pusher's", "The Pinhook", "Durham", "North Carolina", "NC", "United States", "October", "2018", "Fall"], "71DFB4C3-E868-4BE4-906E-D96BD8692D7E": ["Desert", "Land", "Sky", "Sunset Sunrise", "Outdoor", "Royal Palms State Beach", "San Pedro", "Catalina Channel", "Beach Activity", "Activity", "Live Photos", "Los Angeles", "California", "United States", "November", "2017", "Fall"], "2C151013-5BBA-4D00-B70F-1C9420418B86": ["Bench", "Furniture", "Water Body", "Land", "People", "Water", "Plant", "Outdoor", "Vegetation", "Forest", "Christmas Day", "Celebration", "Holiday", "December", "2014", "Winter"]}, "UUID_SEARCH_INFO_ALL_NORMALIZED": {"C8EAF50A-D891-4E0C-8086-C417E1284153": ["food", "butter", "durham bulls athletic park", "blackwell st", "american tobacco district", "downtown durham", "durham", "dinner", "travel", "entertainment", "dining", "trip", "luna rotisserie and empanadas", "copa", "pie pusher's", "the pinhook", "durham", "north carolina", "nc", "united states", "october", "2018", "fall"], "71DFB4C3-E868-4BE4-906E-D96BD8692D7E": ["desert", "land", "sky", "sunset sunrise", "outdoor", "royal palms state beach", "san pedro", "catalina channel", "beach activity", "activity", "live photos", "los angeles", "california", "united states", "november", "2017", "fall"], "2C151013-5BBA-4D00-B70F-1C9420418B86": ["bench", "furniture", "water body", "land", "people", "water", "plant", "outdoor", "vegetation", "forest", "christmas day", "celebration", "holiday", "december", "2014", "winter"]}} diff --git a/tests/test_exportresults.py b/tests/test_exportresults.py index 53726065..41e8c1fb 100644 --- a/tests/test_exportresults.py +++ b/tests/test_exportresults.py @@ -19,7 +19,6 @@ EXPORT_RESULT_ATTRIBUTES = [ "sidecar_xmp_skipped", "missing", "error", - "error_str", "exiftool_warning", "exiftool_error", ] @@ -42,7 +41,6 @@ def test_exportresults_init(): assert results.sidecar_xmp_skipped == [] assert results.missing == [] assert results.error == [] - assert results.error_str == [] assert results.exiftool_warning == [] assert results.exiftool_error == [] @@ -82,14 +80,13 @@ def test_all_files(): """ test ExportResults.all_files() """ results = ExportResults() for x in EXPORT_RESULT_ATTRIBUTES: - if x == "error_str": - continue setattr(results, x, [f"{x}1"]) results.exiftool_warning = [("exiftool_warning1", "foo")] results.exiftool_error = [("exiftool_error1", "foo")] + results.error = [("error1", "foo")] assert sorted(results.all_files()) == sorted( - [f"{x}1" for x in EXPORT_RESULT_ATTRIBUTES if x != "error_str"] + [f"{x}1" for x in EXPORT_RESULT_ATTRIBUTES] ) @@ -98,6 +95,6 @@ def test_str(): results = ExportResults() assert ( str(results) - == "ExportResults(exported=[],new=[],updated=[],skipped=[],exif_updated=[],touched=[],converted_to_jpeg=[],sidecar_json_written=[],sidecar_json_skipped=[],sidecar_exiftool_written=[],sidecar_exiftool_skipped=[],sidecar_xmp_written=[],sidecar_xmp_skipped=[],missing=[],error=[],error_str=[],exiftool_warning=[],exiftool_error=[])" + == "ExportResults(exported=[],new=[],updated=[],skipped=[],exif_updated=[],touched=[],converted_to_jpeg=[],sidecar_json_written=[],sidecar_json_skipped=[],sidecar_exiftool_written=[],sidecar_exiftool_skipped=[],sidecar_xmp_written=[],sidecar_xmp_skipped=[],missing=[],error=[],exiftool_warning=[],exiftool_error=[])" )