mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
Added partial is_bundle() support for Tiger (I hadn't noticed that typeOfFile:error: was Leopard only).
--HG-- extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%40132
This commit is contained in:
parent
cc1bb76c07
commit
3cf2839dc3
@ -20,16 +20,19 @@ from hsutil.str import get_file_ext
|
|||||||
from . import app_cocoa, data
|
from . import app_cocoa, data
|
||||||
from .directories import Directories as DirectoriesBase, STATE_EXCLUDED
|
from .directories import Directories as DirectoriesBase, STATE_EXCLUDED
|
||||||
|
|
||||||
def is_bundle(path):
|
if NSWorkspace.sharedWorkspace().respondsToSelector_('typeOfFile:error:'): # Only from 10.5
|
||||||
sw = NSWorkspace.sharedWorkspace()
|
def is_bundle(str_path):
|
||||||
uti, error = sw.typeOfFile_error_(path)
|
sw = NSWorkspace.sharedWorkspace()
|
||||||
if error is not None:
|
uti, error = sw.typeOfFile_error_(str_path)
|
||||||
logging.warning(u'There was an error trying to detect the UTI of %s', path)
|
if error is not None:
|
||||||
return sw.type_conformsToType_(uti, 'com.apple.bundle') or sw.type_conformsToType_(uti, 'com.apple.package')
|
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')
|
||||||
|
|
||||||
class DGDirectory(DirectoryBase):
|
class DGDirectory(DirectoryBase):
|
||||||
def _create_sub_file(self, name, with_parent=True):
|
def _create_sub_file(self, name, with_parent=True):
|
||||||
ext = get_file_ext(name)
|
|
||||||
if is_bundle(unicode(self.path + name)):
|
if is_bundle(unicode(self.path + name)):
|
||||||
parent = self if with_parent else None
|
parent = self if with_parent else None
|
||||||
return Bundle(parent, name)
|
return Bundle(parent, name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user