mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 06:37:17 +00:00
Converted registration system to Fairware.
This commit is contained in:
20
core/app.py
20
core/app.py
@@ -13,7 +13,7 @@ import subprocess
|
||||
import re
|
||||
|
||||
from send2trash import send2trash
|
||||
from hscommon.reg import RegistrableApplication, RegistrationRequired
|
||||
from hscommon.reg import RegistrableApplication
|
||||
from hscommon.notify import Broadcaster
|
||||
from hsutil import io, files
|
||||
from hsutil.path import Path
|
||||
@@ -32,10 +32,8 @@ class NoScannableFileError(Exception):
|
||||
pass
|
||||
|
||||
class DupeGuru(RegistrableApplication, Broadcaster):
|
||||
DEMO_LIMIT_DESC = "In the demo version, only 10 duplicates per session can be sent to the recycle bin, moved or copied."
|
||||
|
||||
def __init__(self, data_module, appdata, appid):
|
||||
RegistrableApplication.__init__(self, appid)
|
||||
def __init__(self, data_module, appdata):
|
||||
RegistrableApplication.__init__(self, appid=1)
|
||||
Broadcaster.__init__(self)
|
||||
self.appdata = appdata
|
||||
if not op.exists(self.appdata):
|
||||
@@ -44,7 +42,6 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
||||
self.directories = directories.Directories()
|
||||
self.results = results.Results(data_module)
|
||||
self.scanner = scanner.Scanner()
|
||||
self.action_count = 0
|
||||
self.options = {
|
||||
'escape_filter_regexp': True,
|
||||
'clean_empty_dirs': False,
|
||||
@@ -52,15 +49,6 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
||||
}
|
||||
self.selected_dupes = []
|
||||
|
||||
def _demo_check(self):
|
||||
if self.registered:
|
||||
return
|
||||
count = self.results.mark_count
|
||||
if count + self.action_count > 10:
|
||||
raise RegistrationRequired()
|
||||
else:
|
||||
self.action_count += count
|
||||
|
||||
def _do_delete(self, j, replace_with_hardlinks):
|
||||
def op(dupe):
|
||||
j.add_progress()
|
||||
@@ -206,12 +194,10 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
||||
j.start_job(self.results.mark_count)
|
||||
self.results.perform_on_marked(op, not copy)
|
||||
|
||||
self._demo_check()
|
||||
jobid = JOB_COPY if copy else JOB_MOVE
|
||||
self._start_job(jobid, do)
|
||||
|
||||
def delete_marked(self, replace_with_hardlinks=False):
|
||||
self._demo_check()
|
||||
self._start_job(JOB_DELETE, self._do_delete, replace_with_hardlinks)
|
||||
|
||||
def export_to_xhtml(self, column_ids):
|
||||
|
||||
@@ -14,7 +14,6 @@ from hscommon.cocoa import install_exception_hook
|
||||
from hscommon.cocoa.objcmin import (NSNotificationCenter, NSUserDefaults,
|
||||
NSSearchPathForDirectoriesInDomains, NSApplicationSupportDirectory, NSUserDomainMask,
|
||||
NSWorkspace)
|
||||
from hscommon.reg import RegistrationRequired
|
||||
|
||||
from . import app
|
||||
|
||||
@@ -26,24 +25,15 @@ JOBID2TITLE = {
|
||||
app.JOB_DELETE: "Sending to Trash",
|
||||
}
|
||||
|
||||
def demo_method(method):
|
||||
def wrapper(self, *args, **kwargs):
|
||||
try:
|
||||
return method(self, *args, **kwargs)
|
||||
except RegistrationRequired:
|
||||
NSNotificationCenter.defaultCenter().postNotificationName_object_('RegistrationRequired', self)
|
||||
|
||||
return wrapper
|
||||
|
||||
class DupeGuru(app.DupeGuru):
|
||||
def __init__(self, data_module, appdata_subdir, appid):
|
||||
def __init__(self, data_module, appdata_subdir):
|
||||
LOGGING_LEVEL = logging.DEBUG if NSUserDefaults.standardUserDefaults().boolForKey_('debug') else logging.WARNING
|
||||
logging.basicConfig(level=LOGGING_LEVEL, format='%(levelname)s %(message)s')
|
||||
logging.debug('started in debug mode')
|
||||
install_exception_hook()
|
||||
appsupport = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0]
|
||||
appdata = op.join(appsupport, appdata_subdir)
|
||||
app.DupeGuru.__init__(self, data_module, appdata, appid)
|
||||
app.DupeGuru.__init__(self, data_module, appdata)
|
||||
self.progress = cocoa.ThreadedJobPerformer()
|
||||
|
||||
#--- Override
|
||||
@@ -67,9 +57,6 @@ class DupeGuru(app.DupeGuru):
|
||||
NSNotificationCenter.defaultCenter().postNotificationName_object_userInfo_('JobStarted', self, ud)
|
||||
|
||||
#---Public
|
||||
copy_or_move_marked = demo_method(app.DupeGuru.copy_or_move_marked)
|
||||
delete_marked = demo_method(app.DupeGuru.delete_marked)
|
||||
|
||||
def start_scanning(self):
|
||||
self._select_dupes([])
|
||||
try:
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
# Common interface for all editions' dg_cocoa unit.
|
||||
|
||||
from hscommon.cocoa.inter import signature, PyTable, PyOutline, PyGUIObject, PyRegistrable
|
||||
from hscommon.cocoa.inter import signature, PyTable, PyOutline, PyGUIObject, PyFairware
|
||||
|
||||
from .gui.details_panel import DetailsPanel
|
||||
from .gui.directory_tree import DirectoryTree
|
||||
@@ -22,7 +22,7 @@ from .gui.stats_label import StatsLabel
|
||||
from core import app, app_cocoa, data, directories, engine, export, ignore, results, fs, scanner
|
||||
from hsutil import conflict
|
||||
|
||||
class PyDupeGuruBase(PyRegistrable):
|
||||
class PyDupeGuruBase(PyFairware):
|
||||
#---Directories
|
||||
def addDirectory_(self, directory):
|
||||
return self.py.add_directory(directory)
|
||||
|
||||
Reference in New Issue
Block a user