Updated exception handling in PhotosDB.__init__()
This commit is contained in:
@@ -269,7 +269,7 @@ class PhotosDB:
|
|||||||
# got a library path as argument
|
# got a library path as argument
|
||||||
if dbfile:
|
if dbfile:
|
||||||
# shouldn't pass via both *args and dbfile=
|
# shouldn't pass via both *args and dbfile=
|
||||||
raise ValueError(
|
raise TypeError(
|
||||||
f"photos database path must be specified as argument or named parameter dbfile but not both: args: {args}, dbfile: {dbfile}",
|
f"photos database path must be specified as argument or named parameter dbfile but not both: args: {args}, dbfile: {dbfile}",
|
||||||
args,
|
args,
|
||||||
dbfile,
|
dbfile,
|
||||||
@@ -277,7 +277,7 @@ class PhotosDB:
|
|||||||
elif len(args) == 1:
|
elif len(args) == 1:
|
||||||
dbfile = args[0]
|
dbfile = args[0]
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise TypeError(
|
||||||
f"__init__ takes only a single argument (photos database path): {args}",
|
f"__init__ takes only a single argument (photos database path): {args}",
|
||||||
args,
|
args,
|
||||||
)
|
)
|
||||||
@@ -285,7 +285,7 @@ class PhotosDB:
|
|||||||
# no args and dbfile not passed, try to get last opened library
|
# no args and dbfile not passed, try to get last opened library
|
||||||
library_path = get_last_library_path()
|
library_path = get_last_library_path()
|
||||||
if not library_path:
|
if not library_path:
|
||||||
raise ValueError("could not get library path")
|
raise FileNotFoundError("could not get library path")
|
||||||
dbfile = os.path.join(library_path, "database/photos.db")
|
dbfile = os.path.join(library_path, "database/photos.db")
|
||||||
|
|
||||||
if os.path.isdir(dbfile):
|
if os.path.isdir(dbfile):
|
||||||
@@ -294,7 +294,7 @@ class PhotosDB:
|
|||||||
|
|
||||||
# if get here, should have a dbfile path; make sure it exists
|
# if get here, should have a dbfile path; make sure it exists
|
||||||
if not _check_file_exists(dbfile):
|
if not _check_file_exists(dbfile):
|
||||||
raise ValueError(f"dbfile {dbfile} does not exist", dbfile)
|
raise FileNotFoundError(f"dbfile {dbfile} does not exist", dbfile)
|
||||||
|
|
||||||
logging.debug(f"dbfile = {dbfile}")
|
logging.debug(f"dbfile = {dbfile}")
|
||||||
|
|
||||||
@@ -1476,7 +1476,7 @@ class PhotoInfo:
|
|||||||
|
|
||||||
# TODO: find better way to do *args
|
# TODO: find better way to do *args
|
||||||
# maybe dest, *filename?
|
# maybe dest, *filename?
|
||||||
|
|
||||||
# check arguments and get destination path and filename (if provided)
|
# check arguments and get destination path and filename (if provided)
|
||||||
dest = None # destination path
|
dest = None # destination path
|
||||||
filename = None # photo filename
|
filename = None # photo filename
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
""" version info """
|
""" version info """
|
||||||
|
|
||||||
__version__ = "0.15.0"
|
__version__ = "0.15.01"
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ UUID_DICT = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_init():
|
def test_init1():
|
||||||
# test named argument
|
# test named argument
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user