diff --git a/base/py/data.py b/base/py/data.py index 2f81084e..46589c62 100644 --- a/base/py/data.py +++ b/base/py/data.py @@ -40,63 +40,3 @@ def format_dupe_count(c): def cmp_value(value): return value.lower() if isinstance(value, basestring) else value - -COLUMNS = [ - {'attr':'name','display':'Filename'}, - {'attr':'path','display':'Directory'}, - {'attr':'size','display':'Size (KB)'}, - {'attr':'extension','display':'Kind'}, - {'attr':'ctime','display':'Creation'}, - {'attr':'mtime','display':'Modification'}, - {'attr':'percentage','display':'Match %'}, - {'attr':'words','display':'Words Used'}, - {'attr':'dupe_count','display':'Dupe Count'}, -] - -METADATA_TO_READ = ['size', 'ctime', 'mtime'] - -def GetDisplayInfo(dupe, group, delta): - size = dupe.size - ctime = dupe.ctime - mtime = dupe.mtime - m = group.get_match_of(dupe) - if m: - percentage = m.percentage - dupe_count = 0 - if delta: - r = group.ref - size -= r.size - ctime -= r.ctime - mtime -= r.mtime - else: - percentage = group.percentage - dupe_count = len(group.dupes) - return [ - dupe.name, - format_path(dupe.path), - format_size(size, 0, 1, False), - dupe.extension, - format_timestamp(ctime, delta and m), - format_timestamp(mtime, delta and m), - format_perc(percentage), - format_words(dupe.words) if hasattr(dupe, 'words') else '', - format_dupe_count(dupe_count) - ] - -def GetDupeSortKey(dupe, get_group, key, delta): - if key == 6: - m = get_group().get_match_of(dupe) - return m.percentage - if key == 8: - return 0 - r = cmp_value(getattr(dupe, COLUMNS[key]['attr'])) - if delta and (key in (2, 4, 5)): - r -= cmp_value(getattr(get_group().ref, COLUMNS[key]['attr'])) - return r - -def GetGroupSortKey(group, key): - if key == 6: - return group.percentage - if key == 8: - return len(group) - return cmp_value(getattr(group.ref, COLUMNS[key]['attr'])) diff --git a/base/qt/app.py b/base/qt/app.py index 12171c52..f8c2063f 100644 --- a/base/qt/app.py +++ b/base/qt/app.py @@ -145,6 +145,7 @@ class DupeGuru(DupeGuruBase, QObject): def ask_for_reg_code(self): if self.reg.ask_for_code(): + #XXX bug??? self._setup_ui_as_registered() @demo_method diff --git a/se/py/LICENSE b/se/py/LICENSE new file mode 100644 index 00000000..f8818048 --- /dev/null +++ b/se/py/LICENSE @@ -0,0 +1,11 @@ +Copyright 2009 Hardcoded Software Inc. (http://www.hardcoded.net) +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of Hardcoded Software Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * If the source code has been published less than two years ago, any redistribution, in whole or in part, must retain full licensing functionality, without any attempt to change, obscure or in other ways circumvent its intent. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/se/py/__init__.py b/se/py/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/se/py/__init__.py @@ -0,0 +1 @@ + diff --git a/base/py/app_se_cocoa.py b/se/py/app_cocoa.py similarity index 93% rename from base/py/app_se_cocoa.py rename to se/py/app_cocoa.py index c431ab05..4ba82ac2 100644 --- a/base/py/app_se_cocoa.py +++ b/se/py/app_cocoa.py @@ -17,8 +17,9 @@ from hsutil.path import Path from hsutil.misc import extract from hsutil.str import get_file_ext -from . import app_cocoa, data -from .directories import Directories as DirectoriesBase, STATE_EXCLUDED +from dupeguru.app_cocoa import DupeGuru as DupeGuruBase +from dupeguru.directories import Directories as DirectoriesBase, STATE_EXCLUDED +from . import data if NSWorkspace.sharedWorkspace().respondsToSelector_('typeOfFile:error:'): # Only from 10.5 def is_bundle(str_path): @@ -63,7 +64,7 @@ class Directories(DirectoriesBase): return STATE_EXCLUDED -class DupeGuru(app_cocoa.DupeGuru): +class DupeGuru(DupeGuruBase): def __init__(self): app_cocoa.DupeGuru.__init__(self, data, 'dupeGuru', appid=4) self.directories = Directories() diff --git a/se/py/data.py b/se/py/data.py new file mode 100644 index 00000000..dc353319 --- /dev/null +++ b/se/py/data.py @@ -0,0 +1,72 @@ +# Created By: Virgil Dupras +# Created On: 2006/03/15 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) +# +# This software is licensed under the "HS" License as described in the "LICENSE" file, +# which should be included with this package. The terms are also available at +# http://www.hardcoded.net/licenses/hs_license + +from hsutil.str import format_size +from dupeguru.data import (format_path, format_timestamp, format_words, format_perc, + format_dupe_count, cmp_value) + +COLUMNS = [ + {'attr':'name','display':'Filename'}, + {'attr':'path','display':'Directory'}, + {'attr':'size','display':'Size (KB)'}, + {'attr':'extension','display':'Kind'}, + {'attr':'ctime','display':'Creation'}, + {'attr':'mtime','display':'Modification'}, + {'attr':'percentage','display':'Match %'}, + {'attr':'words','display':'Words Used'}, + {'attr':'dupe_count','display':'Dupe Count'}, +] + +METADATA_TO_READ = ['size', 'ctime', 'mtime'] + +def GetDisplayInfo(dupe, group, delta): + size = dupe.size + ctime = dupe.ctime + mtime = dupe.mtime + m = group.get_match_of(dupe) + if m: + percentage = m.percentage + dupe_count = 0 + if delta: + r = group.ref + size -= r.size + ctime -= r.ctime + mtime -= r.mtime + else: + percentage = group.percentage + dupe_count = len(group.dupes) + return [ + dupe.name, + format_path(dupe.path), + format_size(size, 0, 1, False), + dupe.extension, + format_timestamp(ctime, delta and m), + format_timestamp(mtime, delta and m), + format_perc(percentage), + format_words(dupe.words) if hasattr(dupe, 'words') else '', + format_dupe_count(dupe_count) + ] + +def GetDupeSortKey(dupe, get_group, key, delta): + if key == 6: + m = get_group().get_match_of(dupe) + return m.percentage + if key == 8: + return 0 + r = cmp_value(getattr(dupe, COLUMNS[key]['attr'])) + if delta and (key in (2, 4, 5)): + r -= cmp_value(getattr(get_group().ref, COLUMNS[key]['attr'])) + return r + +def GetGroupSortKey(group, key): + if key == 6: + return group.percentage + if key == 8: + return len(group) + return cmp_value(getattr(group.ref, COLUMNS[key]['attr']))