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
This commit is contained in:
hsoft 2009-10-30 16:24:34 +00:00
parent e004c0c2d4
commit 0a06e52d65
4 changed files with 15 additions and 27 deletions

View File

@ -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

View File

@ -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:

View File

@ -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()

View File

@ -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