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:
parent
d075218621
commit
719edb6b6e
@ -6,14 +6,14 @@
|
|||||||
# 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
|
||||||
|
|
||||||
import objc
|
|
||||||
from Foundation import (NSNotificationCenter, NSUserDefaults, NSSearchPathForDirectoriesInDomains,
|
|
||||||
NSApplicationSupportDirectory, NSUserDomainMask)
|
|
||||||
import logging
|
import logging
|
||||||
import os.path as op
|
import os.path as op
|
||||||
|
|
||||||
from hsutil import cocoa, job
|
from hsutil import cocoa, job
|
||||||
from hsutil.cocoa import install_exception_hook
|
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.misc import stripnone
|
||||||
from hsutil.reg import RegistrationRequired
|
from hsutil.reg import RegistrationRequired
|
||||||
|
|
||||||
@ -54,15 +54,10 @@ class DupeGuru(app.DupeGuru):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _recycle_dupe(dupe):
|
def _recycle_dupe(dupe):
|
||||||
# local import because first appkit import takes a lot of memory. we want to avoid it.
|
# 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])
|
directory = unicode(dupe.path[:-1])
|
||||||
filename = dupe.name
|
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_(
|
||||||
result, tag = NSWorkspace.sharedWorkspace().performFileOperation_source_destination_files_tag_(
|
NSWorkspaceRecycleOperation, directory, '', [filename], None)
|
||||||
NSWorkspaceRecycleOperation, directory, '', [filename])
|
|
||||||
else:
|
|
||||||
result, tag = NSWorkspace.sharedWorkspace().performFileOperation_source_destination_files_tag_(
|
|
||||||
NSWorkspaceRecycleOperation, directory, '', [filename], None)
|
|
||||||
|
|
||||||
def _start_job(self, jobid, func):
|
def _start_job(self, jobid, func):
|
||||||
try:
|
try:
|
||||||
@ -117,7 +112,6 @@ class DupeGuru(app.DupeGuru):
|
|||||||
|
|
||||||
def OpenSelected(self):
|
def OpenSelected(self):
|
||||||
# local import because first appkit import takes a lot of memory. we want to avoid it.
|
# local import because first appkit import takes a lot of memory. we want to avoid it.
|
||||||
from AppKit import NSWorkspace
|
|
||||||
if self.selected_dupes:
|
if self.selected_dupes:
|
||||||
path = unicode(self.selected_dupes[0].path)
|
path = unicode(self.selected_dupes[0].path)
|
||||||
NSWorkspace.sharedWorkspace().openFile_(path)
|
NSWorkspace.sharedWorkspace().openFile_(path)
|
||||||
@ -154,7 +148,6 @@ class DupeGuru(app.DupeGuru):
|
|||||||
|
|
||||||
def RevealSelected(self):
|
def RevealSelected(self):
|
||||||
# local import because first appkit import takes a lot of memory. we want to avoid it.
|
# local import because first appkit import takes a lot of memory. we want to avoid it.
|
||||||
from AppKit import NSWorkspace
|
|
||||||
if self.selected_dupes:
|
if self.selected_dupes:
|
||||||
path = unicode(self.selected_dupes[0].path)
|
path = unicode(self.selected_dupes[0].path)
|
||||||
NSWorkspace.sharedWorkspace().selectFile_inFileViewerRootedAtPath_(path,'')
|
NSWorkspace.sharedWorkspace().selectFile_inFileViewerRootedAtPath_(path,'')
|
||||||
|
@ -9,8 +9,7 @@
|
|||||||
|
|
||||||
# Common interface for all editions' dg_cocoa unit.
|
# Common interface for all editions' dg_cocoa unit.
|
||||||
|
|
||||||
import objc
|
from hsutil.cocoa.objcmin import NSObject
|
||||||
from Foundation import NSObject
|
|
||||||
|
|
||||||
from hsutil.cocoa import signature
|
from hsutil.cocoa import signature
|
||||||
from hsutil.reg import InvalidCodeError
|
from hsutil.reg import InvalidCodeError
|
||||||
|
@ -11,13 +11,13 @@ import logging
|
|||||||
import plistlib
|
import plistlib
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from Foundation import NSUserDefaults, NSURL
|
|
||||||
from appscript import app, k, CommandError
|
from appscript import app, k, CommandError
|
||||||
|
|
||||||
from hsutil import io
|
from hsutil import io
|
||||||
from hsutil.str import get_file_ext
|
from hsutil.str import get_file_ext
|
||||||
from hsutil.path import Path
|
from hsutil.path import Path
|
||||||
from hsutil.cocoa import as_fetch
|
from hsutil.cocoa import as_fetch
|
||||||
|
from hsutil.cocoa.objcmin import NSUserDefaults, NSURL
|
||||||
|
|
||||||
from core import fs
|
from core import fs
|
||||||
from core import app_cocoa, directories
|
from core import app_cocoa, directories
|
||||||
|
@ -10,11 +10,9 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import objc
|
|
||||||
from AppKit import NSWorkspace
|
|
||||||
|
|
||||||
from hsutil import io
|
from hsutil import io
|
||||||
from hsutil.path import Path
|
from hsutil.path import Path
|
||||||
|
from hsutil.cocoa.objcmin import NSWorkspace
|
||||||
|
|
||||||
from core import fs
|
from core import fs
|
||||||
from core.app_cocoa import DupeGuru as DupeGuruBase
|
from core.app_cocoa import DupeGuru as DupeGuruBase
|
||||||
@ -24,10 +22,7 @@ from .fs import Bundle as BundleBase
|
|||||||
|
|
||||||
def is_bundle(str_path):
|
def is_bundle(str_path):
|
||||||
sw = NSWorkspace.sharedWorkspace()
|
sw = NSWorkspace.sharedWorkspace()
|
||||||
if objc.__version__ == '1.4': # For a while, we have to support this.
|
uti, error = sw.typeOfFile_error_(str_path, None)
|
||||||
uti, error = sw.typeOfFile_error_(str_path)
|
|
||||||
else:
|
|
||||||
uti, error = sw.typeOfFile_error_(str_path, None)
|
|
||||||
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')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user