diff --git a/osxphotos/__main__.py b/osxphotos/__main__.py index 6ad482df..f1777e9a 100644 --- a/osxphotos/__main__.py +++ b/osxphotos/__main__.py @@ -1423,7 +1423,7 @@ def export( (export_as_hardlink, exiftool), (any(place), no_place), (deleted, deleted_only), - (skip_edited, skip_original_if_edited) + (skip_edited, skip_original_if_edited), ] if any(all(bb) for bb in exclusive): click.echo("Incompatible export options", err=True) diff --git a/osxphotos/_version.py b/osxphotos/_version.py index 841e877e..36c84a5b 100644 --- a/osxphotos/_version.py +++ b/osxphotos/_version.py @@ -1,3 +1,3 @@ """ version info """ -__version__ = "0.34.1" +__version__ = "0.34.2" diff --git a/osxphotos/phototemplate.py b/osxphotos/phototemplate.py index dd71ef27..377bf9d0 100644 --- a/osxphotos/phototemplate.py +++ b/osxphotos/phototemplate.py @@ -621,6 +621,9 @@ class PhotoTemplate: """ return list of values for a multi-valued template field """ if field == "album": values = self.photo.albums + values = [ + value.replace("/", ":") for value in values + ] # TODO: temp fix for issue #213 elif field == "keyword": values = self.photo.keywords elif field == "person": @@ -638,11 +641,13 @@ class PhotoTemplate: if album.folder_names: # album in folder folder = path_sep.join(album.folder_names) - folder += path_sep + album.title + folder += path_sep + album.title.replace( + "/", ":" + ) # TODO: temp fix for issue #213 values.append(folder) else: # album not in folder - values.append(album.title) + values.append(album.title.replace("/", ":")) else: raise ValueError(f"Unhandleded template value: {field}") diff --git a/tests/Test-10.15.6.photoslibrary/database/Photos.sqlite-shm b/tests/Test-10.15.6.photoslibrary/database/Photos.sqlite-shm index a5e29bd3..4823f4bd 100644 Binary files a/tests/Test-10.15.6.photoslibrary/database/Photos.sqlite-shm and b/tests/Test-10.15.6.photoslibrary/database/Photos.sqlite-shm differ diff --git a/tests/Test-10.15.6.photoslibrary/database/Photos.sqlite-wal b/tests/Test-10.15.6.photoslibrary/database/Photos.sqlite-wal index a7b92702..3d96f6a7 100644 Binary files a/tests/Test-10.15.6.photoslibrary/database/Photos.sqlite-wal and b/tests/Test-10.15.6.photoslibrary/database/Photos.sqlite-wal differ diff --git a/tests/Test-10.15.6.photoslibrary/database/Photos.sqlite.lock b/tests/Test-10.15.6.photoslibrary/database/Photos.sqlite.lock index 5b9b78f5..2342dda3 100644 --- a/tests/Test-10.15.6.photoslibrary/database/Photos.sqlite.lock +++ b/tests/Test-10.15.6.photoslibrary/database/Photos.sqlite.lock @@ -7,7 +7,7 @@ hostuuid 9575E48B-8D5F-5654-ABAC-4431B1167324 pid - 1942 + 80508 processname photolibraryd uid diff --git a/tests/Test-10.15.6.photoslibrary/database/search/psi.sqlite b/tests/Test-10.15.6.photoslibrary/database/search/psi.sqlite index 3f06de8f..ac583031 100644 Binary files a/tests/Test-10.15.6.photoslibrary/database/search/psi.sqlite and b/tests/Test-10.15.6.photoslibrary/database/search/psi.sqlite differ diff --git a/tests/Test-10.15.6.photoslibrary/database/search/searchMetadata.plist b/tests/Test-10.15.6.photoslibrary/database/search/searchMetadata.plist deleted file mode 100644 index 3eec4180..00000000 --- a/tests/Test-10.15.6.photoslibrary/database/search/searchMetadata.plist +++ /dev/null @@ -1,188 +0,0 @@ - - - - - BlacklistedMeaningsByMeaning - - MePersonUUID - 39488755-78C0-40B2-B378-EDA280E1823C - SceneWhitelist - - Graduation - Aquarium - Food - Ice Skating - Mountain - Cliff - Basketball - Tennis - Jewelry - Cheese - Softball - Football - Circus - Jet Ski - Playground - Carousel - Paint Ball - Windsurfing - Sailboat - Sunbathing - Dam - Fireplace - Flower - Scuba - Hiking - Cetacean - Pier - Bowling - Snowboarding - Zoo - Snowmobile - Theater - Boat - Casino - Car - Diving - Cycling - Musical Instrument - Board Game - Castle - Sunset Sunrise - Martial Arts - Motocross - Submarine - Cat - Snow - Kiteboarding - Squash - Geyser - Music - Archery - Desert - Blackjack - Fireworks - Sportscar - Feline - Soccer - Museum - Baby - Fencing - Railroad - Nascar - Sky Surfing - Bird - Games - Baseball - Dressage - Snorkeling - Pyramid - Kite - Rowboat - Golf - Watersports - Lightning - Canyon - Auditorium - Night Sky - Karaoke - Skiing - Parade - Forest - Hot Air Balloon - Dragon Parade - Easter Egg - Monument - Jungle - Thanksgiving - Jockey Horse - Stadium - Airplane - Ballet - Yoga - Coral Reef - Skating - Wrestling - Bicycle - Tattoo - Amusement Park - Canoe - Cheerleading - Ping Pong - Fishing - Magic - Reptile - Winter Sport - Waterfall - Train - Bonsai - Surfing - Dog - Cake - Sledding - Sandcastle - Glacier - Lighthouse - Equestrian - Rafting - Shore - Hockey - Santa Claus - Formula One Car - Sport - Vehicle - Boxing - Rollerskating - Underwater - Orchestra - Carnival - Rocket - Skateboarding - Helicopter - Performance - Oktoberfest - Water Polo - Skate Park - Animal - Nightclub - String Instrument - Dinosaur - Gymnastics - Cricket - Volcano - Lake - Aurora - Dancing - Concert - Rock Climbing - Hang Glider - Rodeo - Fish - Art - Motorcycle - Volleyball - Wake Boarding - Badminton - Motor Sport - Sumo - Parasailing - Skydiving - Kickboxing - Pinata - Foosball - Go Kart - Poker - Kayak - Swimming - Atv - Beach - Dartboard - Athletics - Camping - Tornado - Billiards - Rugby - Airshow - - - diff --git a/tests/Test-10.15.6.photoslibrary/database/search/zeroKeywords.data b/tests/Test-10.15.6.photoslibrary/database/search/zeroKeywords.data index 5d03620c..a4dcac95 100644 Binary files a/tests/Test-10.15.6.photoslibrary/database/search/zeroKeywords.data and b/tests/Test-10.15.6.photoslibrary/database/search/zeroKeywords.data differ diff --git a/tests/Test-10.15.6.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-shm b/tests/Test-10.15.6.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-shm index 057f218f..224e42df 100644 Binary files a/tests/Test-10.15.6.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-shm and b/tests/Test-10.15.6.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-shm differ diff --git a/tests/Test-10.15.6.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-wal b/tests/Test-10.15.6.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-wal index 920a6544..27ca9feb 100644 Binary files a/tests/Test-10.15.6.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-wal and b/tests/Test-10.15.6.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-wal differ diff --git a/tests/Test-10.15.6.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSLocationCache.sqlite-shm b/tests/Test-10.15.6.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSLocationCache.sqlite-shm index eb0386c2..8f27ed5e 100644 Binary files a/tests/Test-10.15.6.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSLocationCache.sqlite-shm and b/tests/Test-10.15.6.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSLocationCache.sqlite-shm differ diff --git a/tests/Test-10.15.6.photoslibrary/private/com.apple.photoanalysisd/caches/graph/changetoken.plist b/tests/Test-10.15.6.photoslibrary/private/com.apple.photoanalysisd/caches/graph/changetoken.plist index 3af2e280..46a0d6b4 100644 Binary files a/tests/Test-10.15.6.photoslibrary/private/com.apple.photoanalysisd/caches/graph/changetoken.plist and b/tests/Test-10.15.6.photoslibrary/private/com.apple.photoanalysisd/caches/graph/changetoken.plist differ diff --git a/tests/Test-10.15.6.photoslibrary/private/com.apple.photolibraryd/caches/clientservertransaction/87554DE2-780A-4ED2-83B2-324CCE3DEE45 b/tests/Test-10.15.6.photoslibrary/private/com.apple.photolibraryd/caches/clientservertransaction/87554DE2-780A-4ED2-83B2-324CCE3DEE45 deleted file mode 100644 index 5142c798..00000000 Binary files a/tests/Test-10.15.6.photoslibrary/private/com.apple.photolibraryd/caches/clientservertransaction/87554DE2-780A-4ED2-83B2-324CCE3DEE45 and /dev/null differ diff --git a/tests/Test-10.15.6.photoslibrary/resources/journals/Album-change.plj b/tests/Test-10.15.6.photoslibrary/resources/journals/Album-change.plj index 5ef0bce4..c34ef490 100644 Binary files a/tests/Test-10.15.6.photoslibrary/resources/journals/Album-change.plj and b/tests/Test-10.15.6.photoslibrary/resources/journals/Album-change.plj differ diff --git a/tests/Test-10.15.6.photoslibrary/resources/journals/Folder-change.plj b/tests/Test-10.15.6.photoslibrary/resources/journals/Folder-change.plj index f70ba701..e0384369 100644 Binary files a/tests/Test-10.15.6.photoslibrary/resources/journals/Folder-change.plj and b/tests/Test-10.15.6.photoslibrary/resources/journals/Folder-change.plj differ diff --git a/tests/Test-10.15.6.photoslibrary/resources/journals/HistoryToken.plist b/tests/Test-10.15.6.photoslibrary/resources/journals/HistoryToken.plist index 55617142..f0162126 100644 Binary files a/tests/Test-10.15.6.photoslibrary/resources/journals/HistoryToken.plist and b/tests/Test-10.15.6.photoslibrary/resources/journals/HistoryToken.plist differ diff --git a/tests/test_catalina_10_15_6.py b/tests/test_catalina_10_15_6.py index ca942446..21a9c035 100644 --- a/tests/test_catalina_10_15_6.py +++ b/tests/test_catalina_10_15_6.py @@ -34,6 +34,7 @@ ALBUMS = [ "I have a deleted twin", # there's an empty album with same name that has been deleted "EmptyAlbum", "2018-10 - Sponsion, Museum, Frühstück, Römermuseum", + "2019-10/11 Paris Clermont", ] KEYWORDS_DICT = { "Kids": 4, @@ -55,6 +56,7 @@ ALBUM_DICT = { "I have a deleted twin": 1, "EmptyAlbum": 0, "2018-10 - Sponsion, Museum, Frühstück, Römermuseum": 1, + "2019-10/11 Paris Clermont": 1, } # Note: there are 2 albums named "Test Album" for testing duplicate album names UUID_DICT = { diff --git a/tests/test_cli.py b/tests/test_cli.py index 3295d28c..51097278 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -182,7 +182,14 @@ CLI_EXPORTED_FILENAME_TEMPLATE_FILENAMES2 = [ "I have a deleted twin-wedding_edited.jpeg", ] +CLI_EXPORTED_FILENAME_TEMPLATE_FILENAMES_PATHSEP = [ +"2018-10 - Sponsion, Museum, Frühstück, Römermuseum/IMG_4547.jpg", +"Folder1/SubFolder2/AlbumInFolder/IMG_4547.jpg", +"2019-10:11 Paris Clermont/IMG_4547.jpg", +] + CLI_EXPORT_UUID = "D79B8D77-BFFC-460B-9312-034F2877D35B" +CLI_EXPORT_UUID_STATUE = "3DD2C897-F19E-4CA6-8C22-B027D5A71907" CLI_EXPORT_UUID_FILENAME = "Pumkins2.jpg" @@ -311,6 +318,7 @@ ALBUMS_JSON = { "AlbumInFolder": 2, "I have a deleted twin": 1, "2018-10 - Sponsion, Museum, Frühstück, Römermuseum": 1, + "2019-10/11 Paris Clermont": 1, "EmptyAlbum": 0, }, "shared albums": {}, @@ -1818,6 +1826,37 @@ def test_export_filename_template_2(): files = glob.glob("*.*") assert sorted(files) == sorted(CLI_EXPORTED_FILENAME_TEMPLATE_FILENAMES2) +def test_export_filename_template_pathsep_in_name(): + """ export photos using filename template with folder_album and "/" in album name """ + import locale + import os + import os.path + import pathlib + import osxphotos + from osxphotos.__main__ import export + + locale.setlocale(locale.LC_ALL, "en_US") + + runner = CliRunner() + cwd = os.getcwd() + # pylint: disable=not-context-manager + with runner.isolated_filesystem(): + result = runner.invoke( + export, + [ + os.path.join(cwd, PHOTOS_DB_15_6), + ".", + "-V", + "--directory", + "{folder_album,None}", + "--uuid", + CLI_EXPORT_UUID_STATUE + ], + ) + assert result.exit_code == 0 + for fname in CLI_EXPORTED_FILENAME_TEMPLATE_FILENAMES_PATHSEP: + # assert fname in result.output + assert pathlib.Path(fname).is_file() def test_export_filename_template_3(): """ test --filename with invalid template """