Bug fix for keywords, persons in deleted photos
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
""" version info """
|
""" version info """
|
||||||
|
|
||||||
__version__ = "0.30.6"
|
__version__ = "0.30.7"
|
||||||
|
|||||||
@@ -541,7 +541,7 @@ class PhotosDB:
|
|||||||
""" select RKPerson.name, RKVersion.uuid from RKFace, RKPerson, RKVersion, RKMaster
|
""" select RKPerson.name, RKVersion.uuid from RKFace, RKPerson, RKVersion, RKMaster
|
||||||
where RKFace.personID = RKperson.modelID and RKVersion.modelId = RKFace.ImageModelId
|
where RKFace.personID = RKperson.modelID and RKVersion.modelId = RKFace.ImageModelId
|
||||||
and RKVersion.masterUuid = RKMaster.uuid
|
and RKVersion.masterUuid = RKMaster.uuid
|
||||||
and RKVersion.isInTrash = 0 """
|
"""
|
||||||
)
|
)
|
||||||
for person in c:
|
for person in c:
|
||||||
if person[0] is None:
|
if person[0] is None:
|
||||||
@@ -561,7 +561,7 @@ class PhotosDB:
|
|||||||
from RKAlbum, RKVersion, RKAlbumVersion
|
from RKAlbum, RKVersion, RKAlbumVersion
|
||||||
where RKAlbum.modelID = RKAlbumVersion.albumId and
|
where RKAlbum.modelID = RKAlbumVersion.albumId and
|
||||||
RKAlbumVersion.versionID = RKVersion.modelId
|
RKAlbumVersion.versionID = RKVersion.modelId
|
||||||
and RKVersion.isInTrash = 0 """
|
"""
|
||||||
)
|
)
|
||||||
for album in c:
|
for album in c:
|
||||||
# store by uuid in _dbalbums_uuid and by album in _dbalbums_album
|
# store by uuid in _dbalbums_uuid and by album in _dbalbums_album
|
||||||
@@ -680,12 +680,17 @@ class PhotosDB:
|
|||||||
|
|
||||||
# Get info on keywords
|
# Get info on keywords
|
||||||
c.execute(
|
c.execute(
|
||||||
""" select RKKeyword.name, RKVersion.uuid, RKMaster.uuid from
|
""" SELECT
|
||||||
|
RKKeyword.name,
|
||||||
|
RKVersion.uuid,
|
||||||
|
RKMaster.uuid
|
||||||
|
FROM
|
||||||
RKKeyword, RKKeywordForVersion, RKVersion, RKMaster
|
RKKeyword, RKKeywordForVersion, RKVersion, RKMaster
|
||||||
where RKKeyword.modelId = RKKeyWordForVersion.keywordID and
|
WHERE
|
||||||
RKVersion.modelID = RKKeywordForVersion.versionID and
|
RKKeyword.modelId = RKKeyWordForVersion.keywordID AND
|
||||||
RKMaster.uuid = RKVersion.masterUuid and
|
RKVersion.modelID = RKKeywordForVersion.versionID AND
|
||||||
RKVersion.isInTrash = 0 """
|
RKMaster.uuid = RKVersion.masterUuid
|
||||||
|
"""
|
||||||
)
|
)
|
||||||
for keyword in c:
|
for keyword in c:
|
||||||
if not keyword[1] in self._dbkeywords_uuid:
|
if not keyword[1] in self._dbkeywords_uuid:
|
||||||
@@ -1750,7 +1755,6 @@ class PhotosDB:
|
|||||||
"FROM ZGENERICASSET, ZUNMANAGEDADJUSTMENT "
|
"FROM ZGENERICASSET, ZUNMANAGEDADJUSTMENT "
|
||||||
"JOIN ZADDITIONALASSETATTRIBUTES ON ZADDITIONALASSETATTRIBUTES.ZASSET = ZGENERICASSET.Z_PK "
|
"JOIN ZADDITIONALASSETATTRIBUTES ON ZADDITIONALASSETATTRIBUTES.ZASSET = ZGENERICASSET.Z_PK "
|
||||||
"WHERE ZADDITIONALASSETATTRIBUTES.ZUNMANAGEDADJUSTMENT = ZUNMANAGEDADJUSTMENT.Z_PK "
|
"WHERE ZADDITIONALASSETATTRIBUTES.ZUNMANAGEDADJUSTMENT = ZUNMANAGEDADJUSTMENT.Z_PK "
|
||||||
"AND ZGENERICASSET.ZTRASHEDSTATE = 0 "
|
|
||||||
)
|
)
|
||||||
for row in c:
|
for row in c:
|
||||||
uuid = row[0]
|
uuid = row[0]
|
||||||
|
|||||||
Binary file not shown.
@@ -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>763</integer>
|
<integer>1613</integer>
|
||||||
<key>processname</key>
|
<key>processname</key>
|
||||||
<string>photolibraryd</string>
|
<string>photolibraryd</string>
|
||||||
<key>uid</key>
|
<key>uid</key>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 524 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 196 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7,9 +7,9 @@ PHOTOS_DB = "tests/Test-10.15.5.photoslibrary/database/photos.db"
|
|||||||
PHOTOS_DB_PATH = "/Test-10.15.5.photoslibrary/database/photos.db"
|
PHOTOS_DB_PATH = "/Test-10.15.5.photoslibrary/database/photos.db"
|
||||||
PHOTOS_LIBRARY_PATH = "/Test-10.15.5.photoslibrary"
|
PHOTOS_LIBRARY_PATH = "/Test-10.15.5.photoslibrary"
|
||||||
|
|
||||||
PHOTOS_DB_LEN = 14
|
PHOTOS_DB_LEN = 15
|
||||||
PHOTOS_NOT_IN_TRASH_LEN = 13
|
PHOTOS_NOT_IN_TRASH_LEN = 13
|
||||||
PHOTOS_IN_TRASH_LEN = 1
|
PHOTOS_IN_TRASH_LEN = 2
|
||||||
|
|
||||||
KEYWORDS = [
|
KEYWORDS = [
|
||||||
"Kids",
|
"Kids",
|
||||||
@@ -34,7 +34,7 @@ ALBUMS = [
|
|||||||
]
|
]
|
||||||
KEYWORDS_DICT = {
|
KEYWORDS_DICT = {
|
||||||
"Kids": 4,
|
"Kids": 4,
|
||||||
"wedding": 2,
|
"wedding": 3,
|
||||||
"flowers": 1,
|
"flowers": 1,
|
||||||
"England": 1,
|
"England": 1,
|
||||||
"London": 1,
|
"London": 1,
|
||||||
@@ -43,7 +43,7 @@ KEYWORDS_DICT = {
|
|||||||
"UK": 1,
|
"UK": 1,
|
||||||
"United Kingdom": 1,
|
"United Kingdom": 1,
|
||||||
}
|
}
|
||||||
PERSONS_DICT = {"Katie": 3, "Suzy": 2, "Maria": 1, _UNKNOWN_PERSON: 1}
|
PERSONS_DICT = {"Katie": 3, "Suzy": 2, "Maria": 2, _UNKNOWN_PERSON: 1}
|
||||||
ALBUM_DICT = {
|
ALBUM_DICT = {
|
||||||
"Pumpkin Farm": 3,
|
"Pumpkin Farm": 3,
|
||||||
"Test Album": 2,
|
"Test Album": 2,
|
||||||
@@ -71,6 +71,7 @@ UUID_DICT = {
|
|||||||
"date_invalid": "8846E3E6-8AC8-4857-8448-E3D025784410",
|
"date_invalid": "8846E3E6-8AC8-4857-8448-E3D025784410",
|
||||||
"intrash": "71E3E212-00EB-430D-8A63-5E294B268554",
|
"intrash": "71E3E212-00EB-430D-8A63-5E294B268554",
|
||||||
"not_intrash": "DC99FBDD-7A52-4100-A5BB-344131646C30",
|
"not_intrash": "DC99FBDD-7A52-4100-A5BB-344131646C30",
|
||||||
|
"intrash_person_keywords": "6FD38366-3BF2-407D-81FE-7153EB6125B6",
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID_PUMPKIN_FARM = [
|
UUID_PUMPKIN_FARM = [
|
||||||
@@ -195,7 +196,7 @@ def test_keywords_dict():
|
|||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
keywords = photosdb.keywords_as_dict
|
keywords = photosdb.keywords_as_dict
|
||||||
assert keywords["wedding"] == 2
|
assert keywords["wedding"] == 3
|
||||||
assert keywords == KEYWORDS_DICT
|
assert keywords == KEYWORDS_DICT
|
||||||
|
|
||||||
|
|
||||||
@@ -204,7 +205,7 @@ def test_persons_as_dict():
|
|||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
persons = photosdb.persons_as_dict
|
persons = photosdb.persons_as_dict
|
||||||
assert persons["Maria"] == 1
|
assert persons["Maria"] == 2
|
||||||
assert persons == PERSONS_DICT
|
assert persons == PERSONS_DICT
|
||||||
|
|
||||||
|
|
||||||
@@ -459,7 +460,7 @@ def test_photos_intrash_2():
|
|||||||
assert p.intrash
|
assert p.intrash
|
||||||
|
|
||||||
|
|
||||||
def test_photos_intrash_2():
|
def test_photos_intrash_3():
|
||||||
""" test PhotosDB.photos(intrash=False) """
|
""" test PhotosDB.photos(intrash=False) """
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
@@ -487,6 +488,39 @@ def test_photoinfo_intrash_2():
|
|||||||
assert not p
|
assert not p
|
||||||
|
|
||||||
|
|
||||||
|
def test_photoinfo_intrash_3():
|
||||||
|
""" Test PhotoInfo.intrash and photo has keyword and person """
|
||||||
|
import osxphotos
|
||||||
|
|
||||||
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
|
p = photosdb.photos(uuid=[UUID_DICT["intrash_person_keywords"]], intrash=True)[0]
|
||||||
|
assert p.intrash
|
||||||
|
assert "Maria" in p.persons
|
||||||
|
assert "wedding" in p.keywords
|
||||||
|
|
||||||
|
|
||||||
|
def test_photoinfo_intrash_4():
|
||||||
|
""" Test PhotoInfo.intrash and photo has keyword and person """
|
||||||
|
import osxphotos
|
||||||
|
|
||||||
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
|
p = photosdb.photos(persons=["Maria"], intrash=True)[0]
|
||||||
|
assert p.intrash
|
||||||
|
assert "Maria" in p.persons
|
||||||
|
assert "wedding" in p.keywords
|
||||||
|
|
||||||
|
|
||||||
|
def test_photoinfo_intrash_5():
|
||||||
|
""" Test PhotoInfo.intrash and photo has keyword and person """
|
||||||
|
import osxphotos
|
||||||
|
|
||||||
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
|
p = photosdb.photos(keywords=["wedding"], intrash=True)[0]
|
||||||
|
assert p.intrash
|
||||||
|
assert "Maria" in p.persons
|
||||||
|
assert "wedding" in p.keywords
|
||||||
|
|
||||||
|
|
||||||
def test_photoinfo_not_intrash():
|
def test_photoinfo_not_intrash():
|
||||||
""" Test PhotoInfo.intrash """
|
""" Test PhotoInfo.intrash """
|
||||||
import osxphotos
|
import osxphotos
|
||||||
@@ -501,7 +535,7 @@ def test_keyword_2():
|
|||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
photos = photosdb.photos(keywords=["wedding"])
|
photos = photosdb.photos(keywords=["wedding"])
|
||||||
assert len(photos) == 2
|
assert len(photos) == 2 # won't show the one in the trash
|
||||||
|
|
||||||
|
|
||||||
def test_keyword_not_in_album():
|
def test_keyword_not_in_album():
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ PHOTOS_IN_TRASH_LEN_14_6 = 1
|
|||||||
PHOTOS_MISSING_14_6 = 1
|
PHOTOS_MISSING_14_6 = 1
|
||||||
|
|
||||||
PHOTOS_NOT_IN_TRASH_LEN_15_5 = 13
|
PHOTOS_NOT_IN_TRASH_LEN_15_5 = 13
|
||||||
PHOTOS_IN_TRASH_LEN_15_5 = 1
|
PHOTOS_IN_TRASH_LEN_15_5 = 2
|
||||||
PHOTOS_MISSING_15_5 = 2
|
PHOTOS_MISSING_15_5 = 2
|
||||||
|
|
||||||
CLI_PLACES_JSON = """{"places": {"_UNKNOWN_": 1, "Maui, Wailea, Hawai'i, United States": 1, "Washington, District of Columbia, United States": 1}}"""
|
CLI_PLACES_JSON = """{"places": {"_UNKNOWN_": 1, "Maui, Wailea, Hawai'i, United States": 1, "Washington, District of Columbia, United States": 1}}"""
|
||||||
@@ -260,7 +260,7 @@ LABELS_JSON = {
|
|||||||
KEYWORDS_JSON = {
|
KEYWORDS_JSON = {
|
||||||
"keywords": {
|
"keywords": {
|
||||||
"Kids": 4,
|
"Kids": 4,
|
||||||
"wedding": 2,
|
"wedding": 3,
|
||||||
"London 2018": 1,
|
"London 2018": 1,
|
||||||
"St. James's Park": 1,
|
"St. James's Park": 1,
|
||||||
"England": 1,
|
"England": 1,
|
||||||
@@ -283,7 +283,7 @@ ALBUMS_JSON = {
|
|||||||
"shared albums": {},
|
"shared albums": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
PERSONS_JSON = {"persons": {"Katie": 3, "Suzy": 2, "_UNKNOWN_": 1, "Maria": 1}}
|
PERSONS_JSON = {"persons": {"Katie": 3, "Suzy": 2, "_UNKNOWN_": 1, "Maria": 2}}
|
||||||
|
|
||||||
# determine if exiftool installed so exiftool tests can be skipped
|
# determine if exiftool installed so exiftool tests can be skipped
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user