From 646ea4f24ca1119b27280af1445e31adcd0690f0 Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Fri, 17 Jan 2020 15:31:07 -0800 Subject: [PATCH] Changed get_system_library_path to return None if could not get system library --- README.md | 2 +- osxphotos/utils.py | 7 ++++--- tests/test_utils.py | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6e4ce611..7f7c3a8c 100644 --- a/README.md +++ b/README.md @@ -692,7 +692,7 @@ The following functions are located in osxphotos.utils #### ```get_system_library_path()``` -**MacOS 10.15 Only** Returns path to System Photo Library as string. On MacOS version < 10.15, raises Exception. +**MacOS 10.15 Only** Returns path to System Photo Library as string. On MacOS version < 10.15, returns None. #### ```get_last_library_path()``` diff --git a/osxphotos/utils.py b/osxphotos/utils.py index 1bdb5a49..ef39f44b 100644 --- a/osxphotos/utils.py +++ b/osxphotos/utils.py @@ -169,12 +169,13 @@ def dd_to_dms_str(lat, lon): def get_system_library_path(): """ return the path to the system Photos library as string """ """ only works on MacOS 10.15+ """ - """ on earlier versions, will raise exception """ + """ on earlier versions, returns None """ _, major, _ = _get_os_version() if int(major) < 15: - raise Exception( - "get_system_library_path not implemented for MacOS < 10.15", major + logging.debug( + f"get_system_library_path not implemented for MacOS < 10.15: you have {major}" ) + return None plist_file = Path( str(Path.home()) diff --git a/tests/test_utils.py b/tests/test_utils.py index cad65cea..27ea5b2c 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -31,8 +31,7 @@ def test_get_system_library_path(): _, major, _ = osxphotos.utils._get_os_version() if int(major) < 15: - with pytest.raises(Exception): - assert osxphotos.utils.get_system_library_path() + assert osxphotos.utils.get_system_library_path() is None else: assert osxphotos.utils.get_system_library_path() is not None