mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
Cleaned up some cruft.
This commit is contained in:
parent
514426b980
commit
112ffb981f
@ -23,11 +23,6 @@ http://www.hardcoded.net/licenses/hs_license
|
|||||||
|
|
||||||
- (NSNumber *)doScan;
|
- (NSNumber *)doScan;
|
||||||
|
|
||||||
- (NSArray *)selectedPowerMarkerNodePaths;
|
|
||||||
- (void)selectPowerMarkerNodePaths:(NSArray *)aIndexPaths;
|
|
||||||
- (NSArray *)selectedResultNodePaths;
|
|
||||||
- (void)selectResultNodePaths:(NSArray *)aIndexPaths;
|
|
||||||
|
|
||||||
- (void)toggleSelectedMark;
|
- (void)toggleSelectedMark;
|
||||||
- (void)markAll;
|
- (void)markAll;
|
||||||
- (void)markInvert;
|
- (void)markInvert;
|
||||||
|
@ -80,7 +80,7 @@ http://www.hardcoded.net/licenses/hs_license
|
|||||||
{
|
{
|
||||||
NSIndexPath *path = item;
|
NSIndexPath *path = item;
|
||||||
NSString *identifier = [column identifier];
|
NSString *identifier = [column identifier];
|
||||||
if ([identifier isEqual:@"mark"]) {
|
if ([identifier isEqual:@"marked"]) {
|
||||||
return b2n([self boolProperty:@"marked" valueAtPath:path]);
|
return b2n([self boolProperty:@"marked" valueAtPath:path]);
|
||||||
}
|
}
|
||||||
NSInteger columnId = [identifier integerValue];
|
NSInteger columnId = [identifier integerValue];
|
||||||
@ -89,8 +89,7 @@ http://www.hardcoded.net/licenses/hs_license
|
|||||||
|
|
||||||
- (void)outlineView:(NSOutlineView *)aOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
|
- (void)outlineView:(NSOutlineView *)aOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
|
||||||
{
|
{
|
||||||
if (![[tableColumn identifier] isEqual:@"0"])
|
if ([[tableColumn identifier] isEqual:@"0"]) {
|
||||||
return; //We only want to cover renames.
|
|
||||||
NSIndexPath *path = item;
|
NSIndexPath *path = item;
|
||||||
NSString *oldName = [[self py] valueForPath:p2a(path) column:0];
|
NSString *oldName = [[self py] valueForPath:p2a(path) column:0];
|
||||||
NSString *newName = object;
|
NSString *newName = object;
|
||||||
@ -101,6 +100,10 @@ http://www.hardcoded.net/licenses/hs_license
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
[super outlineView:aOutlineView setObjectValue:object forTableColumn:tableColumn byItem:item];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Delegate */
|
/* Delegate */
|
||||||
- (void)outlineView:(NSOutlineView *)aOutlineView didClickTableColumn:(NSTableColumn *)tableColumn
|
- (void)outlineView:(NSOutlineView *)aOutlineView didClickTableColumn:(NSTableColumn *)tableColumn
|
||||||
@ -115,7 +118,7 @@ http://www.hardcoded.net/licenses/hs_license
|
|||||||
{
|
{
|
||||||
NSIndexPath *path = item;
|
NSIndexPath *path = item;
|
||||||
BOOL isMarkable = [self boolProperty:@"markable" valueAtPath:path];
|
BOOL isMarkable = [self boolProperty:@"markable" valueAtPath:path];
|
||||||
if ([[tableColumn identifier] isEqual:@"mark"]) {
|
if ([[tableColumn identifier] isEqual:@"marked"]) {
|
||||||
[cell setEnabled:isMarkable];
|
[cell setEnabled:isMarkable];
|
||||||
}
|
}
|
||||||
if ([cell isKindOfClass:[NSTextFieldCell class]]) {
|
if ([cell isKindOfClass:[NSTextFieldCell class]]) {
|
||||||
|
@ -40,7 +40,6 @@ http://www.hardcoded.net/licenses/hs_license
|
|||||||
- (NSDictionary *)getColumnsWidth;
|
- (NSDictionary *)getColumnsWidth;
|
||||||
- (NSArray *)getSelectedPaths:(BOOL)aDupesOnly;
|
- (NSArray *)getSelectedPaths:(BOOL)aDupesOnly;
|
||||||
- (void)initResultColumns;
|
- (void)initResultColumns;
|
||||||
- (void)performPySelection:(NSArray *)aIndexPaths;
|
|
||||||
- (void)restoreColumnsPosition:(NSArray *)aColumnsOrder widths:(NSDictionary *)aColumnsWidth;
|
- (void)restoreColumnsPosition:(NSArray *)aColumnsOrder widths:(NSDictionary *)aColumnsWidth;
|
||||||
|
|
||||||
/* Actions */
|
/* Actions */
|
||||||
@ -56,7 +55,6 @@ http://www.hardcoded.net/licenses/hs_license
|
|||||||
- (IBAction)markInvert:(id)sender;
|
- (IBAction)markInvert:(id)sender;
|
||||||
- (IBAction)markNone:(id)sender;
|
- (IBAction)markNone:(id)sender;
|
||||||
- (IBAction)markSelected:(id)sender;
|
- (IBAction)markSelected:(id)sender;
|
||||||
- (IBAction)markToggle:(id)sender;
|
|
||||||
- (IBAction)moveMarked:(id)sender;
|
- (IBAction)moveMarked:(id)sender;
|
||||||
- (IBAction)openClicked:(id)sender;
|
- (IBAction)openClicked:(id)sender;
|
||||||
- (IBAction)openSelected:(id)sender;
|
- (IBAction)openSelected:(id)sender;
|
||||||
|
@ -139,7 +139,7 @@ http://www.hardcoded.net/licenses/hs_license
|
|||||||
}
|
}
|
||||||
//Add columns and set widths
|
//Add columns and set widths
|
||||||
for (NSString *colId in aColumnsOrder) {
|
for (NSString *colId in aColumnsOrder) {
|
||||||
if ([colId isEqual:@"mark"]) {
|
if ([colId isEqual:@"marked"]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
NSTableColumn *col = [_resultColumns objectAtIndex:[colId intValue]];
|
NSTableColumn *col = [_resultColumns objectAtIndex:[colId intValue]];
|
||||||
@ -152,28 +152,6 @@ http://www.hardcoded.net/licenses/hs_license
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// - (void)updatePySelection
|
|
||||||
// {
|
|
||||||
// NSArray *selection;
|
|
||||||
// if (_powerMode) {
|
|
||||||
// selection = [py selectedPowerMarkerNodePaths];
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// selection = [py selectedResultNodePaths];
|
|
||||||
// }
|
|
||||||
// [matches selectNodePaths:selection];
|
|
||||||
// }
|
|
||||||
|
|
||||||
- (void)performPySelection:(NSArray *)aIndexPaths
|
|
||||||
{
|
|
||||||
if ([outline powerMarkerMode]) {
|
|
||||||
[py selectPowerMarkerNodePaths:aIndexPaths];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
[py selectResultNodePaths:aIndexPaths];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Actions */
|
/* Actions */
|
||||||
- (IBAction)clearIgnoreList:(id)sender
|
- (IBAction)clearIgnoreList:(id)sender
|
||||||
{
|
{
|
||||||
@ -268,14 +246,6 @@ http://www.hardcoded.net/licenses/hs_license
|
|||||||
|
|
||||||
- (IBAction)markSelected:(id)sender
|
- (IBAction)markSelected:(id)sender
|
||||||
{
|
{
|
||||||
[self performPySelection:[self getSelectedPaths:YES]];
|
|
||||||
[py toggleSelectedMark];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (IBAction)markToggle:(id)sender
|
|
||||||
{
|
|
||||||
NSIndexPath *path = [matches itemAtRow:[matches clickedRow]];
|
|
||||||
[self performPySelection:[NSArray arrayWithObject:p2a(path)]];
|
|
||||||
[py toggleSelectedMark];
|
[py toggleSelectedMark];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +280,6 @@ http://www.hardcoded.net/licenses/hs_license
|
|||||||
|
|
||||||
- (IBAction)openSelected:(id)sender
|
- (IBAction)openSelected:(id)sender
|
||||||
{
|
{
|
||||||
[self performPySelection:[self getSelectedPaths:NO]];
|
|
||||||
[py openSelected];
|
[py openSelected];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +300,6 @@ http://www.hardcoded.net/licenses/hs_license
|
|||||||
return;
|
return;
|
||||||
if ([Dialogs askYesNo:[NSString stringWithFormat:@"You are about to remove %d files from results. Continue?",[pathList count]]] == NSAlertSecondButtonReturn) // NO
|
if ([Dialogs askYesNo:[NSString stringWithFormat:@"You are about to remove %d files from results. Continue?",[pathList count]]] == NSAlertSecondButtonReturn) // NO
|
||||||
return;
|
return;
|
||||||
[self performPySelection:[self getSelectedPaths:YES]];
|
|
||||||
[py removeSelected];
|
[py removeSelected];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +317,6 @@ http://www.hardcoded.net/licenses/hs_license
|
|||||||
|
|
||||||
- (IBAction)revealSelected:(id)sender
|
- (IBAction)revealSelected:(id)sender
|
||||||
{
|
{
|
||||||
[self performPySelection:[self getSelectedPaths:NO]];
|
|
||||||
[py revealSelected];
|
[py revealSelected];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,11 +436,6 @@ http://www.hardcoded.net/licenses/hs_license
|
|||||||
[Dialogs showMessage:msg];
|
[Dialogs showMessage:msg];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)outlineViewSelectionDidChange:(NSNotification *)notification
|
|
||||||
{
|
|
||||||
[self performPySelection:[self getSelectedPaths:NO]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)validateToolbarItem:(NSToolbarItem *)theItem
|
- (BOOL)validateToolbarItem:(NSToolbarItem *)theItem
|
||||||
{
|
{
|
||||||
return ![[ProgressController mainProgressController] isShown];
|
return ![[ProgressController mainProgressController] isShown];
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
</object>
|
</object>
|
||||||
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
|
<integer value="406"/>
|
||||||
<integer value="29"/>
|
<integer value="29"/>
|
||||||
<integer value="21"/>
|
|
||||||
</object>
|
</object>
|
||||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
@ -710,7 +710,7 @@
|
|||||||
<object class="NSMutableArray" key="NSTableColumns">
|
<object class="NSMutableArray" key="NSTableColumns">
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
<object class="NSTableColumn" id="430098394">
|
<object class="NSTableColumn" id="430098394">
|
||||||
<string key="NSIdentifier">mark</string>
|
<string key="NSIdentifier">marked</string>
|
||||||
<double key="NSWidth">47</double>
|
<double key="NSWidth">47</double>
|
||||||
<double key="NSMinWidth">16</double>
|
<double key="NSMinWidth">16</double>
|
||||||
<double key="NSMaxWidth">1000</double>
|
<double key="NSMaxWidth">1000</double>
|
||||||
@ -752,6 +752,7 @@
|
|||||||
<int key="NSPeriodicDelay">400</int>
|
<int key="NSPeriodicDelay">400</int>
|
||||||
<int key="NSPeriodicInterval">75</int>
|
<int key="NSPeriodicInterval">75</int>
|
||||||
</object>
|
</object>
|
||||||
|
<bool key="NSIsEditable">YES</bool>
|
||||||
<reference key="NSTableView" ref="40047569"/>
|
<reference key="NSTableView" ref="40047569"/>
|
||||||
</object>
|
</object>
|
||||||
<object class="NSTableColumn" id="932540235">
|
<object class="NSTableColumn" id="932540235">
|
||||||
@ -1691,14 +1692,6 @@
|
|||||||
</object>
|
</object>
|
||||||
<int key="connectionID">410</int>
|
<int key="connectionID">410</int>
|
||||||
</object>
|
</object>
|
||||||
<object class="IBConnectionRecord">
|
|
||||||
<object class="IBActionConnection" key="connection">
|
|
||||||
<string key="label">markToggle:</string>
|
|
||||||
<reference key="source" ref="339936126"/>
|
|
||||||
<reference key="destination" ref="705360835"/>
|
|
||||||
</object>
|
|
||||||
<int key="connectionID">414</int>
|
|
||||||
</object>
|
|
||||||
<object class="IBConnectionRecord">
|
<object class="IBConnectionRecord">
|
||||||
<object class="IBOutletConnection" key="connection">
|
<object class="IBOutletConnection" key="connection">
|
||||||
<string key="label">stats</string>
|
<string key="label">stats</string>
|
||||||
|
@ -253,6 +253,13 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
|||||||
self.results.mark_invert()
|
self.results.mark_invert()
|
||||||
self.notify('marking_changed')
|
self.notify('marking_changed')
|
||||||
|
|
||||||
|
def mark_dupe(self, dupe, marked):
|
||||||
|
if marked:
|
||||||
|
self.results.mark(dupe)
|
||||||
|
else:
|
||||||
|
self.results.unmark(dupe)
|
||||||
|
self.notify('marking_changed')
|
||||||
|
|
||||||
def open_selected(self):
|
def open_selected(self):
|
||||||
if self.selected_dupes:
|
if self.selected_dupes:
|
||||||
self._open_path(self.selected_dupes[0].path)
|
self._open_path(self.selected_dupes[0].path)
|
||||||
|
@ -74,18 +74,6 @@ class DupeGuru(app.DupeGuru):
|
|||||||
ud = {'desc': JOBID2TITLE[jobid], 'jobid':jobid}
|
ud = {'desc': JOBID2TITLE[jobid], 'jobid':jobid}
|
||||||
NSNotificationCenter.defaultCenter().postNotificationName_object_userInfo_('JobStarted', self, ud)
|
NSNotificationCenter.defaultCenter().postNotificationName_object_userInfo_('JobStarted', self, ud)
|
||||||
|
|
||||||
#---Helpers
|
|
||||||
def GetObjects(self,node_path):
|
|
||||||
#returns a tuple g,d
|
|
||||||
try:
|
|
||||||
g = self.results.groups[node_path[0]]
|
|
||||||
if len(node_path) == 2:
|
|
||||||
return (g,self.results.groups[node_path[0]].dupes[node_path[1]])
|
|
||||||
else:
|
|
||||||
return (g,None)
|
|
||||||
except IndexError:
|
|
||||||
return (None,None)
|
|
||||||
|
|
||||||
#---Public
|
#---Public
|
||||||
copy_or_move_marked = demo_method(app.DupeGuru.copy_or_move_marked)
|
copy_or_move_marked = demo_method(app.DupeGuru.copy_or_move_marked)
|
||||||
delete_marked = demo_method(app.DupeGuru.delete_marked)
|
delete_marked = demo_method(app.DupeGuru.delete_marked)
|
||||||
@ -112,46 +100,3 @@ class DupeGuru(app.DupeGuru):
|
|||||||
except app.AllFilesAreRefError:
|
except app.AllFilesAreRefError:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def selected_result_node_paths(self):
|
|
||||||
def get_path(dupe):
|
|
||||||
try:
|
|
||||||
group = self.results.get_group_of_duplicate(dupe)
|
|
||||||
groupindex = self.results.groups.index(group)
|
|
||||||
if dupe is group.ref:
|
|
||||||
return [groupindex]
|
|
||||||
dupeindex = group.dupes.index(dupe)
|
|
||||||
return [groupindex, dupeindex]
|
|
||||||
except ValueError: # dupe not in there
|
|
||||||
return None
|
|
||||||
|
|
||||||
dupes = self.selected_dupes
|
|
||||||
return stripnone(get_path(dupe) for dupe in dupes)
|
|
||||||
|
|
||||||
def selected_powermarker_node_paths(self):
|
|
||||||
def get_path(dupe):
|
|
||||||
try:
|
|
||||||
dupeindex = self.results.dupes.index(dupe)
|
|
||||||
return [dupeindex]
|
|
||||||
except ValueError: # dupe not in there
|
|
||||||
return None
|
|
||||||
|
|
||||||
dupes = self.selected_dupes
|
|
||||||
return stripnone(get_path(dupe) for dupe in dupes)
|
|
||||||
|
|
||||||
def SelectResultNodePaths(self,node_paths):
|
|
||||||
def extract_dupe(t):
|
|
||||||
g,d = t
|
|
||||||
if d is not None:
|
|
||||||
return d
|
|
||||||
else:
|
|
||||||
if g is not None:
|
|
||||||
return g.ref
|
|
||||||
|
|
||||||
selected = [extract_dupe(self.GetObjects(p)) for p in node_paths]
|
|
||||||
self._select_dupes([dupe for dupe in selected if dupe is not None])
|
|
||||||
|
|
||||||
def SelectPowerMarkerNodePaths(self,node_paths):
|
|
||||||
rows = [p[0] for p in node_paths]
|
|
||||||
dupes = [self.results.dupes[row] for row in rows if row in xrange(len(self.results.dupes))]
|
|
||||||
self._select_dupes(dupes)
|
|
||||||
|
|
||||||
|
@ -65,18 +65,6 @@ class PyDupeGuruBase(PyRegistrable):
|
|||||||
def saveResults(self):
|
def saveResults(self):
|
||||||
self.py.save()
|
self.py.save()
|
||||||
|
|
||||||
def selectedResultNodePaths(self):
|
|
||||||
return self.py.selected_result_node_paths()
|
|
||||||
|
|
||||||
def selectResultNodePaths_(self,node_paths):
|
|
||||||
self.py.SelectResultNodePaths(node_paths)
|
|
||||||
|
|
||||||
def selectedPowerMarkerNodePaths(self):
|
|
||||||
return self.py.selected_powermarker_node_paths()
|
|
||||||
|
|
||||||
def selectPowerMarkerNodePaths_(self,node_paths):
|
|
||||||
self.py.SelectPowerMarkerNodePaths(node_paths)
|
|
||||||
|
|
||||||
#---Actions
|
#---Actions
|
||||||
def addSelectedToIgnoreList(self):
|
def addSelectedToIgnoreList(self):
|
||||||
self.py.add_selected_to_ignore_list()
|
self.py.add_selected_to_ignore_list()
|
||||||
|
@ -42,6 +42,10 @@ class DupeNode(Node):
|
|||||||
def marked(self):
|
def marked(self):
|
||||||
return self._app.results.is_marked(self._dupe)
|
return self._app.results.is_marked(self._dupe)
|
||||||
|
|
||||||
|
@marked.setter
|
||||||
|
def marked(self, value):
|
||||||
|
self._app.mark_dupe(self._dupe, value)
|
||||||
|
|
||||||
|
|
||||||
class ResultTree(GUIObject, Tree):
|
class ResultTree(GUIObject, Tree):
|
||||||
def __init__(self, view, app):
|
def __init__(self, view, app):
|
||||||
|
@ -28,6 +28,7 @@ except ImportError:
|
|||||||
raise SkipTest("These tests can only be run on OS X")
|
raise SkipTest("These tests can only be run on OS X")
|
||||||
from ..gui.details_panel import DetailsPanel
|
from ..gui.details_panel import DetailsPanel
|
||||||
from ..gui.directory_tree import DirectoryTree
|
from ..gui.directory_tree import DirectoryTree
|
||||||
|
from ..gui.result_tree import ResultTree
|
||||||
|
|
||||||
class DupeGuru(DupeGuruBase):
|
class DupeGuru(DupeGuruBase):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -60,12 +61,14 @@ class CallLogger(object):
|
|||||||
class TCDupeGuru(TestCase):
|
class TCDupeGuru(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.app = DupeGuru()
|
self.app = DupeGuru()
|
||||||
|
self.objects,self.matches,self.groups = GetTestGroups()
|
||||||
|
self.app.results.groups = self.groups
|
||||||
self.dpanel_gui = CallLogger()
|
self.dpanel_gui = CallLogger()
|
||||||
self.dpanel = DetailsPanel(self.dpanel_gui, self.app)
|
self.dpanel = DetailsPanel(self.dpanel_gui, self.app)
|
||||||
self.dtree_gui = CallLogger()
|
self.dtree_gui = CallLogger()
|
||||||
self.dtree = DirectoryTree(self.dtree_gui, self.app)
|
self.dtree = DirectoryTree(self.dtree_gui, self.app)
|
||||||
self.objects,self.matches,self.groups = GetTestGroups()
|
self.rtree_gui = CallLogger()
|
||||||
self.app.results.groups = self.groups
|
self.rtree = ResultTree(self.rtree_gui, self.app)
|
||||||
tmppath = self.tmppath()
|
tmppath = self.tmppath()
|
||||||
io.mkdir(tmppath + 'foo')
|
io.mkdir(tmppath + 'foo')
|
||||||
io.mkdir(tmppath + 'bar')
|
io.mkdir(tmppath + 'bar')
|
||||||
@ -110,142 +113,117 @@ class TCDupeGuru(TestCase):
|
|||||||
gui.clear_calls()
|
gui.clear_calls()
|
||||||
|
|
||||||
def test_GetObjects(self):
|
def test_GetObjects(self):
|
||||||
app = self.app
|
|
||||||
objects = self.objects
|
objects = self.objects
|
||||||
groups = self.groups
|
groups = self.groups
|
||||||
g,d = app.GetObjects([0])
|
n = self.rtree.get_node([0])
|
||||||
self.assert_(g is groups[0])
|
assert n._group is groups[0]
|
||||||
self.assert_(d is None)
|
assert n._dupe is objects[0]
|
||||||
g,d = app.GetObjects([0,0])
|
n = self.rtree.get_node([0, 0])
|
||||||
self.assert_(g is groups[0])
|
assert n._group is groups[0]
|
||||||
self.assert_(d is objects[1])
|
assert n._dupe is objects[1]
|
||||||
g,d = app.GetObjects([1,0])
|
n = self.rtree.get_node([1, 0])
|
||||||
self.assert_(g is groups[1])
|
assert n._group is groups[1]
|
||||||
self.assert_(d is objects[4])
|
assert n._dupe is objects[4]
|
||||||
|
|
||||||
def test_GetObjects_after_sort(self):
|
def test_GetObjects_after_sort(self):
|
||||||
app = self.app
|
|
||||||
objects = self.objects
|
objects = self.objects
|
||||||
groups = self.groups[:] #To keep the old order in memory
|
groups = self.groups[:] # we need an un-sorted reference
|
||||||
app.sort_groups(0,False) #0 = Filename
|
self.rtree.sort(0, False) #0 = Filename
|
||||||
#Now, the group order is supposed to be reversed
|
n = self.rtree.get_node([0, 0])
|
||||||
g,d = app.GetObjects([0,0])
|
assert n._group is groups[1]
|
||||||
self.assert_(g is groups[1])
|
assert n._dupe is objects[4]
|
||||||
self.assert_(d is objects[4])
|
|
||||||
|
|
||||||
def test_GetObjects_out_of_range(self):
|
|
||||||
app = self.app
|
|
||||||
self.assertEqual((None,None),app.GetObjects([2]))
|
|
||||||
self.assertEqual((None,None),app.GetObjects([]))
|
|
||||||
self.assertEqual((None,None),app.GetObjects([1,2]))
|
|
||||||
|
|
||||||
def test_selected_result_node_paths(self):
|
def test_selected_result_node_paths(self):
|
||||||
# app.selected_dupes is correctly converted into node paths
|
# app.selected_dupes is correctly converted into node paths
|
||||||
app = self.app
|
|
||||||
objects = self.objects
|
|
||||||
paths = [[0, 0], [0, 1], [1]]
|
paths = [[0, 0], [0, 1], [1]]
|
||||||
app.SelectResultNodePaths(paths)
|
self.rtree.selected_paths = paths
|
||||||
eq_(app.selected_result_node_paths(), paths)
|
eq_(self.rtree.selected_paths, paths)
|
||||||
|
|
||||||
def test_selected_result_node_paths_after_deletion(self):
|
def test_selected_result_node_paths_after_deletion(self):
|
||||||
# cases where the selected dupes aren't there are correctly handled
|
# cases where the selected dupes aren't there are correctly handled
|
||||||
app = self.app
|
|
||||||
objects = self.objects
|
|
||||||
paths = [[0, 0], [0, 1], [1]]
|
paths = [[0, 0], [0, 1], [1]]
|
||||||
app.SelectResultNodePaths(paths)
|
self.rtree.selected_paths = paths
|
||||||
app.remove_selected()
|
self.app.remove_selected()
|
||||||
# The first 2 dupes have been removed. The 3rd one is a ref. it stays there, in first pos.
|
# The first 2 dupes have been removed. The 3rd one is a ref. it stays there, in first pos.
|
||||||
eq_(app.selected_result_node_paths(), [[0]]) # no exception
|
eq_(self.rtree.selected_paths, [[0]]) # no exception
|
||||||
|
|
||||||
def test_selectResultNodePaths(self):
|
def test_selectResultNodePaths(self):
|
||||||
app = self.app
|
app = self.app
|
||||||
objects = self.objects
|
objects = self.objects
|
||||||
app.SelectResultNodePaths([[0,0],[0,1]])
|
self.rtree.selected_paths = [[0, 0], [0, 1]]
|
||||||
self.assertEqual(2,len(app.selected_dupes))
|
eq_(len(app.selected_dupes), 2)
|
||||||
self.assert_(app.selected_dupes[0] is objects[1])
|
assert app.selected_dupes[0] is objects[1]
|
||||||
self.assert_(app.selected_dupes[1] is objects[2])
|
assert app.selected_dupes[1] is objects[2]
|
||||||
|
|
||||||
def test_selectResultNodePaths_with_ref(self):
|
def test_selectResultNodePaths_with_ref(self):
|
||||||
app = self.app
|
app = self.app
|
||||||
objects = self.objects
|
objects = self.objects
|
||||||
app.SelectResultNodePaths([[0,0],[0,1],[1]])
|
self.rtree.selected_paths = [[0, 0], [0, 1], [1]]
|
||||||
self.assertEqual(3,len(app.selected_dupes))
|
eq_(len(app.selected_dupes), 3)
|
||||||
self.assert_(app.selected_dupes[0] is objects[1])
|
assert app.selected_dupes[0] is objects[1]
|
||||||
self.assert_(app.selected_dupes[1] is objects[2])
|
assert app.selected_dupes[1] is objects[2]
|
||||||
self.assert_(app.selected_dupes[2] is self.groups[1].ref)
|
assert app.selected_dupes[2] is self.groups[1].ref
|
||||||
|
|
||||||
def test_selectResultNodePaths_empty(self):
|
|
||||||
self.app.SelectResultNodePaths([])
|
|
||||||
self.assertEqual(0,len(self.app.selected_dupes))
|
|
||||||
|
|
||||||
def test_selectResultNodePaths_after_sort(self):
|
def test_selectResultNodePaths_after_sort(self):
|
||||||
app = self.app
|
app = self.app
|
||||||
objects = self.objects
|
objects = self.objects
|
||||||
groups = self.groups[:] #To keep the old order in memory
|
groups = self.groups[:] #To keep the old order in memory
|
||||||
app.sort_groups(0,False) #0 = Filename
|
self.rtree.sort(0, False) #0 = Filename
|
||||||
#Now, the group order is supposed to be reversed
|
#Now, the group order is supposed to be reversed
|
||||||
app.SelectResultNodePaths([[0,0],[1],[1,0]])
|
self.rtree.selected_paths = [[0, 0], [1], [1, 0]]
|
||||||
self.assertEqual(3,len(app.selected_dupes))
|
eq_(len(app.selected_dupes), 3)
|
||||||
self.assert_(app.selected_dupes[0] is objects[4])
|
assert app.selected_dupes[0] is objects[4]
|
||||||
self.assert_(app.selected_dupes[1] is groups[0].ref)
|
assert app.selected_dupes[1] is groups[0].ref
|
||||||
self.assert_(app.selected_dupes[2] is objects[1])
|
assert app.selected_dupes[2] is objects[1]
|
||||||
|
|
||||||
def test_selectResultNodePaths_out_of_range(self):
|
|
||||||
app = self.app
|
|
||||||
app.SelectResultNodePaths([[0,0],[0,1],[1],[1,1],[2]])
|
|
||||||
self.assertEqual(3,len(app.selected_dupes))
|
|
||||||
|
|
||||||
def test_selected_powermarker_node_paths(self):
|
def test_selected_powermarker_node_paths(self):
|
||||||
# app.selected_dupes is correctly converted into paths
|
# app.selected_dupes is correctly converted into paths
|
||||||
app = self.app
|
app = self.app
|
||||||
objects = self.objects
|
objects = self.objects
|
||||||
paths = r2np([0, 1, 2])
|
self.rtree.power_marker = True
|
||||||
app.SelectPowerMarkerNodePaths(paths)
|
self.rtree.selected_paths = [[0], [1], [2]]
|
||||||
eq_(app.selected_powermarker_node_paths(), paths)
|
self.rtree.power_marker = False
|
||||||
|
eq_(self.rtree.selected_paths, [[0, 0], [0, 1], [1, 0]])
|
||||||
|
|
||||||
def test_selected_powermarker_node_paths_after_deletion(self):
|
def test_selected_powermarker_node_paths_after_deletion(self):
|
||||||
# cases where the selected dupes aren't there are correctly handled
|
# cases where the selected dupes aren't there are correctly handled
|
||||||
app = self.app
|
app = self.app
|
||||||
objects = self.objects
|
objects = self.objects
|
||||||
paths = r2np([0, 1, 2])
|
self.rtree.power_marker = True
|
||||||
app.SelectPowerMarkerNodePaths(paths)
|
self.rtree.selected_paths = [[0], [1], [2]]
|
||||||
app.remove_selected()
|
app.remove_selected()
|
||||||
eq_(app.selected_powermarker_node_paths(), []) # no exception
|
eq_(self.rtree.selected_paths, []) # no exception
|
||||||
|
|
||||||
def test_selectPowerMarkerRows(self):
|
def test_selectPowerMarkerRows(self):
|
||||||
app = self.app
|
app = self.app
|
||||||
objects = self.objects
|
objects = self.objects
|
||||||
app.SelectPowerMarkerNodePaths(r2np([0,1,2]))
|
self.rtree.selected_paths = [[0, 0], [0, 1], [1, 0]]
|
||||||
self.assertEqual(3,len(app.selected_dupes))
|
eq_(len(app.selected_dupes), 3)
|
||||||
self.assert_(app.selected_dupes[0] is objects[1])
|
assert app.selected_dupes[0] is objects[1]
|
||||||
self.assert_(app.selected_dupes[1] is objects[2])
|
assert app.selected_dupes[1] is objects[2]
|
||||||
self.assert_(app.selected_dupes[2] is objects[4])
|
assert app.selected_dupes[2] is objects[4]
|
||||||
|
|
||||||
def test_selectPowerMarkerRows_empty(self):
|
def test_selectPowerMarkerRows_empty(self):
|
||||||
self.app.SelectPowerMarkerNodePaths([])
|
self.rtree.selected_paths = []
|
||||||
self.assertEqual(0,len(self.app.selected_dupes))
|
eq_(len(self.app.selected_dupes), 0)
|
||||||
|
|
||||||
def test_selectPowerMarkerRows_after_sort(self):
|
def test_selectPowerMarkerRows_after_sort(self):
|
||||||
app = self.app
|
app = self.app
|
||||||
objects = self.objects
|
objects = self.objects
|
||||||
app.sort_dupes(0,False) #0 = Filename
|
self.rtree.power_marker = True
|
||||||
app.SelectPowerMarkerNodePaths(r2np([0,1,2]))
|
self.rtree.sort(0, False) #0 = Filename
|
||||||
self.assertEqual(3,len(app.selected_dupes))
|
self.rtree.selected_paths = [[0], [1], [2]]
|
||||||
self.assert_(app.selected_dupes[0] is objects[4])
|
eq_(len(app.selected_dupes), 3)
|
||||||
self.assert_(app.selected_dupes[1] is objects[2])
|
assert app.selected_dupes[0] is objects[4]
|
||||||
self.assert_(app.selected_dupes[2] is objects[1])
|
assert app.selected_dupes[1] is objects[2]
|
||||||
|
assert app.selected_dupes[2] is objects[1]
|
||||||
def test_selectPowerMarkerRows_out_of_range(self):
|
|
||||||
app = self.app
|
|
||||||
app.SelectPowerMarkerNodePaths(r2np([0,1,2,3]))
|
|
||||||
self.assertEqual(3,len(app.selected_dupes))
|
|
||||||
|
|
||||||
def test_toggleSelectedMark(self):
|
def test_toggleSelectedMark(self):
|
||||||
app = self.app
|
app = self.app
|
||||||
objects = self.objects
|
objects = self.objects
|
||||||
app.toggle_selected_mark_state()
|
app.toggle_selected_mark_state()
|
||||||
eq_(app.results.mark_count, 0)
|
eq_(app.results.mark_count, 0)
|
||||||
app.SelectPowerMarkerNodePaths(r2np([0,2]))
|
self.rtree.selected_paths = [[0, 0], [1, 0]]
|
||||||
app.toggle_selected_mark_state()
|
app.toggle_selected_mark_state()
|
||||||
eq_(app.results.mark_count, 2)
|
eq_(app.results.mark_count, 2)
|
||||||
assert not app.results.is_marked(objects[0])
|
assert not app.results.is_marked(objects[0])
|
||||||
@ -255,10 +233,10 @@ class TCDupeGuru(TestCase):
|
|||||||
assert app.results.is_marked(objects[4])
|
assert app.results.is_marked(objects[4])
|
||||||
|
|
||||||
def test_refreshDetailsWithSelected(self):
|
def test_refreshDetailsWithSelected(self):
|
||||||
self.app.SelectPowerMarkerNodePaths(r2np([0,2]))
|
self.rtree.selected_paths = [[0, 0], [1, 0]]
|
||||||
eq_(self.dpanel.row(0), ('Filename', 'bar bleh', 'foo bar'))
|
eq_(self.dpanel.row(0), ('Filename', 'bar bleh', 'foo bar'))
|
||||||
self.check_gui_calls(self.dpanel_gui, ['refresh'])
|
self.check_gui_calls(self.dpanel_gui, ['refresh'])
|
||||||
self.app.SelectPowerMarkerNodePaths([])
|
self.rtree.selected_paths = []
|
||||||
eq_(self.dpanel.row(0), ('Filename', '---', '---'))
|
eq_(self.dpanel.row(0), ('Filename', '---', '---'))
|
||||||
self.check_gui_calls(self.dpanel_gui, ['refresh'])
|
self.check_gui_calls(self.dpanel_gui, ['refresh'])
|
||||||
|
|
||||||
@ -266,7 +244,7 @@ class TCDupeGuru(TestCase):
|
|||||||
app = self.app
|
app = self.app
|
||||||
objects = self.objects
|
objects = self.objects
|
||||||
groups = self.groups
|
groups = self.groups
|
||||||
app.SelectPowerMarkerNodePaths(r2np([0,2]))
|
self.rtree.selected_paths = [[0, 0], [1, 0]]
|
||||||
app.make_selected_reference()
|
app.make_selected_reference()
|
||||||
assert groups[0].ref is objects[1]
|
assert groups[0].ref is objects[1]
|
||||||
assert groups[1].ref is objects[4]
|
assert groups[1].ref is objects[4]
|
||||||
@ -275,20 +253,20 @@ class TCDupeGuru(TestCase):
|
|||||||
app = self.app
|
app = self.app
|
||||||
objects = self.objects
|
objects = self.objects
|
||||||
groups = self.groups
|
groups = self.groups
|
||||||
app.SelectPowerMarkerNodePaths(r2np([0,1,2]))
|
self.rtree.selected_paths = [[0, 0], [0, 1], [1, 0]]
|
||||||
#Only 0 and 2 must go ref, not 1 because it is a part of the same group
|
#Only [0, 0] and [1, 0] must go ref, not [0, 1] because it is a part of the same group
|
||||||
app.make_selected_reference()
|
app.make_selected_reference()
|
||||||
assert groups[0].ref is objects[1]
|
assert groups[0].ref is objects[1]
|
||||||
assert groups[1].ref is objects[4]
|
assert groups[1].ref is objects[4]
|
||||||
|
|
||||||
def test_removeSelected(self):
|
def test_removeSelected(self):
|
||||||
app = self.app
|
app = self.app
|
||||||
app.SelectPowerMarkerNodePaths(r2np([0,2]))
|
self.rtree.selected_paths = [[0, 0], [1, 0]]
|
||||||
app.remove_selected()
|
app.remove_selected()
|
||||||
eq_(len(app.results.dupes), 1)
|
eq_(len(app.results.dupes), 1)
|
||||||
app.remove_selected()
|
app.remove_selected()
|
||||||
eq_(len(app.results.dupes), 1)
|
eq_(len(app.results.dupes), 1)
|
||||||
app.SelectPowerMarkerNodePaths(r2np([0,2]))
|
self.rtree.selected_path = [0, 0]
|
||||||
app.remove_selected()
|
app.remove_selected()
|
||||||
eq_(len(app.results.dupes), 0)
|
eq_(len(app.results.dupes), 0)
|
||||||
|
|
||||||
@ -309,13 +287,13 @@ class TCDupeGuru(TestCase):
|
|||||||
|
|
||||||
def test_ignore(self):
|
def test_ignore(self):
|
||||||
app = self.app
|
app = self.app
|
||||||
app.SelectPowerMarkerNodePaths(r2np([2])) #The dupe of the second, 2 sized group
|
self.rtree.selected_path = [1, 0] #The dupe of the second, 2 sized group
|
||||||
app.add_selected_to_ignore_list()
|
app.add_selected_to_ignore_list()
|
||||||
self.assertEqual(1,len(app.scanner.ignore_list))
|
eq_(len(app.scanner.ignore_list), 1)
|
||||||
app.SelectPowerMarkerNodePaths(r2np([0])) #first dupe of the 3 dupes group
|
self.rtree.selected_path = [0, 0] #first dupe of the 3 dupes group
|
||||||
app.add_selected_to_ignore_list()
|
app.add_selected_to_ignore_list()
|
||||||
#BOTH the ref and the other dupe should have been added
|
#BOTH the ref and the other dupe should have been added
|
||||||
self.assertEqual(3,len(app.scanner.ignore_list))
|
eq_(len(app.scanner.ignore_list), 3)
|
||||||
|
|
||||||
def test_purgeIgnoreList(self):
|
def test_purgeIgnoreList(self):
|
||||||
app = self.app
|
app = self.app
|
||||||
@ -339,7 +317,7 @@ class TCDupeGuru(TestCase):
|
|||||||
|
|
||||||
app = self.app
|
app = self.app
|
||||||
app.scanner.ignore_list.Ignore = FakeIgnore
|
app.scanner.ignore_list.Ignore = FakeIgnore
|
||||||
app.SelectPowerMarkerNodePaths(r2np([2])) #The dupe of the second, 2 sized group
|
self.rtree.selected_path = [1, 0]
|
||||||
app.add_selected_to_ignore_list()
|
app.add_selected_to_ignore_list()
|
||||||
|
|
||||||
|
|
||||||
@ -363,11 +341,13 @@ class TCDupeGuru_renameSelected(TestCase):
|
|||||||
self.groups = groups
|
self.groups = groups
|
||||||
self.p = p
|
self.p = p
|
||||||
self.files = files
|
self.files = files
|
||||||
|
self.rtree_gui = CallLogger()
|
||||||
|
self.rtree = ResultTree(self.rtree_gui, self.app)
|
||||||
|
|
||||||
def test_simple(self):
|
def test_simple(self):
|
||||||
app = self.app
|
app = self.app
|
||||||
g = self.groups[0]
|
g = self.groups[0]
|
||||||
app.SelectPowerMarkerNodePaths(r2np([0]))
|
self.rtree.selected_path = [0, 0]
|
||||||
assert app.RenameSelected('renamed')
|
assert app.RenameSelected('renamed')
|
||||||
names = io.listdir(self.p)
|
names = io.listdir(self.p)
|
||||||
assert 'renamed' in names
|
assert 'renamed' in names
|
||||||
@ -377,7 +357,7 @@ class TCDupeGuru_renameSelected(TestCase):
|
|||||||
def test_none_selected(self):
|
def test_none_selected(self):
|
||||||
app = self.app
|
app = self.app
|
||||||
g = self.groups[0]
|
g = self.groups[0]
|
||||||
app.SelectPowerMarkerNodePaths([])
|
self.rtree.selected_paths = []
|
||||||
self.mock(logging, 'warning', log_calls(lambda msg: None))
|
self.mock(logging, 'warning', log_calls(lambda msg: None))
|
||||||
assert not app.RenameSelected('renamed')
|
assert not app.RenameSelected('renamed')
|
||||||
msg = logging.warning.calls[0]['msg']
|
msg = logging.warning.calls[0]['msg']
|
||||||
@ -390,7 +370,7 @@ class TCDupeGuru_renameSelected(TestCase):
|
|||||||
def test_name_already_exists(self):
|
def test_name_already_exists(self):
|
||||||
app = self.app
|
app = self.app
|
||||||
g = self.groups[0]
|
g = self.groups[0]
|
||||||
app.SelectPowerMarkerNodePaths(r2np([0]))
|
self.rtree.selected_path = [0, 0]
|
||||||
self.mock(logging, 'warning', log_calls(lambda msg: None))
|
self.mock(logging, 'warning', log_calls(lambda msg: None))
|
||||||
assert not app.RenameSelected('foo bar 1')
|
assert not app.RenameSelected('foo bar 1')
|
||||||
msg = logging.warning.calls[0]['msg']
|
msg = logging.warning.calls[0]['msg']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user