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

Merge with objp branch.

This commit is contained in:
Virgil Dupras 2012-01-05 17:20:02 -05:00
commit d62bfac95e
18 changed files with 55 additions and 53 deletions

View File

@ -6,6 +6,7 @@ run.py
*.so *.so
*.mo *.mo
*.pyd *.pyd
.tm_*
*.xcodeproj/xcuserdata *.xcodeproj/xcuserdata
*.xcodeproj/project.xcworkspace/xcuserdata *.xcodeproj/project.xcworkspace/xcuserdata
conf.json conf.json

View File

@ -12,8 +12,7 @@ from optparse import OptionParser
import shutil import shutil
import json import json
from setuptools import setup from setuptools import setup, Extension
from distutils.extension import Extension
from hscommon import sphinxgen from hscommon import sphinxgen
from hscommon.build import (add_to_pythonpath, print_and_do, copy_packages, filereplace, from hscommon.build import (add_to_pythonpath, print_and_do, copy_packages, filereplace,
@ -38,17 +37,15 @@ def parse_args():
def build_cocoa(edition, dev): def build_cocoa(edition, dev):
from pluginbuilder import build_plugin from pluginbuilder import build_plugin
build_cocoa_proxy_module()
print("Building dg_cocoa.plugin") print("Building dg_cocoa.plugin")
if dev: specific_packages = {
tocopy = ['cocoa/inter'] 'se': ['core_se'],
else: 'me': ['core_me'],
specific_packages = { 'pe': ['core_pe'],
'se': ['core_se'], }[edition]
'me': ['core_me'], tocopy = ['core', 'hscommon', 'cocoa/inter', 'cocoalib/cocoa'] + specific_packages
'pe': ['core_pe'], copy_packages(tocopy, 'build', create_links=dev)
}[edition]
tocopy = ['core', 'hscommon', 'cocoa/inter'] + specific_packages
copy_packages(tocopy, 'build')
cocoa_project_path = 'cocoa/{0}'.format(edition) cocoa_project_path = 'cocoa/{0}'.format(edition)
shutil.copy(op.join(cocoa_project_path, 'dg_cocoa.py'), 'build') shutil.copy(op.join(cocoa_project_path, 'dg_cocoa.py'), 'build')
os.chdir('build') os.chdir('build')
@ -59,11 +56,6 @@ def build_cocoa(edition, dev):
if op.exists(pluginpath): if op.exists(pluginpath):
shutil.rmtree(pluginpath) shutil.rmtree(pluginpath)
shutil.move('build/dist/dg_cocoa.plugin', pluginpath) shutil.move('build/dist/dg_cocoa.plugin', pluginpath)
if dev:
# In alias mode, the tweakings we do to the pythonpath aren't counted in. We have to
# manually put a .pth in the plugin
pthpath = op.join(pluginpath, 'Contents/Resources/dev.pth')
open(pthpath, 'w').write(op.abspath('.'))
os.chdir(cocoa_project_path) os.chdir(cocoa_project_path)
print('Generating Info.plist') print('Generating Info.plist')
app_version = get_module_version('core_{}'.format(edition)) app_version = get_module_version('core_{}'.format(edition))
@ -163,6 +155,20 @@ def build_mergepot():
loc.merge_pots_into_pos(op.join('hscommon', 'locale')) loc.merge_pots_into_pos(op.join('hscommon', 'locale'))
loc.merge_pots_into_pos(op.join('qtlib', 'locale')) loc.merge_pots_into_pos(op.join('qtlib', 'locale'))
def build_cocoa_proxy_module():
print("Building Cocoa Proxy")
import objp.p2o
objp.p2o.generate_python_proxy_code('cocoalib/cocoa/CocoaProxy.h', 'build/CocoaProxy.m')
exts = [
Extension("CocoaProxy", ['cocoalib/cocoa/CocoaProxy.m', 'build/CocoaProxy.m', 'build/ObjP.m'],
extra_link_args=["-framework", "CoreFoundation", "-framework", "Foundation", "-framework", "AppKit"]),
]
setup(
script_args = ['build_ext', '--inplace'],
ext_modules = exts,
)
move_all('CocoaProxy*', 'cocoalib/cocoa')
def build_pe_modules(ui): def build_pe_modules(ui):
print("Building PE Modules") print("Building PE Modules")
exts = [ exts = [

View File

@ -1,11 +1,9 @@
import logging import logging
from jobprogress import job from jobprogress import job
from hscommon import cocoa import cocoa
from hscommon.cocoa import install_exception_hook from cocoa import install_exception_hook, proxy
from hscommon.cocoa.inter import signature, subproxy, PyFairware from cocoa.inter import signature, subproxy, PyFairware
from hscommon.cocoa.objcmin import (NSNotificationCenter, NSSearchPathForDirectoriesInDomains,
NSApplicationSupportDirectory, NSUserDomainMask, NSWorkspace)
from hscommon.trans import trget from hscommon.trans import trget
from core.app import JobType from core.app import JobType
@ -25,7 +23,7 @@ class PyDupeGuruBase(PyFairware):
def _init(self, modelclass): def _init(self, modelclass):
logging.basicConfig(level=logging.WARNING, format='%(levelname)s %(message)s') logging.basicConfig(level=logging.WARNING, format='%(levelname)s %(message)s')
install_exception_hook() install_exception_hook()
appdata = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0] appdata = proxy.getAppdataPath()
self.py = modelclass(self, appdata) self.py = modelclass(self, appdata)
self.progress = cocoa.ThreadedJobPerformer() self.progress = cocoa.ThreadedJobPerformer()
@ -166,10 +164,10 @@ class PyDupeGuruBase(PyFairware):
#--- model --> view #--- model --> view
def open_path(self, path): def open_path(self, path):
NSWorkspace.sharedWorkspace().openFile_(str(path)) proxy.openPath_(str(path))
def reveal_path(self, path): def reveal_path(self, path):
NSWorkspace.sharedWorkspace().selectFile_inFileViewerRootedAtPath_(str(path), '') proxy.revealPath_(str(path))
def start_job(self, jobid, func, args=()): def start_job(self, jobid, func, args=()):
try: try:
@ -177,10 +175,10 @@ class PyDupeGuruBase(PyFairware):
args = tuple([j] + list(args)) args = tuple([j] + list(args))
self.progress.run_threaded(func, args=args) self.progress.run_threaded(func, args=args)
except job.JobInProgressError: except job.JobInProgressError:
NSNotificationCenter.defaultCenter().postNotificationName_object_('JobInProgress', self) proxy.postNotification_userInfo_('JobInProgress', None)
else: else:
ud = {'desc': JOBID2TITLE[jobid], 'jobid':jobid} ud = {'desc': JOBID2TITLE[jobid], 'jobid':jobid}
NSNotificationCenter.defaultCenter().postNotificationName_object_userInfo_('JobStarted', self, ud) proxy.postNotification_userInfo_('JobStarted', ud)
def show_extra_fairware_reminder(self): def show_extra_fairware_reminder(self):
self.cocoa.showExtraFairwareReminder() self.cocoa.showExtraFairwareReminder()

View File

@ -11,7 +11,7 @@ from appscript import app, k, CommandError
import time import time
import os.path as op import os.path as op
from hscommon.cocoa import as_fetch from cocoa import as_fetch
from hscommon.trans import tr from hscommon.trans import tr
from core.app import JobType from core.app import JobType

View File

@ -16,8 +16,8 @@ from appscript import app, its, CommandError, ApplicationNotFoundError
from hscommon import io from hscommon import io
from hscommon.util import remove_invalid_xml from hscommon.util import remove_invalid_xml
from hscommon.path import Path from hscommon.path import Path
from hscommon.cocoa.objcmin import NSUserDefaults, NSURL
from hscommon.trans import tr from hscommon.trans import tr
from cocoa import proxy
from core import directories from core import directories
from core_pe import _block_osx from core_pe import _block_osx
@ -49,14 +49,11 @@ class IPhoto(Photo):
return IPHOTO_PATH return IPHOTO_PATH
def get_iphoto_database_path(): def get_iphoto_database_path():
ud = NSUserDefaults.standardUserDefaults() plisturls = proxy.prefValue_inDomain_('iPhotoRecentDatabases', 'com.apple.iApps')
prefs = ud.persistentDomainForName_('com.apple.iApps') if not plisturls:
if prefs is None:
raise directories.InvalidPathError() raise directories.InvalidPathError()
if 'iPhotoRecentDatabases' not in prefs: plistpath = proxy.url2path_(plisturls[0])
raise directories.InvalidPathError() return Path(plistpath)
plisturl = NSURL.URLWithString_(prefs['iPhotoRecentDatabases'][0])
return Path(plisturl.path())
def get_iphoto_pictures(plistpath): def get_iphoto_pictures(plistpath):
if not io.exists(plistpath): if not io.exists(plistpath):

View File

@ -11,18 +11,17 @@ import os.path as op
from hscommon import io from hscommon import io
from hscommon.path import Path from hscommon.path import Path
from hscommon.cocoa.objcmin import NSWorkspace from cocoa import proxy
from core import fs from core import fs
from core.directories import Directories as DirectoriesBase, DirectoryState from core.directories import Directories as DirectoriesBase, DirectoryState
from core_se.app import DupeGuru as DupeGuruBase from core_se.app import DupeGuru as DupeGuruBase
def is_bundle(str_path): def is_bundle(str_path):
sw = NSWorkspace.sharedWorkspace() uti = proxy.getUTI_(str_path)
uti, error = sw.typeOfFile_error_(str_path, None) if uti is None:
if error is not None:
logging.warning('There was an error trying to detect the UTI of %s', str_path) logging.warning('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 proxy.type_conformsToType_(uti, 'com.apple.bundle') or proxy.type_conformsToType_(uti, 'com.apple.package')
class Bundle(fs.Folder): class Bundle(fs.Folder):
@classmethod @classmethod

View File

@ -1,4 +1,4 @@
from hscommon.cocoa.inter import signature, PyGUIObject from cocoa.inter import signature, PyGUIObject
from core.gui.details_panel import DetailsPanel from core.gui.details_panel import DetailsPanel

View File

@ -1,4 +1,4 @@
from hscommon.cocoa.inter import PyOutline from cocoa.inter import PyOutline
from core.gui.directory_tree import DirectoryTree from core.gui.directory_tree import DirectoryTree

View File

@ -1,4 +1,4 @@
from hscommon.cocoa.inter import PyGUIObject from cocoa.inter import PyGUIObject
from core.gui.extra_fairware_reminder import ExtraFairwareReminder from core.gui.extra_fairware_reminder import ExtraFairwareReminder

View File

@ -1,4 +1,4 @@
from hscommon.cocoa.inter import PyGUIObject, PySelectableList from cocoa.inter import PyGUIObject, PySelectableList
from core.gui.prioritize_dialog import PrioritizeDialog from core.gui.prioritize_dialog import PrioritizeDialog
from .prioritize_list import PyPrioritizeList from .prioritize_list import PyPrioritizeList

View File

@ -1,4 +1,4 @@
from hscommon.cocoa.inter import signature, PySelectableList from cocoa.inter import signature, PySelectableList
class PyPrioritizeList(PySelectableList): class PyPrioritizeList(PySelectableList):
@signature('v@:@i') @signature('v@:@i')

View File

@ -1,4 +1,4 @@
from hscommon.cocoa.inter import PyGUIObject from cocoa.inter import PyGUIObject
from core.gui.problem_dialog import ProblemDialog from core.gui.problem_dialog import ProblemDialog

View File

@ -1,4 +1,4 @@
from hscommon.cocoa.inter import PyTable from cocoa.inter import PyTable
from core.gui.problem_table import ProblemTable from core.gui.problem_table import ProblemTable

View File

@ -1,4 +1,4 @@
from hscommon.cocoa.inter import signature, PyTable from cocoa.inter import signature, PyTable
class PyResultTable(PyTable): class PyResultTable(PyTable):
@signature('c@:') @signature('c@:')

View File

@ -1,4 +1,4 @@
from hscommon.cocoa.inter import PyGUIObject from cocoa.inter import PyGUIObject
from core.gui.stats_label import StatsLabel from core.gui.stats_label import StatsLabel

View File

@ -7,7 +7,7 @@
from hscommon.trans import install_gettext_trans_under_cocoa from hscommon.trans import install_gettext_trans_under_cocoa
install_gettext_trans_under_cocoa() install_gettext_trans_under_cocoa()
from hscommon.cocoa import signature from cocoa.inter import signature
from core.scanner import ScanType from core.scanner import ScanType

View File

@ -7,7 +7,7 @@
from hscommon.trans import install_gettext_trans_under_cocoa from hscommon.trans import install_gettext_trans_under_cocoa
install_gettext_trans_under_cocoa() install_gettext_trans_under_cocoa()
from hscommon.cocoa import signature from cocoa.inter import signature
from core.scanner import ScanType from core.scanner import ScanType

View File

@ -2,3 +2,4 @@
pyobjc-core>=2.3 pyobjc-core>=2.3
pluginbuilder>=1.0.0 pluginbuilder>=1.0.0
appscript>=1.0.0 appscript>=1.0.0
objp>=0.1.0