From 0a06e52d65923257574e11ae9e5372cfd5a6ba15 Mon Sep 17 00:00:00 2001 From: hsoft Date: Fri, 30 Oct 2009 16:24:34 +0000 Subject: [PATCH] dg cocoa: adjusted to pyobjc upgrade (functions with multiple return values now require None placeholders to be placed at the places of the output arguments) and removed a couple of forgotten "dupe.parent". --HG-- extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%40237 --- base/py/app.py | 2 -- base/py/app_cocoa.py | 12 ++---------- base/py/tests/directories_test.py | 10 +++++----- se/py/app_cocoa.py | 18 ++++++++---------- 4 files changed, 15 insertions(+), 27 deletions(-) diff --git a/base/py/app.py b/base/py/app.py index f21cb4e4..f4301814 100644 --- a/base/py/app.py +++ b/base/py/app.py @@ -70,12 +70,10 @@ class DupeGuru(RegistrableApplication): def _do_delete_dupe(self, dupe): if not io.exists(dupe.path): - dupe.parent = None return True self._recycle_dupe(dupe) self.clean_empty_dirs(dupe.path[:-1]) if not io.exists(dupe.path): - dupe.parent = None return True logging.warning("Could not send {0} to trash.".format(unicode(dupe.path))) return False diff --git a/base/py/app_cocoa.py b/base/py/app_cocoa.py index 780388bb..6169cd5b 100644 --- a/base/py/app_cocoa.py +++ b/base/py/app_cocoa.py @@ -53,18 +53,10 @@ class DupeGuru(app.DupeGuru): #--- Override @staticmethod def _recycle_dupe(dupe): - if not io.exists(dupe.path): - dupe.parent = None - return True - directory = unicode(dupe.parent.path) + directory = unicode(dupe.path[:-1]) filename = dupe.name result, tag = NSWorkspace.sharedWorkspace().performFileOperation_source_destination_files_tag_( - NSWorkspaceRecycleOperation, directory, '', [filename]) - if not io.exists(dupe.path): - dupe.parent = None - return True - logging.warning('Could not send %s to trash. tag: %d' % (unicode(dupe.path), tag)) - return False + NSWorkspaceRecycleOperation, directory, '', [filename], None) def _start_job(self, jobid, func): try: diff --git a/base/py/tests/directories_test.py b/base/py/tests/directories_test.py index 4a550f7a..fa74c6bf 100644 --- a/base/py/tests/directories_test.py +++ b/base/py/tests/directories_test.py @@ -154,13 +154,13 @@ class TCDirectories(TestCase): d.add_path(p) d.set_state(p + 'dir1',STATE_REFERENCE) d.set_state(p + 'dir2',STATE_EXCLUDED) - files = d.get_files() - self.assertEqual(5, len(list(files))) + files = list(d.get_files()) + self.assertEqual(5, len(files)) for f in files: - if f.parent.path == p + 'dir1': - self.assert_(f.is_ref) + if f.path[:-1] == p + 'dir1': + assert f.is_ref else: - self.assert_(not f.is_ref) + assert not f.is_ref def test_get_files_with_inherited_exclusion(self): d = Directories() diff --git a/se/py/app_cocoa.py b/se/py/app_cocoa.py index 4eb58820..fcc9b0ae 100644 --- a/se/py/app_cocoa.py +++ b/se/py/app_cocoa.py @@ -7,6 +7,8 @@ # which should be included with this package. The terms are also available at # http://www.hardcoded.net/licenses/hs_license +from __future__ import unicode_literals + import logging from AppKit import * @@ -21,16 +23,12 @@ from dupeguru.directories import Directories as DirectoriesBase, STATE_EXCLUDED from . import data from .fs import Bundle as BundleBase -if NSWorkspace.sharedWorkspace().respondsToSelector_('typeOfFile:error:'): # Only from 10.5 - def is_bundle(str_path): - sw = NSWorkspace.sharedWorkspace() - uti, error = sw.typeOfFile_error_(str_path) - if error is not None: - logging.warning(u'There was an error trying to detect the UTI of %s', str_path) - return sw.type_conformsToType_(uti, 'com.apple.bundle') or sw.type_conformsToType_(uti, 'com.apple.package') -else: # Tiger - def is_bundle(str_path): # just return a list of a few known bundle extensions. - return get_file_ext(str_path) in ('app', 'pages', 'numbers') +def is_bundle(str_path): + sw = NSWorkspace.sharedWorkspace() + uti, error = sw.typeOfFile_error_(str_path, None) + if error is not None: + logging.warning(u'There was an error trying to detect the UTI of %s', str_path) + return sw.type_conformsToType_(uti, 'com.apple.bundle') or sw.type_conformsToType_(uti, 'com.apple.package') class Bundle(BundleBase): @classmethod