1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2025-03-10 05:34:36 +00:00

Use hsutil.cocoa.objcmin instead of Foundation and AppKit.

This commit is contained in:
Virgil Dupras 2010-02-04 17:12:58 +01:00
parent d075218621
commit 719edb6b6e
4 changed files with 9 additions and 22 deletions

View File

@ -6,14 +6,14 @@
# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/hs_license
import objc
from Foundation import (NSNotificationCenter, NSUserDefaults, NSSearchPathForDirectoriesInDomains,
NSApplicationSupportDirectory, NSUserDomainMask)
import logging
import os.path as op
from hsutil import cocoa, job
from hsutil.cocoa import install_exception_hook
from hsutil.cocoa.objcmin import (NSNotificationCenter, NSUserDefaults,
NSSearchPathForDirectoriesInDomains, NSApplicationSupportDirectory, NSUserDomainMask,
NSWorkspace, NSWorkspaceRecycleOperation)
from hsutil.misc import stripnone
from hsutil.reg import RegistrationRequired
@ -54,15 +54,10 @@ class DupeGuru(app.DupeGuru):
@staticmethod
def _recycle_dupe(dupe):
# local import because first appkit import takes a lot of memory. we want to avoid it.
from AppKit import NSWorkspace, NSWorkspaceRecycleOperation
directory = unicode(dupe.path[:-1])
filename = dupe.name
if objc.__version__ == '1.4': # For a while, we have to support this.
result, tag = NSWorkspace.sharedWorkspace().performFileOperation_source_destination_files_tag_(
NSWorkspaceRecycleOperation, directory, '', [filename])
else:
result, tag = NSWorkspace.sharedWorkspace().performFileOperation_source_destination_files_tag_(
NSWorkspaceRecycleOperation, directory, '', [filename], None)
result, tag = NSWorkspace.sharedWorkspace().performFileOperation_source_destination_files_tag_(
NSWorkspaceRecycleOperation, directory, '', [filename], None)
def _start_job(self, jobid, func):
try:
@ -117,7 +112,6 @@ class DupeGuru(app.DupeGuru):
def OpenSelected(self):
# local import because first appkit import takes a lot of memory. we want to avoid it.
from AppKit import NSWorkspace
if self.selected_dupes:
path = unicode(self.selected_dupes[0].path)
NSWorkspace.sharedWorkspace().openFile_(path)
@ -154,7 +148,6 @@ class DupeGuru(app.DupeGuru):
def RevealSelected(self):
# local import because first appkit import takes a lot of memory. we want to avoid it.
from AppKit import NSWorkspace
if self.selected_dupes:
path = unicode(self.selected_dupes[0].path)
NSWorkspace.sharedWorkspace().selectFile_inFileViewerRootedAtPath_(path,'')

View File

@ -9,8 +9,7 @@
# Common interface for all editions' dg_cocoa unit.
import objc
from Foundation import NSObject
from hsutil.cocoa.objcmin import NSObject
from hsutil.cocoa import signature
from hsutil.reg import InvalidCodeError

View File

@ -11,13 +11,13 @@ import logging
import plistlib
import re
from Foundation import NSUserDefaults, NSURL
from appscript import app, k, CommandError
from hsutil import io
from hsutil.str import get_file_ext
from hsutil.path import Path
from hsutil.cocoa import as_fetch
from hsutil.cocoa.objcmin import NSUserDefaults, NSURL
from core import fs
from core import app_cocoa, directories

View File

@ -10,11 +10,9 @@ from __future__ import unicode_literals
import logging
import objc
from AppKit import NSWorkspace
from hsutil import io
from hsutil.path import Path
from hsutil.cocoa.objcmin import NSWorkspace
from core import fs
from core.app_cocoa import DupeGuru as DupeGuruBase
@ -24,10 +22,7 @@ from .fs import Bundle as BundleBase
def is_bundle(str_path):
sw = NSWorkspace.sharedWorkspace()
if objc.__version__ == '1.4': # For a while, we have to support this.
uti, error = sw.typeOfFile_error_(str_path)
else:
uti, error = sw.typeOfFile_error_(str_path, None)
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')