Compare commits

...

3 Commits

Author SHA1 Message Date
Rhet Turnbull
1c9da5ed6f Bug fix for PhotosDB.photos() query 2020-04-10 18:50:58 -07:00
Rhet Turnbull
d74f7f499b Updated test library 2020-04-10 17:58:45 -07:00
Rhet Turnbull
c85bb02304 Updated CHANGELOG.md 2020-04-10 17:35:23 -07:00
31 changed files with 136 additions and 26 deletions

View File

@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
#### [v0.26.0](https://github.com/RhetTbull/osxphotos/compare/v0.25.1...v0.26.0)
> 11 April 2020
- Added test for 10.15.4 [`1820715`](https://github.com/RhetTbull/osxphotos/commit/182071584904d001a9b199eef5febfb79e00696e)
- Changed PhotosDB albums interface as prep for adding folders [`3e50626`](https://github.com/RhetTbull/osxphotos/commit/3e5062684ab6d706d91d4abeb4e3b0ca47867b70)
- Updated CHANGELOG.md [`a6ca3f4`](https://github.com/RhetTbull/osxphotos/commit/a6ca3f453ce0fae4e8d13c7c256ed69a16d2e3f2)
#### [v0.25.1](https://github.com/RhetTbull/osxphotos/compare/v0.25.0...v0.25.1) #### [v0.25.1](https://github.com/RhetTbull/osxphotos/compare/v0.25.0...v0.25.1)
> 5 April 2020 > 5 April 2020

View File

@@ -1,3 +1,3 @@
""" version info """ """ version info """
__version__ = "0.26.0" __version__ = "0.26.1"

View File

@@ -2089,37 +2089,45 @@ class PhotosDB:
photos_sets.append(set(self._dbphotos.keys())) photos_sets.append(set(self._dbphotos.keys()))
else: else:
if albums: if albums:
album_set = set()
for album in albums: for album in albums:
# TODO: can have >1 album with same name. This globs them together. # TODO: can have >1 album with same name. This globs them together.
# Need a way to select which album? # Need a way to select which album?
if album in self._dbalbum_titles: if album in self._dbalbum_titles:
album_set = set() title_set = set()
for album_id in self._dbalbum_titles[album]: for album_id in self._dbalbum_titles[album]:
album_set.update(self._dbalbums_album[album_id]) title_set.update(self._dbalbums_album[album_id])
photos_sets.append(album_set) album_set.update(title_set)
else: else:
logging.debug(f"Could not find album '{album}' in database") logging.debug(f"Could not find album '{album}' in database")
photos_sets.append(album_set)
if uuid: if uuid:
uuid_set = set()
for u in uuid: for u in uuid:
if u in self._dbphotos: if u in self._dbphotos:
photos_sets.append(set([u])) uuid_set.update([u])
else: else:
logging.debug(f"Could not find uuid '{u}' in database") logging.debug(f"Could not find uuid '{u}' in database")
photos_sets.append(uuid_set)
if keywords: if keywords:
keyword_set = set()
for keyword in keywords: for keyword in keywords:
if keyword in self._dbkeywords_keyword: if keyword in self._dbkeywords_keyword:
photos_sets.append(set(self._dbkeywords_keyword[keyword])) keyword_set.update(self._dbkeywords_keyword[keyword])
else: else:
logging.debug(f"Could not find keyword '{keyword}' in database") logging.debug(f"Could not find keyword '{keyword}' in database")
photos_sets.append(keyword_set)
if persons: if persons:
person_set = set()
for person in persons: for person in persons:
if person in self._dbfaces_person: if person in self._dbfaces_person:
photos_sets.append(set(self._dbfaces_person[person])) person_set.update(self._dbfaces_person[person])
else: else:
logging.debug(f"Could not find person '{person}' in database") logging.debug(f"Could not find person '{person}' in database")
photos_sets.append(person_set)
if from_date or to_date: if from_date or to_date:
dsel = self._dbphotos dsel = self._dbphotos

View File

@@ -7,7 +7,7 @@
<key>hostuuid</key> <key>hostuuid</key>
<string>9575E48B-8D5F-5654-ABAC-4431B1167324</string> <string>9575E48B-8D5F-5654-ABAC-4431B1167324</string>
<key>pid</key> <key>pid</key>
<integer>1526</integer> <integer>685</integer>
<key>processname</key> <key>processname</key>
<string>photolibraryd</string> <string>photolibraryd</string>
<key>uid</key> <key>uid</key>

View File

@@ -3,24 +3,24 @@
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>BackgroundHighlightCollection</key> <key>BackgroundHighlightCollection</key>
<date>2020-04-04T17:34:35Z</date> <date>2020-04-11T01:34:25Z</date>
<key>BackgroundHighlightEnrichment</key> <key>BackgroundHighlightEnrichment</key>
<date>2020-04-04T17:34:34Z</date> <date>2020-04-11T01:34:24Z</date>
<key>BackgroundJobAssetRevGeocode</key> <key>BackgroundJobAssetRevGeocode</key>
<date>2020-04-04T20:16:33Z</date> <date>2020-04-11T01:34:26Z</date>
<key>BackgroundJobSearch</key> <key>BackgroundJobSearch</key>
<date>2020-04-04T17:34:35Z</date> <date>2020-04-11T01:34:26Z</date>
<key>BackgroundPeopleSuggestion</key> <key>BackgroundPeopleSuggestion</key>
<date>2020-04-04T17:34:34Z</date> <date>2020-04-11T01:34:23Z</date>
<key>BackgroundUserBehaviorProcessor</key> <key>BackgroundUserBehaviorProcessor</key>
<date>2020-04-04T13:56:56Z</date> <date>2020-04-10T06:04:05Z</date>
<key>PhotoAnalysisGraphLastBackgroundGraphConsistencyUpdateJobDateKey</key> <key>PhotoAnalysisGraphLastBackgroundGraphConsistencyUpdateJobDateKey</key>
<date>2020-04-04T20:16:40Z</date> <date>2020-04-11T01:34:33Z</date>
<key>PhotoAnalysisGraphLastBackgroundGraphRebuildJobDate</key> <key>PhotoAnalysisGraphLastBackgroundGraphRebuildJobDate</key>
<date>2020-04-04T13:56:49Z</date> <date>2020-04-10T06:04:04Z</date>
<key>PhotoAnalysisGraphLastBackgroundMemoryGenerationJobDate</key> <key>PhotoAnalysisGraphLastBackgroundMemoryGenerationJobDate</key>
<date>2020-04-04T20:16:33Z</date> <date>2020-04-11T01:34:26Z</date>
<key>SiriPortraitDonation</key> <key>SiriPortraitDonation</key>
<date>2020-04-04T13:56:56Z</date> <date>2020-04-10T06:04:05Z</date>
</dict> </dict>
</plist> </plist>

View File

@@ -3,8 +3,8 @@
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>FaceIDModelLastGenerationKey</key> <key>FaceIDModelLastGenerationKey</key>
<date>2020-04-04T13:56:59Z</date> <date>2020-04-10T06:04:06Z</date>
<key>LastContactClassificationKey</key> <key>LastContactClassificationKey</key>
<date>2020-04-04T13:57:02Z</date> <date>2020-04-10T06:04:08Z</date>
</dict> </dict>
</plist> </plist>

View File

@@ -24,6 +24,7 @@ PERSONS = ["Katie", "Suzy", "Maria", _UNKNOWN_PERSON]
ALBUMS = [ ALBUMS = [
"Pumpkin Farm", "Pumpkin Farm",
"Test Album", "Test Album",
"Multi Keyword",
] # Note: there are 2 albums named "Test Album" for testing duplicate album names ] # Note: there are 2 albums named "Test Album" for testing duplicate album names
KEYWORDS_DICT = { KEYWORDS_DICT = {
"Kids": 4, "Kids": 4,
@@ -40,6 +41,7 @@ PERSONS_DICT = {"Katie": 3, "Suzy": 2, "Maria": 1, _UNKNOWN_PERSON: 1}
ALBUM_DICT = { ALBUM_DICT = {
"Pumpkin Farm": 3, "Pumpkin Farm": 3,
"Test Album": 2, "Test Album": 2,
"Multi Keyword": 2,
} # Note: there are 2 albums named "Test Album" for testing duplicate album names } # Note: there are 2 albums named "Test Album" for testing duplicate album names
UUID_DICT = { UUID_DICT = {
@@ -55,6 +57,8 @@ UUID_DICT = {
"external_edit": "DC99FBDD-7A52-4100-A5BB-344131646C30", "external_edit": "DC99FBDD-7A52-4100-A5BB-344131646C30",
"no_external_edit": "E9BC5C36-7CD1-40A1-A72B-8B8FAC227D51", "no_external_edit": "E9BC5C36-7CD1-40A1-A72B-8B8FAC227D51",
"export": "D79B8D77-BFFC-460B-9312-034F2877D35B", # "Pumkins2.jpg" "export": "D79B8D77-BFFC-460B-9312-034F2877D35B", # "Pumkins2.jpg"
"multi_query_1": "D79B8D77-BFFC-460B-9312-034F2877D35B",
"multi_query_2": "E9BC5C36-7CD1-40A1-A72B-8B8FAC227D51",
} }
@@ -202,7 +206,7 @@ def test_attributes():
) )
assert p.description == "Girl holding pumpkin" assert p.description == "Girl holding pumpkin"
assert p.title == "I found one!" assert p.title == "I found one!"
assert p.albums == ["Pumpkin Farm", "Test Album"] assert p.albums == ["Pumpkin Farm", "Test Album", "Multi Keyword"]
assert p.persons == ["Katie"] assert p.persons == ["Katie"]
assert p.path.endswith( assert p.path.endswith(
"tests/Test-10.15.1.photoslibrary/originals/D/D79B8D77-BFFC-460B-9312-034F2877D35B.jpeg" "tests/Test-10.15.1.photoslibrary/originals/D/D79B8D77-BFFC-460B-9312-034F2877D35B.jpeg"
@@ -778,3 +782,50 @@ def test_from_to_date():
from_date=dt.datetime(2018, 9, 28), to_date=dt.datetime(2018, 9, 29) from_date=dt.datetime(2018, 9, 28), to_date=dt.datetime(2018, 9, 29)
) )
assert len(photos) == 4 assert len(photos) == 4
def test_multi_uuid():
import osxphotos
photosdb = osxphotos.PhotosDB(PHOTOS_DB)
photos = photosdb.photos(uuid=[UUID_DICT["favorite"], UUID_DICT["not_favorite"]])
assert len(photos) == 2
def test_multi_keyword():
import osxphotos
photosdb = osxphotos.PhotosDB(PHOTOS_DB)
photos = photosdb.photos(keywords=["Kids", "wedding"])
assert len(photos) == 6
def test_multi_album():
import osxphotos
photosdb = osxphotos.PhotosDB(PHOTOS_DB)
photos = photosdb.photos(albums=["Pumpkin Farm", "Test Album"])
assert len(photos) == 3
def test_multi_person():
import osxphotos
photosdb = osxphotos.PhotosDB(PHOTOS_DB)
photos = photosdb.photos(persons=["Katie", "Suzy"])
assert len(photos) == 3
def test_compound_query():
import osxphotos
photosdb = osxphotos.PhotosDB(PHOTOS_DB)
photos = photosdb.photos(persons=["Katie", "Maria"], albums=["Multi Keyword"])
assert len(photos) == 2
assert UUID_DICT["multi_query_1"] in [p.uuid for p in photos]
assert UUID_DICT["multi_query_2"] in [p.uuid for p in photos]

View File

@@ -29,7 +29,7 @@ CLI_OUTPUT_NO_SUBCOMMAND = [
" query Query the Photos database using 1 or more search options; if", " query Query the Photos database using 1 or more search options; if",
] ]
CLI_OUTPUT_QUERY_UUID = '[{"uuid": "D79B8D77-BFFC-460B-9312-034F2877D35B", "filename": "D79B8D77-BFFC-460B-9312-034F2877D35B.jpeg", "original_filename": "Pumkins2.jpg", "date": "2018-09-28T16:07:07-04:00", "description": "Girl holding pumpkin", "title": "I found one!", "keywords": ["Kids"], "albums": ["Pumpkin Farm", "Test Album"], "persons": ["Katie"], "path": "/tests/Test-10.15.1.photoslibrary/originals/D/D79B8D77-BFFC-460B-9312-034F2877D35B.jpeg", "ismissing": false, "hasadjustments": false, "external_edit": false, "favorite": false, "hidden": false, "latitude": null, "longitude": null, "path_edited": null, "shared": false, "isphoto": true, "ismovie": false, "uti": "public.jpeg", "burst": false, "live_photo": false, "path_live_photo": null, "iscloudasset": false, "incloud": null}]' CLI_OUTPUT_QUERY_UUID = '[{"uuid": "D79B8D77-BFFC-460B-9312-034F2877D35B", "filename": "D79B8D77-BFFC-460B-9312-034F2877D35B.jpeg", "original_filename": "Pumkins2.jpg", "date": "2018-09-28T16:07:07-04:00", "description": "Girl holding pumpkin", "title": "I found one!", "keywords": ["Kids"], "albums": ["Pumpkin Farm", "Test Album", "Multi Keyword"], "persons": ["Katie"], "path": "/tests/Test-10.15.1.photoslibrary/originals/D/D79B8D77-BFFC-460B-9312-034F2877D35B.jpeg", "ismissing": false, "hasadjustments": false, "external_edit": false, "favorite": false, "hidden": false, "latitude": null, "longitude": null, "path_edited": null, "shared": false, "isphoto": true, "ismovie": false, "uti": "public.jpeg", "burst": false, "live_photo": false, "path_live_photo": null, "iscloudasset": false, "incloud": null}]'
CLI_EXPORT_FILENAMES = [ CLI_EXPORT_FILENAMES = [
"Pumkins1.jpg", "Pumkins1.jpg",
@@ -52,7 +52,7 @@ CLI_EXPORTED_DIRECTORY_TEMPLATE_FILENAMES1 = [
] ]
CLI_EXPORTED_DIRECTORY_TEMPLATE_FILENAMES_ALBUM1 = [ CLI_EXPORTED_DIRECTORY_TEMPLATE_FILENAMES_ALBUM1 = [
"_/wedding.jpg", "Multi Keyword/wedding.jpg",
"_/Tulips.jpg", "_/Tulips.jpg",
"_/St James Park.jpg", "_/St James Park.jpg",
"Pumpkin Farm/Pumpkins3.jpg", "Pumpkin Farm/Pumpkins3.jpg",
@@ -62,7 +62,7 @@ CLI_EXPORTED_DIRECTORY_TEMPLATE_FILENAMES_ALBUM1 = [
] ]
CLI_EXPORTED_DIRECTORY_TEMPLATE_FILENAMES_ALBUM2 = [ CLI_EXPORTED_DIRECTORY_TEMPLATE_FILENAMES_ALBUM2 = [
"NOALBUM/wedding.jpg", "Multi Keyword/wedding.jpg",
"NOALBUM/Tulips.jpg", "NOALBUM/Tulips.jpg",
"NOALBUM/St James Park.jpg", "NOALBUM/St James Park.jpg",
"Pumpkin Farm/Pumpkins3.jpg", "Pumpkin Farm/Pumpkins3.jpg",

View File

@@ -33,7 +33,10 @@ KEYWORDS_DICT = {
PERSONS_DICT = {"Katie": 3, "Suzy": 2, "Maria": 1} PERSONS_DICT = {"Katie": 3, "Suzy": 2, "Maria": 1}
ALBUM_DICT = {"Pumpkin Farm": 3, "Test Album": 1, "Test Album (1)": 1} ALBUM_DICT = {"Pumpkin Farm": 3, "Test Album": 1, "Test Album (1)": 1}
UUID_DICT = {"favorite": "6bxcNnzRQKGnK4uPrCJ9UQ"} UUID_DICT = {
"favorite": "6bxcNnzRQKGnK4uPrCJ9UQ",
"not_favorite": "8SOE9s0XQVGsuq4ONohTng",
}
def test_init(): def test_init():
@@ -354,3 +357,39 @@ def test_photosinfo_repr():
assert {k: str(v).encode("utf-8") for k, v in photo.__dict__.items()} == { assert {k: str(v).encode("utf-8") for k, v in photo.__dict__.items()} == {
k: str(v).encode("utf-8") for k, v in photo2.__dict__.items() k: str(v).encode("utf-8") for k, v in photo2.__dict__.items()
} }
def test_multi_uuid():
import osxphotos
photosdb = osxphotos.PhotosDB(PHOTOS_DB)
photos = photosdb.photos(uuid=[UUID_DICT["favorite"], UUID_DICT["not_favorite"]])
assert len(photos) == 2
def test_multi_keyword():
import osxphotos
photosdb = osxphotos.PhotosDB(PHOTOS_DB)
photos = photosdb.photos(keywords=["Kids", "wedding"])
assert len(photos) == 6
def test_multi_album():
import osxphotos
photosdb = osxphotos.PhotosDB(PHOTOS_DB)
photos = photosdb.photos(albums=["Pumpkin Farm", "Test Album"])
assert len(photos) == 3
def test_multi_person():
import osxphotos
photosdb = osxphotos.PhotosDB(PHOTOS_DB)
photos = photosdb.photos(persons=["Katie", "Suzy"])
assert len(photos) == 3

View File

@@ -185,7 +185,11 @@ def test_subst_multi_2_1_1():
photo = photosdb.photos(uuid=[UUID_DICT["2_1_1"]])[0] photo = photosdb.photos(uuid=[UUID_DICT["2_1_1"]])[0]
template = "{created.year}/{album}/{keyword}/{person}" template = "{created.year}/{album}/{keyword}/{person}"
expected = ["2018/Pumpkin Farm/Kids/Katie", "2018/Test Album/Kids/Katie"] expected = [
"2018/Pumpkin Farm/Kids/Katie",
"2018/Test Album/Kids/Katie",
"2018/Multi Keyword/Kids/Katie",
]
rendered, _ = render_filepath_template(template, photo) rendered, _ = render_filepath_template(template, photo)
assert sorted(rendered) == sorted(expected) assert sorted(rendered) == sorted(expected)