mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
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:
parent
e004c0c2d4
commit
0a06e52d65
@ -70,12 +70,10 @@ class DupeGuru(RegistrableApplication):
|
|||||||
|
|
||||||
def _do_delete_dupe(self, dupe):
|
def _do_delete_dupe(self, dupe):
|
||||||
if not io.exists(dupe.path):
|
if not io.exists(dupe.path):
|
||||||
dupe.parent = None
|
|
||||||
return True
|
return True
|
||||||
self._recycle_dupe(dupe)
|
self._recycle_dupe(dupe)
|
||||||
self.clean_empty_dirs(dupe.path[:-1])
|
self.clean_empty_dirs(dupe.path[:-1])
|
||||||
if not io.exists(dupe.path):
|
if not io.exists(dupe.path):
|
||||||
dupe.parent = None
|
|
||||||
return True
|
return True
|
||||||
logging.warning("Could not send {0} to trash.".format(unicode(dupe.path)))
|
logging.warning("Could not send {0} to trash.".format(unicode(dupe.path)))
|
||||||
return False
|
return False
|
||||||
|
@ -53,18 +53,10 @@ class DupeGuru(app.DupeGuru):
|
|||||||
#--- Override
|
#--- Override
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _recycle_dupe(dupe):
|
def _recycle_dupe(dupe):
|
||||||
if not io.exists(dupe.path):
|
directory = unicode(dupe.path[:-1])
|
||||||
dupe.parent = None
|
|
||||||
return True
|
|
||||||
directory = unicode(dupe.parent.path)
|
|
||||||
filename = dupe.name
|
filename = dupe.name
|
||||||
result, tag = NSWorkspace.sharedWorkspace().performFileOperation_source_destination_files_tag_(
|
result, tag = NSWorkspace.sharedWorkspace().performFileOperation_source_destination_files_tag_(
|
||||||
NSWorkspaceRecycleOperation, directory, '', [filename])
|
NSWorkspaceRecycleOperation, directory, '', [filename], None)
|
||||||
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
|
|
||||||
|
|
||||||
def _start_job(self, jobid, func):
|
def _start_job(self, jobid, func):
|
||||||
try:
|
try:
|
||||||
|
@ -154,13 +154,13 @@ class TCDirectories(TestCase):
|
|||||||
d.add_path(p)
|
d.add_path(p)
|
||||||
d.set_state(p + 'dir1',STATE_REFERENCE)
|
d.set_state(p + 'dir1',STATE_REFERENCE)
|
||||||
d.set_state(p + 'dir2',STATE_EXCLUDED)
|
d.set_state(p + 'dir2',STATE_EXCLUDED)
|
||||||
files = d.get_files()
|
files = list(d.get_files())
|
||||||
self.assertEqual(5, len(list(files)))
|
self.assertEqual(5, len(files))
|
||||||
for f in files:
|
for f in files:
|
||||||
if f.parent.path == p + 'dir1':
|
if f.path[:-1] == p + 'dir1':
|
||||||
self.assert_(f.is_ref)
|
assert f.is_ref
|
||||||
else:
|
else:
|
||||||
self.assert_(not f.is_ref)
|
assert not f.is_ref
|
||||||
|
|
||||||
def test_get_files_with_inherited_exclusion(self):
|
def test_get_files_with_inherited_exclusion(self):
|
||||||
d = Directories()
|
d = Directories()
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
# which should be included with this package. The terms are also available at
|
# which should be included with this package. The terms are also available at
|
||||||
# http://www.hardcoded.net/licenses/hs_license
|
# http://www.hardcoded.net/licenses/hs_license
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from AppKit import *
|
from AppKit import *
|
||||||
@ -21,16 +23,12 @@ from dupeguru.directories import Directories as DirectoriesBase, STATE_EXCLUDED
|
|||||||
from . import data
|
from . import data
|
||||||
from .fs import Bundle as BundleBase
|
from .fs import Bundle as BundleBase
|
||||||
|
|
||||||
if NSWorkspace.sharedWorkspace().respondsToSelector_('typeOfFile:error:'): # Only from 10.5
|
def is_bundle(str_path):
|
||||||
def is_bundle(str_path):
|
sw = NSWorkspace.sharedWorkspace()
|
||||||
sw = NSWorkspace.sharedWorkspace()
|
uti, error = sw.typeOfFile_error_(str_path, None)
|
||||||
uti, error = sw.typeOfFile_error_(str_path)
|
if error is not None:
|
||||||
if error is not None:
|
logging.warning(u'There was an error trying to detect the UTI of %s', str_path)
|
||||||
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')
|
||||||
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')
|
|
||||||
|
|
||||||
class Bundle(BundleBase):
|
class Bundle(BundleBase):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user