From 97872fc086fdc66ab5482ce7db3e5f63ba4b91d7 Mon Sep 17 00:00:00 2001 From: hsoft Date: Sat, 6 Jun 2009 19:55:33 +0000 Subject: [PATCH] [#23 state:fixed] Wrapped KeyError in prefs for iPhotoDatabase into a InvalidPathError. --HG-- extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%4010 --- py/app.py | 4 +--- py/app_pe_cocoa.py | 13 ++++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/py/app.py b/py/app.py index 0e03603d..5e0a5f07 100644 --- a/py/app.py +++ b/py/app.py @@ -19,9 +19,7 @@ from hsutil.reg import RegistrableApplication, RegistrationRequired from hsutil.misc import flatten, first from hsutil.str import escape -import directories -import results -import scanner +from . import directories, results, scanner JOB_SCAN = 'job_scan' JOB_LOAD = 'job_load' diff --git a/py/app_pe_cocoa.py b/py/app_pe_cocoa.py index eee96086..6d3b22e9 100644 --- a/py/app_pe_cocoa.py +++ b/py/app_pe_cocoa.py @@ -133,6 +133,8 @@ class DupeGuruPE(app_cocoa.DupeGuru): def _create_iphoto_library(self): ud = NSUserDefaults.standardUserDefaults() prefs = ud.persistentDomainForName_('com.apple.iApps') + if 'iPhotoRecentDatabases' not in prefs: + raise directories.InvalidPathError plisturl = NSURL.URLWithString_(prefs['iPhotoRecentDatabases'][0]) plistpath = Path(plisturl.path()) return IPhotoLibrary(plistpath) @@ -185,13 +187,10 @@ class DupeGuruPE(app_cocoa.DupeGuru): return result def AddDirectory(self, d): - try: - added = self.directories.add_path(Path(d)) - if d == 'iPhoto Library': - added.update() - return 0 - except directories.AlreadyThereError: - return 1 + result = app_cocoa.DupeGuru.AddDirectory(self, d) + if (result == 0) and (d == 'iPhoto Library'): + added.update() + return result def CopyOrMove(self, dupe, copy, destination, dest_type): if isinstance(dupe, IPhoto):