working on photos
This commit is contained in:
@@ -12,9 +12,10 @@ import sys
|
|||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
import pprint
|
import pprint
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from loguru import logger
|
|
||||||
from . import _applescript
|
from . import _applescript
|
||||||
|
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
# replace string formatting with fstrings
|
# replace string formatting with fstrings
|
||||||
|
|
||||||
_debug = False
|
_debug = False
|
||||||
@@ -40,9 +41,11 @@ class PhotosDB:
|
|||||||
system = platform.system()
|
system = platform.system()
|
||||||
(_, major, _) = _get_os_version()
|
(_, major, _) = _get_os_version()
|
||||||
logger.debug(system, major)
|
logger.debug(system, major)
|
||||||
if (system != 'Darwin') or (major != '13'):
|
if (system != "Darwin") or (major != "13"):
|
||||||
logger.warning("WARNING: This module has only been tested with MacOS 10.13: "
|
logger.warning(
|
||||||
+ f"{system}, OS version: {major}")
|
"WARNING: This module has only been tested with MacOS 10.13: "
|
||||||
|
+ f"{system}, OS version: {major}"
|
||||||
|
)
|
||||||
|
|
||||||
# Dict with information about all photos by uuid
|
# Dict with information about all photos by uuid
|
||||||
self._dbphotos = {}
|
self._dbphotos = {}
|
||||||
@@ -489,11 +492,14 @@ class PhotosDB:
|
|||||||
If more than one arg, returns photos matching all the criteria (e.g. keywords AND persons)
|
If more than one arg, returns photos matching all the criteria (e.g. keywords AND persons)
|
||||||
TODO: Still need to fix AND
|
TODO: Still need to fix AND
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def photos(self, keywords=[], uuid=[], persons=[], albums=[]):
|
def photos(self, keywords=[], uuid=[], persons=[], albums=[]):
|
||||||
photos = [] # list of photos (PhotoInfo objects) that will be returned
|
#TODO: combine photos and photos_sets, I think only one needed
|
||||||
photos_sets = [] # list of sets to perform intersection of
|
photos = [] # list of photos (PhotoInfo objects) that will be returned
|
||||||
|
photos_sets = [] # list of sets to perform intersection of
|
||||||
if not keywords and not uuid and not persons and not albums:
|
if not keywords and not uuid and not persons and not albums:
|
||||||
# return all the photos
|
# return all the photos
|
||||||
|
logger.debug("return all photos")
|
||||||
photos = list(self._dbphotos.keys())
|
photos = list(self._dbphotos.keys())
|
||||||
else:
|
else:
|
||||||
if albums:
|
if albums:
|
||||||
@@ -503,9 +509,7 @@ class PhotosDB:
|
|||||||
logger.info("processing album %s:" % album)
|
logger.info("processing album %s:" % album)
|
||||||
photos_sets.append(set(self._dbalbums_album[album]))
|
photos_sets.append(set(self._dbalbums_album[album]))
|
||||||
else:
|
else:
|
||||||
logger.debug(
|
logger.debug("Could not find album '%s' in database" % (album))
|
||||||
"Could not find album '%s' in database" % (album),
|
|
||||||
)
|
|
||||||
|
|
||||||
if uuid:
|
if uuid:
|
||||||
for u in uuid:
|
for u in uuid:
|
||||||
@@ -514,9 +518,7 @@ class PhotosDB:
|
|||||||
logger.info("processing uuid %s:" % u)
|
logger.info("processing uuid %s:" % u)
|
||||||
photos_sets.append(set([u]))
|
photos_sets.append(set([u]))
|
||||||
else:
|
else:
|
||||||
logger.debug(
|
logger.debug("Could not find uuid '%s' in database" % (u))
|
||||||
"Could not find uuid '%s' in database" % (u),
|
|
||||||
)
|
|
||||||
|
|
||||||
if keywords:
|
if keywords:
|
||||||
for keyword in keywords:
|
for keyword in keywords:
|
||||||
@@ -527,7 +529,7 @@ class PhotosDB:
|
|||||||
logger.debug(f"photos_sets {photos_sets}")
|
logger.debug(f"photos_sets {photos_sets}")
|
||||||
else:
|
else:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Could not find keyword '%s' in database" % (keyword),
|
"Could not find keyword '%s' in database" % (keyword)
|
||||||
)
|
)
|
||||||
|
|
||||||
if persons:
|
if persons:
|
||||||
@@ -538,11 +540,11 @@ class PhotosDB:
|
|||||||
photos_sets.append(set(self._dbfaces_person[person]))
|
photos_sets.append(set(self._dbfaces_person[person]))
|
||||||
else:
|
else:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Could not find person '%s' in database" % (person),
|
"Could not find person '%s' in database" % (person)
|
||||||
)
|
)
|
||||||
|
|
||||||
photoinfo = []
|
photoinfo = []
|
||||||
if photos_sets: # found some photos
|
if photos_sets: # found some photos
|
||||||
# get the intersection of each argument/search criteria
|
# get the intersection of each argument/search criteria
|
||||||
for p in set.intersection(*photos_sets):
|
for p in set.intersection(*photos_sets):
|
||||||
logger.debug(f"p={p}")
|
logger.debug(f"p={p}")
|
||||||
|
|||||||
Reference in New Issue
Block a user