diff --git a/base/cocoa/AppDelegate.h b/base/cocoa/AppDelegate.h new file mode 100644 index 00000000..055e0a67 --- /dev/null +++ b/base/cocoa/AppDelegate.h @@ -0,0 +1,17 @@ +#import +#import "RecentDirectories.h" +#import "PyDupeGuru.h" + +@interface AppDelegateBase : NSObject +{ + IBOutlet PyDupeGuruBase *py; + IBOutlet RecentDirectories *recentDirectories; + IBOutlet NSMenuItem *unlockMenuItem; + + NSString *_appName; +} +- (IBAction)unlockApp:(id)sender; + +- (PyDupeGuruBase *)py; +- (RecentDirectories *)recentDirectories; +@end diff --git a/base/cocoa/AppDelegate.m b/base/cocoa/AppDelegate.m new file mode 100644 index 00000000..ef3d9162 --- /dev/null +++ b/base/cocoa/AppDelegate.m @@ -0,0 +1,30 @@ +#import "AppDelegate.h" +#import "ProgressController.h" +#import "RegistrationInterface.h" +#import "Utils.h" +#import "Consts.h" + +@implementation AppDelegateBase +- (id)init +{ + self = [super init]; + _appName = @""; + return self; +} + +- (IBAction)unlockApp:(id)sender +{ + if ([[self py] isRegistered]) + return; + RegistrationInterface *ri = [[RegistrationInterface alloc] initWithApp:[self py] name:_appName limitDescription:LIMIT_DESC]; + if ([ri enterCode] == NSOKButton) + { + NSString *menuTitle = [NSString stringWithFormat:@"Thanks for buying %@",_appName]; + [unlockMenuItem setTitle:menuTitle]; + } + [ri release]; +} + +- (PyDupeGuruBase *)py { return py; } +- (RecentDirectories *)recentDirectories { return recentDirectories; } +@end diff --git a/base/cocoa/Consts.h b/base/cocoa/Consts.h new file mode 100644 index 00000000..c0c8a7ee --- /dev/null +++ b/base/cocoa/Consts.h @@ -0,0 +1,17 @@ +#import + +#define DuplicateSelectionChangedNotification @"DuplicateSelectionChangedNotification" +#define ResultsChangedNotification @"ResultsChangedNotification" +#define ResultsMarkingChangedNotification @"ResultsMarkingChangedNotification" +#define RegistrationRequired @"RegistrationRequired" +#define JobStarted @"JobStarted" +#define JobInProgress @"JobInProgress" + +#define jobLoad @"job_load" +#define jobScan @"job_scan" +#define jobCopy @"job_copy" +#define jobMove @"job_move" +#define jobDelete @"job_delete" + +#define DEMO_MAX_ACTION_COUNT 10 +#define LIMIT_DESC @"In the demo version, only 10 duplicates per session can be sent to Trash, moved or copied." \ No newline at end of file diff --git a/base/cocoa/DirectoryPanel.h b/base/cocoa/DirectoryPanel.h new file mode 100644 index 00000000..d5738b29 --- /dev/null +++ b/base/cocoa/DirectoryPanel.h @@ -0,0 +1,25 @@ +#import +#import "RecentDirectories.h" +#import "Outline.h" +#import "PyDupeGuru.h" + +@interface DirectoryPanelBase : NSWindowController +{ + IBOutlet NSPopUpButton *addButtonPopUp; + IBOutlet OutlineView *directories; + IBOutlet NSButton *removeButton; + + PyDupeGuruBase *_py; + RecentDirectories *_recentDirectories; +} +- (id)initWithParentApp:(id)aParentApp; + +- (IBAction)askForDirectory:(id)sender; +- (IBAction)changeDirectoryState:(id)sender; +- (IBAction)popupAddDirectoryMenu:(id)sender; +- (IBAction)removeSelectedDirectory:(id)sender; +- (IBAction)toggleVisible:(id)sender; + +- (void)addDirectory:(NSString *)directory; +- (void)refreshRemoveButtonText; +@end diff --git a/base/cocoa/DirectoryPanel.m b/base/cocoa/DirectoryPanel.m new file mode 100644 index 00000000..b62b7ae8 --- /dev/null +++ b/base/cocoa/DirectoryPanel.m @@ -0,0 +1,178 @@ +#import "DirectoryPanel.h" +#import "Dialogs.h" +#import "Utils.h" +#import "AppDelegate.h" + +@implementation DirectoryPanelBase +- (id)initWithParentApp:(id)aParentApp +{ + self = [super initWithWindowNibName:@"Directories"]; + [self window]; + AppDelegateBase *app = aParentApp; + _py = [app py]; + _recentDirectories = [app recentDirectories]; + [directories setPy:_py]; + NSPopUpButtonCell *cell = [[directories tableColumnWithIdentifier:@"1"] dataCell]; + [cell addItemWithTitle:@"Normal"]; + [cell addItemWithTitle:@"Reference"]; + [cell addItemWithTitle:@"Excluded"]; + for (int i=0;i<[[cell itemArray] count];i++) + { + NSMenuItem *mi = [[cell itemArray] objectAtIndex:i]; + [mi setTarget:self]; + [mi setAction:@selector(changeDirectoryState:)]; + [mi setTag:i]; + } + [self refreshRemoveButtonText]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(directorySelectionChanged:) name:NSOutlineViewSelectionDidChangeNotification object:directories]; + return self; +} + +/* Actions */ + +- (IBAction)askForDirectory:(id)sender +{ + NSOpenPanel *op = [NSOpenPanel openPanel]; + [op setCanChooseFiles:YES]; + [op setCanChooseDirectories:YES]; + [op setAllowsMultipleSelection:NO]; + [op setTitle:@"Select a directory to add to the scanning list"]; + [op setDelegate:self]; + if ([op runModalForTypes:nil] == NSOKButton) + { + NSString *directory = [[op filenames] objectAtIndex:0]; + [self addDirectory:directory]; + } +} + +- (IBAction)changeDirectoryState:(id)sender +{ + OVNode *node = [directories itemAtRow:[directories clickedRow]]; + [_py setDirectory:p2a([node indexPath]) state:i2n([sender tag])]; + [node resetAllBuffers]; + [directories display]; +} + +- (IBAction)popupAddDirectoryMenu:(id)sender +{ + if ([[_recentDirectories directories] count] == 0) + { + [self askForDirectory:sender]; + return; + } + NSMenu *m = [addButtonPopUp menu]; + while ([m numberOfItems] > 0) + [m removeItemAtIndex:0]; + NSMenuItem *mi = [m addItemWithTitle:@"Add New Directory..." action:@selector(askForDirectory:) keyEquivalent:@""]; + [mi setTarget:self]; + [m addItem:[NSMenuItem separatorItem]]; + [_recentDirectories fillMenu:m]; + [addButtonPopUp selectItem:nil]; + [[addButtonPopUp cell] performClickWithFrame:[sender frame] inView:[sender superview]]; +} + +- (IBAction)removeSelectedDirectory:(id)sender +{ + [[self window] makeKeyAndOrderFront:nil]; + if ([directories selectedRow] < 0) + return; + OVNode *node = [directories itemAtRow:[directories selectedRow]]; + if ([node level] == 1) + { + [_py removeDirectory:i2n([node index])]; + [directories reloadData]; + } + else + { + int state = n2i([[node buffer] objectAtIndex:1]); + int newState = state == 2 ? 0 : 2; // If excluded, put it back + [_py setDirectory:p2a([node indexPath]) state:i2n(newState)]; + [node resetAllBuffers]; + [directories display]; + } + [self refreshRemoveButtonText]; +} + +- (IBAction)toggleVisible:(id)sender +{ + if ([[self window] isVisible]) + [[self window] close]; + else + [[self window] makeKeyAndOrderFront:nil]; +} + +/* Public */ + +- (void)addDirectory:(NSString *)directory +{ + int r = [[_py addDirectory:directory] intValue]; + if (r) + { + NSString *m; + switch (r) + { + case 1: + { + m = @"This directory already is in the list."; + break; + } + case 2: + { + m = @"This directory does not exist."; + break; + } + } + [Dialogs showMessage:m]; + } + [directories reloadData]; + [_recentDirectories addDirectory:directory]; + [[self window] makeKeyAndOrderFront:nil]; +} + +- (void)refreshRemoveButtonText +{ + if ([directories selectedRow] < 0) + { + [removeButton setEnabled:NO]; + return; + } + [removeButton setEnabled:YES]; + OVNode *node = [directories itemAtRow:[directories selectedRow]]; + int state = n2i([[node buffer] objectAtIndex:1]); + NSString *buttonText = state == 2 ? @"Put Back" : @"Remove"; + [removeButton setTitle:buttonText]; +} + +/* Delegate */ + +- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item +{ + OVNode *node = item; + int state = n2i([[node buffer] objectAtIndex:1]); + if ([cell isKindOfClass:[NSTextFieldCell class]]) + { + NSTextFieldCell *textCell = cell; + if (state == 1) + [textCell setTextColor:[NSColor blueColor]]; + else if (state == 2) + [textCell setTextColor:[NSColor redColor]]; + else + [textCell setTextColor:[NSColor blackColor]]; + } +} + +- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)path +{ + BOOL isdir; + [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isdir]; + return isdir; +} + +/* Notifications */ + +- (void)directorySelectionChanged:(NSNotification *)aNotification +{ + [self refreshRemoveButtonText]; +} + +@end diff --git a/base/cocoa/English.lproj/InfoPlist.strings b/base/cocoa/English.lproj/InfoPlist.strings new file mode 100644 index 00000000..948e12b9 Binary files /dev/null and b/base/cocoa/English.lproj/InfoPlist.strings differ diff --git a/base/cocoa/Info.plist b/base/cocoa/Info.plist new file mode 100644 index 00000000..80dcade2 --- /dev/null +++ b/base/cocoa/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleName + ${PRODUCT_NAME} + CFBundleIconFile + + CFBundleIdentifier + com.yourcompany.yourcocoaframework + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSPrincipalClass + + + diff --git a/base/cocoa/PyDupeGuru.h b/base/cocoa/PyDupeGuru.h new file mode 100644 index 00000000..6a660b03 --- /dev/null +++ b/base/cocoa/PyDupeGuru.h @@ -0,0 +1,56 @@ +#import +#import "PyApp.h" + +@interface PyDupeGuruBase : PyApp +//Actions +- (NSNumber *)addDirectory:(NSString *)name; +- (void)removeDirectory:(NSNumber *)index; +- (void)setDirectory:(NSArray *)indexPath state:(NSNumber *)state; +- (void)loadResults; +- (void)saveResults; +- (void)loadIgnoreList; +- (void)saveIgnoreList; +- (void)clearIgnoreList; +- (void)purgeIgnoreList; +- (NSString *)exportToXHTMLwithColumns:(NSArray *)aColIds xslt:(NSString *)xsltPath css:(NSString *)cssPath; + +- (NSNumber *)doScan; + +- (void)selectPowerMarkerNodePaths:(NSArray *)aIndexPaths; +- (void)selectResultNodePaths:(NSArray *)aIndexPaths; + +- (void)toggleSelectedMark; +- (void)markAll; +- (void)markInvert; +- (void)markNone; + +- (void)addSelectedToIgnoreList; +- (void)refreshDetailsWithSelected; +- (void)removeSelected; +- (void)openSelected; +- (NSNumber *)renameSelected:(NSString *)aNewName; +- (void)revealSelected; +- (void)makeSelectedReference; +- (void)applyFilter:(NSString *)filter; + +- (void)sortGroupsBy:(NSNumber *)aIdentifier ascending:(NSNumber *)aAscending; +- (void)sortDupesBy:(NSNumber *)aIdentifier ascending:(NSNumber *)aAscending; + +- (void)copyOrMove:(NSNumber *)aCopy markedTo:(NSString *)destination recreatePath:(NSNumber *)aRecreateType; +- (void)deleteMarked; +- (void)removeMarked; + +//Data +- (NSNumber *)getIgnoreListCount; +- (NSNumber *)getMarkCount; +- (NSString *)getStatLine; +- (NSNumber *)getOperationalErrorCount; + +//Scanning options +- (void)setMinMatchPercentage:(NSNumber *)percentage; +- (void)setMixFileKind:(NSNumber *)mix_file_kind; +- (void)setDisplayDeltaValues:(NSNumber *)display_delta_values; +- (void)setEscapeFilterRegexp:(NSNumber *)escape_filter_regexp; +- (void)setRemoveEmptyFolders:(NSNumber *)remove_empty_folders; +- (void)setSizeThreshold:(int)size_threshold; +@end diff --git a/base/cocoa/ResultWindow.h b/base/cocoa/ResultWindow.h new file mode 100644 index 00000000..1cdfb70f --- /dev/null +++ b/base/cocoa/ResultWindow.h @@ -0,0 +1,34 @@ +#import +#import "Outline.h" +#import "DirectoryPanel.h" +#import "PyDupeGuru.h" + +@interface MatchesView : OutlineView +- (void)keyDown:(NSEvent *)theEvent; +@end + +@interface ResultWindowBase : NSWindowController +{ +@protected + IBOutlet PyDupeGuruBase *py; + IBOutlet id app; + IBOutlet NSView *actionMenuView; + IBOutlet NSSegmentedControl *deltaSwitch; + IBOutlet NSView *deltaSwitchView; + IBOutlet NSView *filterFieldView; + IBOutlet MatchesView *matches; + IBOutlet NSView *pmSwitchView; + + BOOL _powerMode; + BOOL _displayDelta; +} +- (NSString *)logoImageName; +/* Actions */ +- (IBAction)changeDelta:(id)sender; +- (IBAction)copyMarked:(id)sender; +- (IBAction)deleteMarked:(id)sender; +- (IBAction)expandAll:(id)sender; +- (IBAction)moveMarked:(id)sender; +/* Notifications */ +- (void)jobCompleted:(NSNotification *)aNotification; +@end diff --git a/base/cocoa/ResultWindow.m b/base/cocoa/ResultWindow.m new file mode 100644 index 00000000..1aa6cb8a --- /dev/null +++ b/base/cocoa/ResultWindow.m @@ -0,0 +1,316 @@ +#import "ResultWindow.h" +#import "Dialogs.h" +#import "ProgressController.h" +#import "Utils.h" +#import "RegistrationInterface.h" +#import "AppDelegate.h" +#import "Consts.h" + +#define tbbDirectories @"tbbDirectories" +#define tbbDetails @"tbbDetail" +#define tbbPreferences @"tbbPreferences" +#define tbbPowerMarker @"tbbPowerMarker" +#define tbbScan @"tbbScan" +#define tbbAction @"tbbAction" +#define tbbDelta @"tbbDelta" +#define tbbFilter @"tbbFilter" + +@implementation MatchesView +- (void)keyDown:(NSEvent *)theEvent +{ + unichar key = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; + // get flags and strip the lower 16 (device dependant) bits + unsigned int flags = ( [theEvent modifierFlags] & 0x00FF ); + if (((key == NSDeleteFunctionKey) || (key == NSDeleteCharacter)) && (flags == 0)) + [self sendAction:@selector(removeSelected:) to:[self delegate]]; + else + if ((key == 0x20) && (flags == 0)) // Space + [self sendAction:@selector(markSelected:) to:[self delegate]]; + else + [super keyDown:theEvent]; +} + +- (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item +{ + if (![[tableColumn identifier] isEqual:@"0"]) + return; //We only want to cover renames. + OVNode *node = item; + NSString *oldName = [[node buffer] objectAtIndex:0]; + NSString *newName = object; + if (![newName isEqual:oldName]) + { + BOOL renamed = n2b([(PyDupeGuruBase *)py renameSelected:newName]); + if (renamed) + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; + else + [Dialogs showMessage:[NSString stringWithFormat:@"The name '%@' already exists.",newName]]; + } +} +@end + +@implementation ResultWindowBase +- (void)awakeFromNib +{ + [self window]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(registrationRequired:) name:RegistrationRequired object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jobStarted:) name:JobStarted object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jobInProgress:) name:JobInProgress object:nil]; +} + +/* Virtual */ +- (NSString *)logoImageName +{ + return @"dg_logo32"; +} + +/* Actions */ +- (IBAction)changeDelta:(id)sender +{ + _displayDelta = [deltaSwitch selectedSegment] == 1; + [py setDisplayDeltaValues:b2n(_displayDelta)]; + [matches reloadData]; + [self expandAll:nil]; +} + +- (IBAction)copyMarked:(id)sender +{ + int mark_count = [[py getMarkCount] intValue]; + if (!mark_count) + return; + NSOpenPanel *op = [NSOpenPanel openPanel]; + [op setCanChooseFiles:NO]; + [op setCanChooseDirectories:YES]; + [op setCanCreateDirectories:YES]; + [op setAllowsMultipleSelection:NO]; + [op setTitle:@"Select a directory to copy marked files to"]; + if ([op runModalForTypes:nil] == NSOKButton) + { + NSString *directory = [[op filenames] objectAtIndex:0]; + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + [py copyOrMove:b2n(YES) markedTo:directory recreatePath:[ud objectForKey:@"recreatePathType"]]; + } +} + +- (IBAction)deleteMarked:(id)sender +{ + int mark_count = [[py getMarkCount] intValue]; + if (!mark_count) + return; + if ([Dialogs askYesNo:[NSString stringWithFormat:@"You are about to send %d files to Trash. Continue?",mark_count]] == NSAlertSecondButtonReturn) // NO + return; + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + [py setRemoveEmptyFolders:[ud objectForKey:@"removeEmptyFolders"]]; + [py deleteMarked]; +} + +- (IBAction)expandAll:(id)sender +{ + for (int i=0;i < [matches numberOfRows];i++) + [matches expandItem:[matches itemAtRow:i]]; +} + +- (IBAction)moveMarked:(id)sender +{ + int mark_count = [[py getMarkCount] intValue]; + if (!mark_count) + return; + NSOpenPanel *op = [NSOpenPanel openPanel]; + [op setCanChooseFiles:NO]; + [op setCanChooseDirectories:YES]; + [op setCanCreateDirectories:YES]; + [op setAllowsMultipleSelection:NO]; + [op setTitle:@"Select a directory to move marked files to"]; + if ([op runModalForTypes:nil] == NSOKButton) + { + NSString *directory = [[op filenames] objectAtIndex:0]; + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + [py setRemoveEmptyFolders:[ud objectForKey:@"removeEmptyFolders"]]; + [py copyOrMove:b2n(NO) markedTo:directory recreatePath:[ud objectForKey:@"recreatePathType"]]; + } +} + +/* Delegate */ + +- (void)outlineView:(NSOutlineView *)outlineView didClickTableColumn:(NSTableColumn *)tableColumn +{ + if ([[outlineView sortDescriptors] count] < 1) + return; + NSSortDescriptor *sd = [[outlineView sortDescriptors] objectAtIndex:0]; + if (_powerMode) + [py sortDupesBy:i2n([[sd key] intValue]) ascending:b2n([sd ascending])]; + else + [py sortGroupsBy:i2n([[sd key] intValue]) ascending:b2n([sd ascending])]; + [matches reloadData]; + [self expandAll:nil]; +} + +/* Notifications */ +- (void)windowWillClose:(NSNotification *)aNotification +{ + [NSApp hide:NSApp]; +} + +- (void)jobCompleted:(NSNotification *)aNotification +{ + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; + int r = n2i([py getOperationalErrorCount]); + id lastAction = [[ProgressController mainProgressController] jobId]; + if ([lastAction isEqualTo:jobCopy]) + { + if (r > 0) + [Dialogs showMessage:[NSString stringWithFormat:@"%d file(s) couldn't be copied.",r]]; + else + [Dialogs showMessage:@"All marked files were copied sucessfully."]; + } + if ([lastAction isEqualTo:jobMove]) + { + if (r > 0) + [Dialogs showMessage:[NSString stringWithFormat:@"%d file(s) couldn't be moved. They were kept in the results, and still are marked.",r]]; + else + [Dialogs showMessage:@"All marked files were moved sucessfully."]; + } + if ([lastAction isEqualTo:jobDelete]) + { + if (r > 0) + [Dialogs showMessage:[NSString stringWithFormat:@"%d file(s) couldn't be sent to Trash. They were kept in the results, and still are marked.",r]]; + else + [Dialogs showMessage:@"All marked files were sucessfully sent to Trash."]; + } + // Re-activate toolbar items right after the progress bar stops showing instead of waiting until + // a mouse-over is performed + [[[self window] toolbar] validateVisibleItems]; +} + +- (void)jobInProgress:(NSNotification *)aNotification +{ + [Dialogs showMessage:@"A previous action is still hanging in there. You can't start a new one yet. Wait a few seconds, then try again."]; +} + +- (void)jobStarted:(NSNotification *)aNotification +{ + NSDictionary *ui = [aNotification userInfo]; + NSString *desc = [ui valueForKey:@"desc"]; + [[ProgressController mainProgressController] setJobDesc:desc]; + NSString *jobid = [ui valueForKey:@"jobid"]; + // NSLog(jobid); + [[ProgressController mainProgressController] setJobId:jobid]; + [[ProgressController mainProgressController] showSheetForParent:[self window]]; +} + +- (void)registrationRequired:(NSNotification *)aNotification +{ + NSString *msg = @"This is a demo version, which only allows you 10 delete/copy/move actions per session. You cannot continue."; + [Dialogs showMessage:msg]; +} + +/* Toolbar */ +- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag +{ + NSToolbarItem *tbi = [[[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier] autorelease]; + if ([itemIdentifier isEqualTo:tbbDirectories]) + { + [tbi setLabel: @"Directories"]; + [tbi setToolTip: @"Show/Hide the directories panel."]; + [tbi setImage: [NSImage imageNamed: @"folder32"]]; + [tbi setTarget: app]; + [tbi setAction: @selector(toggleDirectories:)]; + } + else if ([itemIdentifier isEqualTo:tbbDetails]) + { + [tbi setLabel: @"Details"]; + [tbi setToolTip: @"Show/Hide the details panel."]; + [tbi setImage: [NSImage imageNamed: @"details32"]]; + [tbi setTarget: self]; + [tbi setAction: @selector(toggleDetailsPanel:)]; + } + else if ([itemIdentifier isEqualTo:tbbPreferences]) + { + [tbi setLabel: @"Preferences"]; + [tbi setToolTip: @"Show the preferences panel."]; + [tbi setImage: [NSImage imageNamed: @"preferences32"]]; + [tbi setTarget: self]; + [tbi setAction: @selector(showPreferencesPanel:)]; + } + else if ([itemIdentifier isEqualTo:tbbPowerMarker]) + { + [tbi setLabel: @"Power Marker"]; + [tbi setToolTip: @"When enabled, only the duplicates are shown, not the references."]; + [tbi setView:pmSwitchView]; + [tbi setMinSize:[pmSwitchView frame].size]; + [tbi setMaxSize:[pmSwitchView frame].size]; + } + else if ([itemIdentifier isEqualTo:tbbScan]) + { + [tbi setLabel: @"Start Scanning"]; + [tbi setToolTip: @"Start scanning for duplicates in the selected directories."]; + [tbi setImage: [NSImage imageNamed:[self logoImageName]]]; + [tbi setTarget: self]; + [tbi setAction: @selector(startDuplicateScan:)]; + } + else if ([itemIdentifier isEqualTo:tbbAction]) + { + [tbi setLabel: @"Action"]; + [tbi setView:actionMenuView]; + [tbi setMinSize:[actionMenuView frame].size]; + [tbi setMaxSize:[actionMenuView frame].size]; + } + else if ([itemIdentifier isEqualTo:tbbDelta]) + { + [tbi setLabel: @"Delta Values"]; + [tbi setToolTip: @"When enabled, this option makes dupeGuru display, where applicable, delta values instead of absolute values."]; + [tbi setView:deltaSwitchView]; + [tbi setMinSize:[deltaSwitchView frame].size]; + [tbi setMaxSize:[deltaSwitchView frame].size]; + } + else if ([itemIdentifier isEqualTo:tbbFilter]) + { + [tbi setLabel: @"Filter"]; + [tbi setToolTip: @"Filters the results using regular expression."]; + [tbi setView:filterFieldView]; + [tbi setMinSize:[filterFieldView frame].size]; + [tbi setMaxSize:NSMakeSize(1000, [filterFieldView frame].size.height)]; + } + [tbi setPaletteLabel: [tbi label]]; + return tbi; +} + +- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar +{ + return [NSArray arrayWithObjects: + tbbDirectories, + tbbDetails, + tbbPreferences, + tbbPowerMarker, + tbbScan, + tbbAction, + tbbDelta, + tbbFilter, + NSToolbarSeparatorItemIdentifier, + NSToolbarSpaceItemIdentifier, + NSToolbarFlexibleSpaceItemIdentifier, + nil]; +} + +- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar +{ + return [NSArray arrayWithObjects: + tbbScan, + tbbAction, + tbbDirectories, + tbbDetails, + tbbPowerMarker, + tbbDelta, + tbbFilter, + nil]; +} + +- (BOOL)validateToolbarItem:(NSToolbarItem *)theItem +{ + return ![[ProgressController mainProgressController] isShown]; +} + +- (BOOL)validateMenuItem:(NSMenuItem *)item +{ + return ![[ProgressController mainProgressController] isShown]; +} +@end diff --git a/base/cocoa/dgbase.xcodeproj/project.pbxproj b/base/cocoa/dgbase.xcodeproj/project.pbxproj new file mode 100644 index 00000000..54889c77 --- /dev/null +++ b/base/cocoa/dgbase.xcodeproj/project.pbxproj @@ -0,0 +1,408 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 44; + objects = { + +/* Begin PBXBuildFile section */ + 8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; }; + 8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */; }; + CE62CA730CFAF80D0001B6E0 /* ResultWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = CE62CA710CFAF80D0001B6E0 /* ResultWindow.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CE62CA740CFAF80D0001B6E0 /* ResultWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CE62CA720CFAF80D0001B6E0 /* ResultWindow.m */; }; + CE70A0FC0CF8C2560048C314 /* PyDupeGuru.h in Headers */ = {isa = PBXBuildFile; fileRef = CE70A0FB0CF8C2560048C314 /* PyDupeGuru.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CE7D77050CF8987800BA287E /* Consts.h in Headers */ = {isa = PBXBuildFile; fileRef = CE7D77030CF8987800BA287E /* Consts.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CE80DA190FC191320086DCA6 /* RecentDirectories.h in Headers */ = {isa = PBXBuildFile; fileRef = CE80DA170FC191320086DCA6 /* RecentDirectories.h */; settings = {ATTRIBUTES = (Private, ); }; }; + CE80DA1A0FC191320086DCA6 /* RecentDirectories.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DA180FC191320086DCA6 /* RecentDirectories.m */; }; + CE80DA2E0FC191980086DCA6 /* Dialogs.h in Headers */ = {isa = PBXBuildFile; fileRef = CE80DA250FC191980086DCA6 /* Dialogs.h */; settings = {ATTRIBUTES = (Private, ); }; }; + CE80DA2F0FC191980086DCA6 /* Dialogs.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DA260FC191980086DCA6 /* Dialogs.m */; }; + CE80DA300FC191980086DCA6 /* ProgressController.h in Headers */ = {isa = PBXBuildFile; fileRef = CE80DA270FC191980086DCA6 /* ProgressController.h */; settings = {ATTRIBUTES = (Private, ); }; }; + CE80DA310FC191980086DCA6 /* ProgressController.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DA280FC191980086DCA6 /* ProgressController.m */; }; + CE80DA320FC191980086DCA6 /* PyApp.h in Headers */ = {isa = PBXBuildFile; fileRef = CE80DA290FC191980086DCA6 /* PyApp.h */; settings = {ATTRIBUTES = (Private, ); }; }; + CE80DA330FC191980086DCA6 /* RegistrationInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = CE80DA2A0FC191980086DCA6 /* RegistrationInterface.h */; settings = {ATTRIBUTES = (Private, ); }; }; + CE80DA340FC191980086DCA6 /* RegistrationInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DA2B0FC191980086DCA6 /* RegistrationInterface.m */; }; + CE80DA350FC191980086DCA6 /* Utils.h in Headers */ = {isa = PBXBuildFile; fileRef = CE80DA2C0FC191980086DCA6 /* Utils.h */; settings = {ATTRIBUTES = (Private, ); }; }; + CE80DA360FC191980086DCA6 /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DA2D0FC191980086DCA6 /* Utils.m */; }; + CE80DA3B0FC191C40086DCA6 /* Outline.h in Headers */ = {isa = PBXBuildFile; fileRef = CE80DA370FC191C40086DCA6 /* Outline.h */; settings = {ATTRIBUTES = (Private, ); }; }; + CE80DA3C0FC191C40086DCA6 /* Outline.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DA380FC191C40086DCA6 /* Outline.m */; }; + CE80DA3D0FC191C40086DCA6 /* Table.h in Headers */ = {isa = PBXBuildFile; fileRef = CE80DA390FC191C40086DCA6 /* Table.h */; settings = {ATTRIBUTES = (Private, ); }; }; + CE80DA3E0FC191C40086DCA6 /* Table.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DA3A0FC191C40086DCA6 /* Table.m */; }; + CE80DB6D0FC194560086DCA6 /* progress.nib in Resources */ = {isa = PBXBuildFile; fileRef = CE80DB690FC194560086DCA6 /* progress.nib */; }; + CE80DB6E0FC194560086DCA6 /* registration.nib in Resources */ = {isa = PBXBuildFile; fileRef = CE80DB6B0FC194560086DCA6 /* registration.nib */; }; + CE895B5F0CFAE78300B5ADEA /* AppDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = CE895B5D0CFAE78300B5ADEA /* AppDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CE895B600CFAE78300B5ADEA /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CE895B5E0CFAE78300B5ADEA /* AppDelegate.m */; }; + CE895C150CFAF0C900B5ADEA /* DirectoryPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = CE895C130CFAF0C900B5ADEA /* DirectoryPanel.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CE895C160CFAF0C900B5ADEA /* DirectoryPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = CE895C140CFAF0C900B5ADEA /* DirectoryPanel.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 0867D69BFE84028FC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; + 0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; + 089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; + 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; + 8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 8DC2EF5B0486A6940098B216 /* dgbase.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = dgbase.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + CE62CA710CFAF80D0001B6E0 /* ResultWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResultWindow.h; sourceTree = ""; }; + CE62CA720CFAF80D0001B6E0 /* ResultWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ResultWindow.m; sourceTree = ""; }; + CE70A0FB0CF8C2560048C314 /* PyDupeGuru.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PyDupeGuru.h; sourceTree = ""; }; + CE7D77030CF8987800BA287E /* Consts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Consts.h; sourceTree = ""; }; + CE80DA170FC191320086DCA6 /* RecentDirectories.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RecentDirectories.h; path = ../../../cocoalib/RecentDirectories.h; sourceTree = SOURCE_ROOT; }; + CE80DA180FC191320086DCA6 /* RecentDirectories.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RecentDirectories.m; path = ../../../cocoalib/RecentDirectories.m; sourceTree = SOURCE_ROOT; }; + CE80DA250FC191980086DCA6 /* Dialogs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Dialogs.h; path = ../../../cocoalib/Dialogs.h; sourceTree = SOURCE_ROOT; }; + CE80DA260FC191980086DCA6 /* Dialogs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Dialogs.m; path = ../../../cocoalib/Dialogs.m; sourceTree = SOURCE_ROOT; }; + CE80DA270FC191980086DCA6 /* ProgressController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ProgressController.h; path = ../../../cocoalib/ProgressController.h; sourceTree = SOURCE_ROOT; }; + CE80DA280FC191980086DCA6 /* ProgressController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ProgressController.m; path = ../../../cocoalib/ProgressController.m; sourceTree = SOURCE_ROOT; }; + CE80DA290FC191980086DCA6 /* PyApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PyApp.h; path = ../../../cocoalib/PyApp.h; sourceTree = SOURCE_ROOT; }; + CE80DA2A0FC191980086DCA6 /* RegistrationInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegistrationInterface.h; path = ../../../cocoalib/RegistrationInterface.h; sourceTree = SOURCE_ROOT; }; + CE80DA2B0FC191980086DCA6 /* RegistrationInterface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RegistrationInterface.m; path = ../../../cocoalib/RegistrationInterface.m; sourceTree = SOURCE_ROOT; }; + CE80DA2C0FC191980086DCA6 /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Utils.h; path = ../../../cocoalib/Utils.h; sourceTree = SOURCE_ROOT; }; + CE80DA2D0FC191980086DCA6 /* Utils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Utils.m; path = ../../../cocoalib/Utils.m; sourceTree = SOURCE_ROOT; }; + CE80DA370FC191C40086DCA6 /* Outline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Outline.h; path = ../../../cocoalib/Outline.h; sourceTree = SOURCE_ROOT; }; + CE80DA380FC191C40086DCA6 /* Outline.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Outline.m; path = ../../../cocoalib/Outline.m; sourceTree = SOURCE_ROOT; }; + CE80DA390FC191C40086DCA6 /* Table.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Table.h; path = ../../../cocoalib/Table.h; sourceTree = SOURCE_ROOT; }; + CE80DA3A0FC191C40086DCA6 /* Table.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Table.m; path = ../../../cocoalib/Table.m; sourceTree = SOURCE_ROOT; }; + CE80DB6A0FC194560086DCA6 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = ../../../cocoalib/English.lproj/progress.nib; sourceTree = SOURCE_ROOT; }; + CE80DB6C0FC194560086DCA6 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = ../../../cocoalib/English.lproj/registration.nib; sourceTree = SOURCE_ROOT; }; + CE895B5D0CFAE78300B5ADEA /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + CE895B5E0CFAE78300B5ADEA /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + CE895C130CFAF0C900B5ADEA /* DirectoryPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectoryPanel.h; sourceTree = ""; }; + CE895C140CFAF0C900B5ADEA /* DirectoryPanel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DirectoryPanel.m; sourceTree = ""; }; + D2F7E79907B2D74100F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8DC2EF560486A6940098B216 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 034768DFFF38A50411DB9C8B /* Products */ = { + isa = PBXGroup; + children = ( + 8DC2EF5B0486A6940098B216 /* dgbase.framework */, + ); + name = Products; + sourceTree = ""; + }; + 0867D691FE84028FC02AAC07 /* dgbase */ = { + isa = PBXGroup; + children = ( + 08FB77AEFE84172EC02AAC07 /* Classes */, + CE80DA160FC1910F0086DCA6 /* cocoalib */, + 32C88DFF0371C24200C91783 /* Other Sources */, + 089C1665FE841158C02AAC07 /* Resources */, + 0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */, + 034768DFFF38A50411DB9C8B /* Products */, + ); + name = dgbase; + sourceTree = ""; + }; + 0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */ = { + isa = PBXGroup; + children = ( + 1058C7B0FEA5585E11CA2CBB /* Linked Frameworks */, + 1058C7B2FEA5585E11CA2CBB /* Other Frameworks */, + ); + name = "External Frameworks and Libraries"; + sourceTree = ""; + }; + 089C1665FE841158C02AAC07 /* Resources */ = { + isa = PBXGroup; + children = ( + CE80DB690FC194560086DCA6 /* progress.nib */, + CE80DB6B0FC194560086DCA6 /* registration.nib */, + 8DC2EF5A0486A6940098B216 /* Info.plist */, + 089C1666FE841158C02AAC07 /* InfoPlist.strings */, + ); + name = Resources; + sourceTree = ""; + }; + 08FB77AEFE84172EC02AAC07 /* Classes */ = { + isa = PBXGroup; + children = ( + CE62CA710CFAF80D0001B6E0 /* ResultWindow.h */, + CE62CA720CFAF80D0001B6E0 /* ResultWindow.m */, + CE895C130CFAF0C900B5ADEA /* DirectoryPanel.h */, + CE895C140CFAF0C900B5ADEA /* DirectoryPanel.m */, + CE895B5D0CFAE78300B5ADEA /* AppDelegate.h */, + CE895B5E0CFAE78300B5ADEA /* AppDelegate.m */, + ); + name = Classes; + sourceTree = ""; + }; + 1058C7B0FEA5585E11CA2CBB /* Linked Frameworks */ = { + isa = PBXGroup; + children = ( + 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */, + ); + name = "Linked Frameworks"; + sourceTree = ""; + }; + 1058C7B2FEA5585E11CA2CBB /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 0867D6A5FE840307C02AAC07 /* AppKit.framework */, + D2F7E79907B2D74100F64583 /* CoreData.framework */, + 0867D69BFE84028FC02AAC07 /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; + 32C88DFF0371C24200C91783 /* Other Sources */ = { + isa = PBXGroup; + children = ( + CE70A0FB0CF8C2560048C314 /* PyDupeGuru.h */, + CE7D77030CF8987800BA287E /* Consts.h */, + ); + name = "Other Sources"; + sourceTree = ""; + }; + CE80DA160FC1910F0086DCA6 /* cocoalib */ = { + isa = PBXGroup; + children = ( + CE80DA370FC191C40086DCA6 /* Outline.h */, + CE80DA380FC191C40086DCA6 /* Outline.m */, + CE80DA390FC191C40086DCA6 /* Table.h */, + CE80DA3A0FC191C40086DCA6 /* Table.m */, + CE80DA250FC191980086DCA6 /* Dialogs.h */, + CE80DA260FC191980086DCA6 /* Dialogs.m */, + CE80DA270FC191980086DCA6 /* ProgressController.h */, + CE80DA280FC191980086DCA6 /* ProgressController.m */, + CE80DA290FC191980086DCA6 /* PyApp.h */, + CE80DA2A0FC191980086DCA6 /* RegistrationInterface.h */, + CE80DA2B0FC191980086DCA6 /* RegistrationInterface.m */, + CE80DA2C0FC191980086DCA6 /* Utils.h */, + CE80DA2D0FC191980086DCA6 /* Utils.m */, + CE80DA170FC191320086DCA6 /* RecentDirectories.h */, + CE80DA180FC191320086DCA6 /* RecentDirectories.m */, + ); + name = cocoalib; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 8DC2EF500486A6940098B216 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + CE7D77050CF8987800BA287E /* Consts.h in Headers */, + CE70A0FC0CF8C2560048C314 /* PyDupeGuru.h in Headers */, + CE895B5F0CFAE78300B5ADEA /* AppDelegate.h in Headers */, + CE895C150CFAF0C900B5ADEA /* DirectoryPanel.h in Headers */, + CE62CA730CFAF80D0001B6E0 /* ResultWindow.h in Headers */, + CE80DA190FC191320086DCA6 /* RecentDirectories.h in Headers */, + CE80DA2E0FC191980086DCA6 /* Dialogs.h in Headers */, + CE80DA300FC191980086DCA6 /* ProgressController.h in Headers */, + CE80DA320FC191980086DCA6 /* PyApp.h in Headers */, + CE80DA330FC191980086DCA6 /* RegistrationInterface.h in Headers */, + CE80DA350FC191980086DCA6 /* Utils.h in Headers */, + CE80DA3B0FC191C40086DCA6 /* Outline.h in Headers */, + CE80DA3D0FC191C40086DCA6 /* Table.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 8DC2EF4F0486A6940098B216 /* dgbase */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB91AD08733DA50010E9CD /* Build configuration list for PBXNativeTarget "dgbase" */; + buildPhases = ( + 8DC2EF500486A6940098B216 /* Headers */, + 8DC2EF520486A6940098B216 /* Resources */, + 8DC2EF540486A6940098B216 /* Sources */, + 8DC2EF560486A6940098B216 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = dgbase; + productInstallPath = "$(HOME)/Library/Frameworks"; + productName = dgbase; + productReference = 8DC2EF5B0486A6940098B216 /* dgbase.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 0867D690FE84028FC02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "dgbase" */; + compatibilityVersion = "Xcode 3.0"; + hasScannedForEncodings = 1; + mainGroup = 0867D691FE84028FC02AAC07 /* dgbase */; + productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8DC2EF4F0486A6940098B216 /* dgbase */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8DC2EF520486A6940098B216 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */, + CE80DB6D0FC194560086DCA6 /* progress.nib in Resources */, + CE80DB6E0FC194560086DCA6 /* registration.nib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8DC2EF540486A6940098B216 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CE895B600CFAE78300B5ADEA /* AppDelegate.m in Sources */, + CE895C160CFAF0C900B5ADEA /* DirectoryPanel.m in Sources */, + CE62CA740CFAF80D0001B6E0 /* ResultWindow.m in Sources */, + CE80DA1A0FC191320086DCA6 /* RecentDirectories.m in Sources */, + CE80DA2F0FC191980086DCA6 /* Dialogs.m in Sources */, + CE80DA310FC191980086DCA6 /* ProgressController.m in Sources */, + CE80DA340FC191980086DCA6 /* RegistrationInterface.m in Sources */, + CE80DA360FC191980086DCA6 /* Utils.m in Sources */, + CE80DA3C0FC191C40086DCA6 /* Outline.m in Sources */, + CE80DA3E0FC191C40086DCA6 /* Table.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 089C1666FE841158C02AAC07 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 089C1667FE841158C02AAC07 /* English */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + CE80DB690FC194560086DCA6 /* progress.nib */ = { + isa = PBXVariantGroup; + children = ( + CE80DB6A0FC194560086DCA6 /* English */, + ); + name = progress.nib; + sourceTree = SOURCE_ROOT; + }; + CE80DB6B0FC194560086DCA6 /* registration.nib */ = { + isa = PBXVariantGroup; + children = ( + CE80DB6C0FC194560086DCA6 /* English */, + ); + name = registration.nib; + sourceTree = SOURCE_ROOT; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 1DEB91AE08733DA50010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/../../../cocoalib/build/Release\"", + ); + FRAMEWORK_VERSION = A; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Library/Frameworks"; + PRODUCT_NAME = dgbase; + WRAPPER_EXTENSION = framework; + ZERO_LINK = YES; + }; + name = Debug; + }; + 1DEB91AF08733DA50010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/../../../cocoalib/build/Release\"", + ); + FRAMEWORK_VERSION = A; + GCC_MODEL_TUNING = G5; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + GCC_PREFIX_HEADER = ""; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "@executable_path/../Frameworks"; + PRODUCT_NAME = dgbase; + WRAPPER_EXTENSION = framework; + }; + name = Release; + }; + 1DEB91B208733DA50010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_C_LANGUAGE_STANDARD = c99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; + }; + name = Debug; + }; + 1DEB91B308733DA50010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + ppc, + i386, + ); + GCC_C_LANGUAGE_STANDARD = c99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB91AD08733DA50010E9CD /* Build configuration list for PBXNativeTarget "dgbase" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB91AE08733DA50010E9CD /* Debug */, + 1DEB91AF08733DA50010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "dgbase" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB91B208733DA50010E9CD /* Debug */, + 1DEB91B308733DA50010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 0867D690FE84028FC02AAC07 /* Project object */; +} diff --git a/base/qt/__init__.py b/base/qt/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/base/qt/about_box.py b/base/qt/about_box.py new file mode 100644 index 00000000..55a36eb1 --- /dev/null +++ b/base/qt/about_box.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# Unit Name: about_box +# Created By: Virgil Dupras +# Created On: 2009-05-09 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import Qt, QCoreApplication, SIGNAL +from PyQt4.QtGui import QDialog, QDialogButtonBox, QPixmap + +from about_box_ui import Ui_AboutBox + +class AboutBox(QDialog, Ui_AboutBox): + def __init__(self, parent, app): + flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.MSWindowsFixedSizeDialogHint + QDialog.__init__(self, parent, flags) + self.app = app + self._setupUi() + + self.connect(self.buttonBox, SIGNAL('clicked(QAbstractButton*)'), self.buttonClicked) + + def _setupUi(self): + self.setupUi(self) + # Stuff that can't be done in the Designer + self.setWindowTitle(u"About %s" % QCoreApplication.instance().applicationName()) + self.nameLabel.setText(QCoreApplication.instance().applicationName()) + self.versionLabel.setText('Version ' + QCoreApplication.instance().applicationVersion()) + self.logoLabel.setPixmap(QPixmap(':/%s_big' % self.app.LOGO_NAME)) + self.registerButton = self.buttonBox.addButton("Register", QDialogButtonBox.ActionRole) + + #--- Events + def buttonClicked(self, button): + if button is self.registerButton: + self.app.ask_for_reg_code() + diff --git a/base/qt/about_box.ui b/base/qt/about_box.ui new file mode 100644 index 00000000..aa9c5ce5 --- /dev/null +++ b/base/qt/about_box.ui @@ -0,0 +1,133 @@ + + + AboutBox + + + + 0 + 0 + 400 + 190 + + + + + 0 + 0 + + + + About dupeGuru + + + + + + + + + :/logo_me_big + + + + + + + + + + 75 + true + + + + dupeGuru + + + + + + + Version + + + + + + + Copyright Hardcoded Software 2009 + + + + + + + + 75 + true + + + + Registered To: + + + + + + + UNREGISTERED + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + + + + + buttonBox + accepted() + AboutBox + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AboutBox + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/base/qt/app.py b/base/qt/app.py new file mode 100644 index 00000000..3fa340bf --- /dev/null +++ b/base/qt/app.py @@ -0,0 +1,269 @@ +#!/usr/bin/env python +# Unit Name: app +# Created By: Virgil Dupras +# Created On: 2009-04-25 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import logging +import os.path as op +import traceback + +from PyQt4.QtCore import Qt, QTimer, QObject, QCoreApplication, QUrl, SIGNAL +from PyQt4.QtGui import QProgressDialog, QDesktopServices, QFileDialog, QDialog, QMessageBox + +from hsutil import job +from hsutil.reg import RegistrationRequired + +from dupeguru import data_pe +from dupeguru.app import (DupeGuru as DupeGuruBase, JOB_SCAN, JOB_LOAD, JOB_MOVE, JOB_COPY, + JOB_DELETE) + +from main_window import MainWindow +from directories_dialog import DirectoriesDialog +from about_box import AboutBox +from reg import Registration +from error_report_dialog import ErrorReportDialog + +JOBID2TITLE = { + JOB_SCAN: "Scanning for duplicates", + JOB_LOAD: "Loading", + JOB_MOVE: "Moving", + JOB_COPY: "Copying", + JOB_DELETE: "Sending files to the recycle bin", +} + +class Progress(QProgressDialog, job.ThreadedJobPerformer): + def __init__(self, parent): + flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint + QProgressDialog.__init__(self, '', u"Cancel", 0, 100, parent, flags) + self.setModal(True) + self.setAutoReset(False) + self.setAutoClose(False) + self._timer = QTimer() + self._jobid = '' + self.connect(self._timer, SIGNAL('timeout()'), self.updateProgress) + + def updateProgress(self): + # the values might change before setValue happens + last_progress = self.last_progress + last_desc = self.last_desc + if not self._job_running or last_progress is None: + self._timer.stop() + self.close() + self.emit(SIGNAL('finished(QString)'), self._jobid) + if self._last_error is not None: + s = ''.join(traceback.format_exception(*self._last_error)) + dialog = ErrorReportDialog(self.parent(), s) + dialog.exec_() + return + if self.wasCanceled(): + self.job_cancelled = True + return + if last_desc: + self.setLabelText(last_desc) + self.setValue(last_progress) + + def run(self, jobid, title, target, args=()): + self._jobid = jobid + self.reset() + self.setLabelText('') + self.run_threaded(target, args) + self.setWindowTitle(title) + self.show() + self._timer.start(500) + + +def demo_method(method): + def wrapper(self, *args, **kwargs): + try: + return method(self, *args, **kwargs) + except RegistrationRequired: + msg = "The demo version of dupeGuru only allows 10 actions (delete/move/copy) per session." + QMessageBox.information(self.main_window, 'Demo', msg) + + return wrapper + +class DupeGuru(DupeGuruBase, QObject): + LOGO_NAME = '' + NAME = '' + DELTA_COLUMNS = frozenset() + + def __init__(self, data_module, appid): + appdata = unicode(QDesktopServices.storageLocation(QDesktopServices.DataLocation)) + DupeGuruBase.__init__(self, data_module, appdata, appid) + QObject.__init__(self) + self._setup() + + #--- Private + def _setup(self): + self.selected_dupe = None + self.prefs = self._create_preferences() + self.prefs.load() + self._update_options() + self.main_window = self._create_main_window() + self._progress = Progress(self.main_window) + self.directories_dialog = DirectoriesDialog(self.main_window, self) + self.details_dialog = self._create_details_dialog(self.main_window) + self.preferences_dialog = self._create_preferences_dialog(self.main_window) + self.about_box = AboutBox(self.main_window, self) + + self.reg = Registration(self) + self.set_registration(self.prefs.registration_code, self.prefs.registration_email) + if not self.registered: + self.reg.show_nag() + self.main_window.show() + self.load() + + self.connect(QCoreApplication.instance(), SIGNAL('aboutToQuit()'), self.application_will_terminate) + self.connect(self._progress, SIGNAL('finished(QString)'), self.job_finished) + + def _setup_as_registered(self): + self.prefs.registration_code = self.registration_code + self.prefs.registration_email = self.registration_email + self.main_window.actionRegister.setVisible(False) + self.about_box.registerButton.hide() + self.about_box.registeredEmailLabel.setText(self.prefs.registration_email) + + def _update_options(self): + self.scanner.mix_file_kind = self.prefs.mix_file_kind + self.options['escape_filter_regexp'] = self.prefs.use_regexp + self.options['clean_empty_dirs'] = self.prefs.remove_empty_folders + + #--- Virtual + def _create_details_dialog(self, parent): + raise NotImplementedError() + + def _create_main_window(self): + return MainWindow(app=self) + + def _create_preferences(self): + raise NotImplementedError() + + def _create_preferences_dialog(self, parent): + raise NotImplementedError() + + #--- Override + def _start_job(self, jobid, func): + title = JOBID2TITLE[jobid] + try: + j = self._progress.create_job() + self._progress.run(jobid, title, func, args=(j, )) + except job.JobInProgressError: + msg = "A previous action is still hanging in there. You can't start a new one yet. Wait a few seconds, then try again." + QMessageBox.information(self.main_window, 'Action in progress', msg) + + #--- Public + def add_dupes_to_ignore_list(self, duplicates): + for dupe in duplicates: + self.AddToIgnoreList(dupe) + self.remove_duplicates(duplicates) + + def ApplyFilter(self, filter): + DupeGuruBase.ApplyFilter(self, filter) + self.emit(SIGNAL('resultsChanged()')) + + def ask_for_reg_code(self): + if self.reg.ask_for_code(): + self._setup_ui_as_registered() + + @demo_method + def copy_or_move_marked(self, copy): + opname = 'copy' if copy else 'move' + title = "Select a directory to {0} marked files to".format(opname) + flags = QFileDialog.ShowDirsOnly + destination = unicode(QFileDialog.getExistingDirectory(self.main_window, title, '', flags)) + if not destination: + return + recreate_path = self.prefs.destination_type + DupeGuruBase.copy_or_move_marked(self, copy, destination, recreate_path) + + delete_marked = demo_method(DupeGuruBase.delete_marked) + + def make_reference(self, duplicates): + DupeGuruBase.make_reference(self, duplicates) + self.emit(SIGNAL('resultsChanged()')) + + def mark_all(self): + self.results.mark_all() + self.emit(SIGNAL('dupeMarkingChanged()')) + + def mark_invert(self): + self.results.mark_invert() + self.emit(SIGNAL('dupeMarkingChanged()')) + + def mark_none(self): + self.results.mark_none() + self.emit(SIGNAL('dupeMarkingChanged()')) + + def open_selected(self): + if self.selected_dupe is None: + return + url = QUrl.fromLocalFile(unicode(self.selected_dupe.path)) + QDesktopServices.openUrl(url) + + def remove_duplicates(self, duplicates): + self.results.remove_duplicates(duplicates) + self.emit(SIGNAL('resultsChanged()')) + + def remove_marked_duplicates(self): + marked = [d for d in self.results.dupes if self.results.is_marked(d)] + self.remove_duplicates(marked) + + def rename_dupe(self, dupe, newname): + try: + dupe.move(dupe.parent, newname) + return True + except (IndexError, fs.FSError) as e: + logging.warning("dupeGuru Warning: %s" % unicode(e)) + return False + + def reveal_selected(self): + if self.selected_dupe is None: + return + url = QUrl.fromLocalFile(unicode(self.selected_dupe.path[:-1])) + QDesktopServices.openUrl(url) + + def select_duplicate(self, dupe): + self.selected_dupe = dupe + self.emit(SIGNAL('duplicateSelected()')) + + def show_about_box(self): + self.about_box.show() + + def show_details(self): + self.details_dialog.show() + + def show_directories(self): + self.directories_dialog.show() + + def show_help(self): + url = QUrl.fromLocalFile(op.abspath('help/intro.htm')) + QDesktopServices.openUrl(url) + + def show_preferences(self): + self.preferences_dialog.load() + result = self.preferences_dialog.exec_() + if result == QDialog.Accepted: + self.preferences_dialog.save() + self.prefs.save() + self._update_options() + + def toggle_marking_for_dupes(self, dupes): + for dupe in dupes: + self.results.mark_toggle(dupe) + self.emit(SIGNAL('dupeMarkingChanged()')) + + #--- Events + def application_will_terminate(self): + self.Save() + self.SaveIgnoreList() + + def job_finished(self, jobid): + self.emit(SIGNAL('resultsChanged()')) + if jobid == JOB_LOAD: + self.emit(SIGNAL('directoriesChanged()')) + if jobid in (JOB_MOVE, JOB_COPY, JOB_DELETE) and self.last_op_error_count > 0: + msg = "{0} files could not be processed.".format(self.results.mark_count) + QMessageBox.warning(self.main_window, 'Warning', msg) + diff --git a/base/qt/details_table.py b/base/qt/details_table.py new file mode 100644 index 00000000..1c45de1e --- /dev/null +++ b/base/qt/details_table.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +# Unit Name: details_table +# Created By: Virgil Dupras +# Created On: 2009-05-17 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import Qt, SIGNAL, QAbstractTableModel, QVariant +from PyQt4.QtGui import QHeaderView, QTableView + +HEADER = ['Attribute', 'Selected', 'Reference'] + +class DetailsModel(QAbstractTableModel): + def __init__(self, app): + QAbstractTableModel.__init__(self) + self._app = app + self._data = app.data + self._dupe_data = None + self._ref_data = None + self.connect(app, SIGNAL('duplicateSelected()'), self.duplicateSelected) + + def columnCount(self, parent): + return len(HEADER) + + def data(self, index, role): + if not index.isValid(): + return QVariant() + if role != Qt.DisplayRole: + return QVariant() + column = index.column() + row = index.row() + if column == 0: + return QVariant(self._data.COLUMNS[row]['display']) + elif column == 1 and self._dupe_data: + return QVariant(self._dupe_data[row]) + elif column == 2 and self._ref_data: + return QVariant(self._ref_data[row]) + return QVariant() + + def headerData(self, section, orientation, role): + if orientation == Qt.Horizontal and role == Qt.DisplayRole and section < len(HEADER): + return QVariant(HEADER[section]) + return QVariant() + + def rowCount(self, parent): + return len(self._data.COLUMNS) + + #--- Events + def duplicateSelected(self): + dupe = self._app.selected_dupe + group = self._app.results.get_group_of_duplicate(dupe) + ref = group.ref + self._dupe_data = self._data.GetDisplayInfo(dupe, group) + self._ref_data = self._data.GetDisplayInfo(ref, group) + self.reset() + + +class DetailsTable(QTableView): + def __init__(self, *args): + QTableView.__init__(self, *args) + self.setAlternatingRowColors(True) + self.setSelectionBehavior(QTableView.SelectRows) + self.setShowGrid(False) + + def setModel(self, model): + QTableView.setModel(self, model) + # The model needs to be set to set header stuff + hheader = self.horizontalHeader() + hheader.setHighlightSections(False) + hheader.setStretchLastSection(False) + hheader.resizeSection(0, 100) + hheader.setResizeMode(0, QHeaderView.Fixed) + hheader.setResizeMode(1, QHeaderView.Stretch) + hheader.setResizeMode(2, QHeaderView.Stretch) + vheader = self.verticalHeader() + vheader.setVisible(False) + vheader.setDefaultSectionSize(18) + diff --git a/base/qt/dg.qrc b/base/qt/dg.qrc new file mode 100644 index 00000000..f2f5e936 --- /dev/null +++ b/base/qt/dg.qrc @@ -0,0 +1,17 @@ + + + images/details32.png + images/dgpe_logo_32.png + images/dgpe_logo_128.png + images/dgme_logo_32.png + images/dgme_logo_128.png + images/dgse_logo_32.png + images/dgse_logo_128.png + images/folderwin32.png + images/gear.png + images/preferences32.png + images/actions32.png + images/delta32.png + images/power_marker32.png + + \ No newline at end of file diff --git a/base/qt/directories_dialog.py b/base/qt/directories_dialog.py new file mode 100644 index 00000000..e2f3ddb3 --- /dev/null +++ b/base/qt/directories_dialog.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python +# Unit Name: directories_dialog +# Created By: Virgil Dupras +# Created On: 2009-04-25 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import SIGNAL, Qt +from PyQt4.QtGui import QDialog, QFileDialog, QHeaderView + +from directories_dialog_ui import Ui_DirectoriesDialog +from directories_model import DirectoriesModel, DirectoriesDelegate + +class DirectoriesDialog(QDialog, Ui_DirectoriesDialog): + def __init__(self, parent, app): + flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint + QDialog.__init__(self, parent, flags) + self.app = app + self._setupUi() + self._updateRemoveButton() + + self.connect(self.doneButton, SIGNAL('clicked()'), self.doneButtonClicked) + self.connect(self.addButton, SIGNAL('clicked()'), self.addButtonClicked) + self.connect(self.removeButton, SIGNAL('clicked()'), self.removeButtonClicked) + self.connect(self.treeView.selectionModel(), SIGNAL('selectionChanged(QItemSelection,QItemSelection)'), self.selectionChanged) + self.connect(self.app, SIGNAL('directoriesChanged()'), self.directoriesChanged) + + def _setupUi(self): + self.setupUi(self) + # Stuff that can't be done in the Designer + self.directoriesModel = DirectoriesModel(self.app) + self.directoriesDelegate = DirectoriesDelegate() + self.treeView.setItemDelegate(self.directoriesDelegate) + self.treeView.setModel(self.directoriesModel) + + header = self.treeView.header() + header.setStretchLastSection(False) + header.setResizeMode(0, QHeaderView.Stretch) + header.setResizeMode(1, QHeaderView.Fixed) + header.resizeSection(1, 100) + + def _updateRemoveButton(self): + indexes = self.treeView.selectedIndexes() + if not indexes: + self.removeButton.setEnabled(False) + return + self.removeButton.setEnabled(True) + index = indexes[0] + node = index.internalPointer() + # label = 'Remove' if node.parent is None else 'Exclude' + + def addButtonClicked(self): + title = u"Select a directory to add to the scanning list" + flags = QFileDialog.ShowDirsOnly + dirpath = unicode(QFileDialog.getExistingDirectory(self, title, '', flags)) + if not dirpath: + return + self.app.AddDirectory(dirpath) + self.directoriesModel.reset() + + def directoriesChanged(self): + self.directoriesModel.reset() + + def doneButtonClicked(self): + self.hide() + + def removeButtonClicked(self): + indexes = self.treeView.selectedIndexes() + if not indexes: + return + index = indexes[0] + node = index.internalPointer() + if node.parent is None: + row = index.row() + del self.app.directories[row] + self.directoriesModel.reset() + + def selectionChanged(self, selected, deselected): + self._updateRemoveButton() + diff --git a/base/qt/directories_dialog.ui b/base/qt/directories_dialog.ui new file mode 100644 index 00000000..68bc8d84 --- /dev/null +++ b/base/qt/directories_dialog.ui @@ -0,0 +1,133 @@ + + + DirectoriesDialog + + + + 0 + 0 + 420 + 338 + + + + Directories + + + + + + QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + + + true + + + false + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 91 + 0 + + + + + 16777215 + 32 + + + + Remove + + + + + + + + 91 + 0 + + + + + 16777215 + 32 + + + + Add + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 91 + 0 + + + + + 16777215 + 32 + + + + Done + + + true + + + + + + + + + + diff --git a/base/qt/directories_model.py b/base/qt/directories_model.py new file mode 100644 index 00000000..cae88f39 --- /dev/null +++ b/base/qt/directories_model.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python +# Unit Name: directories_model +# Created By: Virgil Dupras +# Created On: 2009-04-25 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import QVariant, QModelIndex, Qt, QRect, QEvent, QPoint +from PyQt4.QtGui import QComboBox, QStyledItemDelegate, QMouseEvent, QApplication, QBrush + +from tree_model import TreeNode, TreeModel + +HEADERS = ['Name', 'State'] +STATES = ['Normal', 'Reference', 'Excluded'] + +class DirectoriesDelegate(QStyledItemDelegate): + def createEditor(self, parent, option, index): + editor = QComboBox(parent); + editor.addItems(STATES) + return editor + + def setEditorData(self, editor, index): + value, ok = index.model().data(index, Qt.EditRole).toInt() + assert ok + editor.setCurrentIndex(value); + press = QMouseEvent(QEvent.MouseButtonPress, QPoint(0, 0), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) + release = QMouseEvent(QEvent.MouseButtonRelease, QPoint(0, 0), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) + QApplication.sendEvent(editor, press) + QApplication.sendEvent(editor, release) + # editor.showPopup() # this causes a weird glitch. the ugly workaround is above. + + def setModelData(self, editor, model, index): + value = QVariant(editor.currentIndex()) + model.setData(index, value, Qt.EditRole) + + def updateEditorGeometry(self, editor, option, index): + editor.setGeometry(option.rect) + + +class DirectoryNode(TreeNode): + def __init__(self, parent, ref, row): + TreeNode.__init__(self, parent, row) + self.ref = ref + + def _get_children(self): + children = [] + for index, directory in enumerate(self.ref.dirs): + node = DirectoryNode(self, directory, index) + children.append(node) + return children + + +class DirectoriesModel(TreeModel): + def __init__(self, app): + self._dirs = app.directories + TreeModel.__init__(self) + + def _root_nodes(self): + nodes = [] + for index, directory in enumerate(self._dirs): + nodes.append(DirectoryNode(None, directory, index)) + return nodes + + def columnCount(self, parent): + return 2 + + def data(self, index, role): + if not index.isValid(): + return QVariant() + node = index.internalPointer() + if role == Qt.DisplayRole: + if index.column() == 0: + return QVariant(node.ref.name) + else: + return QVariant(STATES[self._dirs.GetState(node.ref.path)]) + elif role == Qt.EditRole and index.column() == 1: + return QVariant(self._dirs.GetState(node.ref.path)) + elif role == Qt.ForegroundRole: + state = self._dirs.GetState(node.ref.path) + if state == 1: + return QVariant(QBrush(Qt.blue)) + elif state == 2: + return QVariant(QBrush(Qt.red)) + return QVariant() + + def flags(self, index): + if not index.isValid(): + return 0 + result = Qt.ItemIsEnabled | Qt.ItemIsSelectable + if index.column() == 1: + result |= Qt.ItemIsEditable + return result + + def headerData(self, section, orientation, role): + if orientation == Qt.Horizontal: + if role == Qt.DisplayRole and section < len(HEADERS): + return QVariant(HEADERS[section]) + return QVariant() + + def setData(self, index, value, role): + if not index.isValid() or role != Qt.EditRole or index.column() != 1: + return False + node = index.internalPointer() + state, ok = value.toInt() + assert ok + self._dirs.SetState(node.ref.path, state) + return True + diff --git a/base/qt/error_report_dialog.py b/base/qt/error_report_dialog.py new file mode 100644 index 00000000..4aa8f977 --- /dev/null +++ b/base/qt/error_report_dialog.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +# Unit Name: error_report_dialog +# Created By: Virgil Dupras +# Created On: 2009-05-23 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import Qt, QUrl +from PyQt4.QtGui import QDialog, QDesktopServices + +from error_report_dialog_ui import Ui_ErrorReportDialog + +class ErrorReportDialog(QDialog, Ui_ErrorReportDialog): + def __init__(self, parent, error): + flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint + QDialog.__init__(self, parent, flags) + self.setupUi(self) + self.errorTextEdit.setPlainText(error) + + def accept(self): + text = self.errorTextEdit.toPlainText() + url = QUrl("mailto:support@hardcoded.net?SUBJECT=Error Report&BODY=%s" % text) + QDesktopServices.openUrl(url) + QDialog.accept(self) + diff --git a/base/qt/error_report_dialog.ui b/base/qt/error_report_dialog.ui new file mode 100644 index 00000000..0974dd2f --- /dev/null +++ b/base/qt/error_report_dialog.ui @@ -0,0 +1,117 @@ + + + ErrorReportDialog + + + + 0 + 0 + 553 + 349 + + + + Error Report + + + + + + Something went wrong. Would you like to send the error report to Hardcoded Software? + + + true + + + + + + + true + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 110 + 0 + + + + Don't Send + + + + + + + + 110 + 0 + + + + Send + + + true + + + + + + + + + + + sendButton + clicked() + ErrorReportDialog + accept() + + + 485 + 320 + + + 276 + 174 + + + + + dontSendButton + clicked() + ErrorReportDialog + reject() + + + 373 + 320 + + + 276 + 174 + + + + + diff --git a/base/qt/gen.py b/base/qt/gen.py new file mode 100644 index 00000000..3b0df2fa --- /dev/null +++ b/base/qt/gen.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# Unit Name: gen +# Created By: Virgil Dupras +# Created On: 2009-05-22 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import os + +def print_and_do(cmd): + print cmd + os.system(cmd) + +print_and_do("pyuic4 main_window.ui > main_window_ui.py") +print_and_do("pyuic4 directories_dialog.ui > directories_dialog_ui.py") +print_and_do("pyuic4 about_box.ui > about_box_ui.py") +print_and_do("pyuic4 reg_submit_dialog.ui > reg_submit_dialog_ui.py") +print_and_do("pyuic4 reg_demo_dialog.ui > reg_demo_dialog_ui.py") +print_and_do("pyuic4 error_report_dialog.ui > error_report_dialog_ui.py") +print_and_do("pyrcc4 dg.qrc > dg_rc.py") \ No newline at end of file diff --git a/base/qt/main_window.py b/base/qt/main_window.py new file mode 100644 index 00000000..3ca20de3 --- /dev/null +++ b/base/qt/main_window.py @@ -0,0 +1,304 @@ +#!/usr/bin/env python +# Unit Name: main_window +# Created By: Virgil Dupras +# Created On: 2009-04-25 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import Qt, QCoreApplication, QProcess, SIGNAL +from PyQt4.QtGui import (QMainWindow, QMenu, QPixmap, QIcon, QToolButton, QLabel, QHeaderView, + QMessageBox, QInputDialog, QLineEdit) + +from hsutil.misc import nonone + +from dupeguru.app import NoScannableFileError, AllFilesAreRefError + +import dg_rc +from main_window_ui import Ui_MainWindow +from results_model import ResultsDelegate, ResultsModel + +class MainWindow(QMainWindow, Ui_MainWindow): + def __init__(self, app): + QMainWindow.__init__(self, None) + self.app = app + self._last_filter = None + self._setupUi() + self.resultsDelegate = ResultsDelegate() + self.resultsModel = ResultsModel(self.app) + self.resultsView.setModel(self.resultsModel) + self.resultsView.setItemDelegate(self.resultsDelegate) + self._load_columns() + self._update_column_actions_status() + self.resultsView.expandAll() + self._update_status_line() + + self.connect(self.app, SIGNAL('resultsChanged()'), self.resultsChanged) + self.connect(self.app, SIGNAL('dupeMarkingChanged()'), self.dupeMarkingChanged) + self.connect(self.actionQuit, SIGNAL('triggered()'), QCoreApplication.instance().quit) + self.connect(self.resultsView.selectionModel(), SIGNAL('selectionChanged(QItemSelection,QItemSelection)'), self.selectionChanged) + self.connect(self.menuColumns, SIGNAL('triggered(QAction*)'), self.columnToggled) + self.connect(QCoreApplication.instance(), SIGNAL('aboutToQuit()'), self.application_will_terminate) + self.connect(self.resultsModel, SIGNAL('modelReset()'), self.resultsReset) + + def _setupUi(self): + self.setupUi(self) + # Stuff that can't be setup in the Designer + h = self.resultsView.header() + h.setHighlightSections(False) + h.setMovable(True) + h.setStretchLastSection(False) + h.setDefaultAlignment(Qt.AlignLeft) + + self.setWindowTitle(QCoreApplication.instance().applicationName()) + self.actionScan.setIcon(QIcon(QPixmap(':/%s' % self.app.LOGO_NAME))) + + # Columns menu + menu = self.menuColumns + self._column_actions = [] + for index, column in enumerate(self.app.data.COLUMNS): + action = menu.addAction(column['display']) + action.setCheckable(True) + action.column_index = index + self._column_actions.append(action) + menu.addSeparator() + action = menu.addAction("Reset to Defaults") + action.column_index = -1 + + # Action menu + actionMenu = QMenu('Actions', self.toolBar) + actionMenu.setIcon(QIcon(QPixmap(":/actions"))) + actionMenu.addAction(self.actionDeleteMarked) + actionMenu.addAction(self.actionMoveMarked) + actionMenu.addAction(self.actionCopyMarked) + actionMenu.addAction(self.actionRemoveMarked) + actionMenu.addSeparator() + actionMenu.addAction(self.actionRemoveSelected) + actionMenu.addAction(self.actionIgnoreSelected) + actionMenu.addAction(self.actionMakeSelectedReference) + actionMenu.addSeparator() + actionMenu.addAction(self.actionOpenSelected) + actionMenu.addAction(self.actionRevealSelected) + actionMenu.addAction(self.actionRenameSelected) + self.actionActions.setMenu(actionMenu) + button = QToolButton(self.toolBar) + button.setDefaultAction(actionMenu.menuAction()) + button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) + self.actionsButton = button + self.toolBar.insertWidget(self.actionActions, button) # the action is a placeholder + self.toolBar.removeAction(self.actionActions) + + self.statusLabel = QLabel(self) + self.statusbar.addPermanentWidget(self.statusLabel, 1) + + #--- Private + def _confirm(self, title, msg, default_button=QMessageBox.Yes): + buttons = QMessageBox.Yes | QMessageBox.No + answer = QMessageBox.question(self, title, msg, buttons, default_button) + return answer == QMessageBox.Yes + + def _load_columns(self): + h = self.resultsView.header() + h.setResizeMode(QHeaderView.Interactive) + prefs = self.app.prefs + attrs = zip(prefs.columns_width, prefs.columns_visible) + for index, (width, visible) in enumerate(attrs): + h.resizeSection(index, width) + h.setSectionHidden(index, not visible) + h.setResizeMode(0, QHeaderView.Stretch) + + def _redraw_results(self): + # HACK. this is the only way I found to update the widget without reseting everything + self.resultsView.scroll(0, 1) + self.resultsView.scroll(0, -1) + + def _save_columns(self): + h = self.resultsView.header() + widths = [] + visible = [] + for i in range(len(self.app.data.COLUMNS)): + widths.append(h.sectionSize(i)) + visible.append(not h.isSectionHidden(i)) + prefs = self.app.prefs + prefs.columns_width = widths + prefs.columns_visible = visible + prefs.save() + + def _update_column_actions_status(self): + h = self.resultsView.header() + for action in self._column_actions: + colid = action.column_index + action.setChecked(not h.isSectionHidden(colid)) + + def _update_status_line(self): + self.statusLabel.setText(self.app.stat_line) + + #--- Actions + def aboutTriggered(self): + self.app.show_about_box() + + def actionsTriggered(self): + self.actionsButton.showMenu() + + def addToIgnoreListTriggered(self): + dupes = self.resultsView.selectedDupes() + if not dupes: + return + title = "Add to Ignore List" + msg = "All selected {0} matches are going to be ignored in all subsequent scans. Continue?".format(len(dupes)) + if self._confirm(title, msg): + self.app.add_dupes_to_ignore_list(dupes) + + def applyFilterTriggered(self): + title = "Apply Filter" + msg = "Type the filter you want to apply on your results. See help for details." + text = nonone(self._last_filter, '[*]') + answer, ok = QInputDialog.getText(self, title, msg, QLineEdit.Normal, text) + if not ok: + return + answer = unicode(answer) + self.app.ApplyFilter(answer) + self._last_filter = answer + + def cancelFilterTriggered(self): + self.app.ApplyFilter('') + + def checkForUpdateTriggered(self): + QProcess.execute('updater.exe', ['/checknow']) + + def clearIgnoreListTriggered(self): + title = "Clear Ignore List" + count = len(self.app.scanner.ignore_list) + if not count: + QMessageBox.information(self, title, "Nothing to clear.") + return + msg = "Do you really want to remove all {0} items from the ignore list?".format(count) + if self._confirm(title, msg, QMessageBox.No): + self.app.scanner.ignore_list.Clear() + QMessageBox.information(self, title, "Ignore list cleared.") + + def copyTriggered(self): + self.app.copy_or_move_marked(True) + + def deleteTriggered(self): + count = self.app.results.mark_count + if not count: + return + title = "Delete duplicates" + msg = "You are about to send {0} files to the recycle bin. Continue?".format(count) + if self._confirm(title, msg): + self.app.delete_marked() + + def deltaTriggered(self): + self.resultsModel.delta = self.actionDelta.isChecked() + self._redraw_results() + + def detailsTriggered(self): + self.app.show_details() + + def directoriesTriggered(self): + self.app.show_directories() + + def makeReferenceTriggered(self): + self.app.make_reference(self.resultsView.selectedDupes()) + + def markAllTriggered(self): + self.app.mark_all() + + def markInvertTriggered(self): + self.app.mark_invert() + + def markNoneTriggered(self): + self.app.mark_none() + + def markSelectedTriggered(self): + dupes = self.resultsView.selectedDupes() + self.app.toggle_marking_for_dupes(dupes) + + def moveTriggered(self): + self.app.copy_or_move_marked(False) + + def openTriggered(self): + self.app.open_selected() + + def powerMarkerTriggered(self): + self.resultsModel.power_marker = self.actionPowerMarker.isChecked() + + def preferencesTriggered(self): + self.app.show_preferences() + + def registerTrigerred(self): + self.app.ask_for_reg_code() + + def removeMarkedTriggered(self): + count = self.app.results.mark_count + if not count: + return + title = "Remove duplicates" + msg = "You are about to remove {0} files from results. Continue?".format(count) + if self._confirm(title, msg): + self.app.remove_marked_duplicates() + + def removeSelectedTriggered(self): + dupes = self.resultsView.selectedDupes() + if not dupes: + return + title = "Remove duplicates" + msg = "You are about to remove {0} files from results. Continue?".format(len(dupes)) + if self._confirm(title, msg): + self.app.remove_duplicates(dupes) + + def renameTriggered(self): + self.resultsView.edit(self.resultsView.selectionModel().currentIndex()) + + def revealTriggered(self): + self.app.reveal_selected() + + def scanTriggered(self): + title = "Start a new scan" + if len(self.app.results.groups) > 0: + msg = "Are you sure you want to start a new duplicate scan?" + if not self._confirm(title, msg): + return + try: + self.app.start_scanning() + except NoScannableFileError: + msg = "The selected directories contain no scannable file." + QMessageBox.warning(self, title, msg) + self.app.show_directories() + except AllFilesAreRefError: + msg = "You cannot make a duplicate scan with only reference directories." + QMessageBox.warning(self, title, msg) + + def showHelpTriggered(self): + self.app.show_help() + + #--- Events + def application_will_terminate(self): + self._save_columns() + + def columnToggled(self, action): + colid = action.column_index + if colid == -1: + self.app.prefs.reset_columns() + self._load_columns() + else: + h = self.resultsView.header() + h.setSectionHidden(colid, not h.isSectionHidden(colid)) + self._update_column_actions_status() + + def dupeMarkingChanged(self): + self._redraw_results() + self._update_status_line() + + def resultsChanged(self): + self.resultsView.model().reset() + + def resultsReset(self): + self.resultsView.expandAll() + self._update_status_line() + + def selectionChanged(self, selected, deselected): + index = self.resultsView.selectionModel().currentIndex() + dupe = index.internalPointer().dupe if index.isValid() else None + self.app.select_duplicate(dupe) + diff --git a/base/qt/main_window.ui b/base/qt/main_window.ui new file mode 100644 index 00000000..754f265c --- /dev/null +++ b/base/qt/main_window.ui @@ -0,0 +1,911 @@ + + + MainWindow + + + + 0 + 0 + 630 + 514 + + + + dupeGuru + + + + + 0 + + + + + QAbstractItemView::ExtendedSelection + + + QAbstractItemView::SelectRows + + + false + + + true + + + false + + + true + + + false + + + false + + + + + + + + + 0 + 0 + 630 + 22 + + + + + Columns + + + + + Actions + + + + + + + + + + + + + + + + + + + + Mark + + + + + + + + + Modes + + + + + + + Windows + + + + + + + + Help + + + + + + + + + File + + + + + + + + + + + + + + + + + + toolBar + + + false + + + Qt::ToolButtonTextUnderIcon + + + false + + + TopToolBarArea + + + false + + + + + + + + + + + + true + + + + + + :/logo_pe:/logo_pe + + + Start Scan + + + Start scanning for duplicates + + + Ctrl+S + + + + + + :/folder:/folder + + + Directories + + + Ctrl+4 + + + + + + :/details:/details + + + Details + + + Ctrl+3 + + + + + + :/actions:/actions + + + Actions + + + + + + :/preferences:/preferences + + + Preferences + + + Ctrl+5 + + + + + true + + + + :/delta:/delta + + + Delta Values + + + Ctrl+2 + + + + + true + + + + :/power_marker:/power_marker + + + Power Marker + + + Ctrl+1 + + + + + Send Marked to Recycle Bin + + + Ctrl+D + + + + + Move Marked to... + + + Ctrl+M + + + + + Copy Marked to... + + + Ctrl+Shift+M + + + + + Remove Marked from Results + + + Ctrl+R + + + + + Remove Selected from Results + + + Ctrl+Del + + + + + Add Selected to Ignore List + + + Ctrl+Shift+Del + + + + + Make Selected Reference + + + Ctrl+Space + + + + + Open Selected with Default Application + + + Ctrl+O + + + + + Open Containing Folder of Selected + + + Ctrl+Shift+O + + + + + Rename Selected + + + F2 + + + + + Mark All + + + Ctrl+A + + + + + Mark None + + + Ctrl+Shift+A + + + + + Invert Marking + + + Ctrl+Alt+A + + + + + Mark Selected + + + + + Clear Ignore List + + + + + Quit + + + Ctrl+Q + + + + + Apply Filter + + + Ctrl+F + + + + + Cancel Filter + + + Ctrl+Shift+F + + + + + dupeGuru Help + + + F1 + + + + + About dupeGuru + + + + + Register dupeGuru + + + + + Check for Update + + + + + + ResultsView + QTreeView +
results_model
+
+
+ + + + + + actionDirectories + triggered() + MainWindow + directoriesTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionActions + triggered() + MainWindow + actionsTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionCopyMarked + triggered() + MainWindow + copyTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionDeleteMarked + triggered() + MainWindow + deleteTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionDelta + triggered() + MainWindow + deltaTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionDetails + triggered() + MainWindow + detailsTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionIgnoreSelected + triggered() + MainWindow + addToIgnoreListTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionMakeSelectedReference + triggered() + MainWindow + makeReferenceTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionMoveMarked + triggered() + MainWindow + moveTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionOpenSelected + triggered() + MainWindow + openTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionPowerMarker + triggered() + MainWindow + powerMarkerTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionPreferences + triggered() + MainWindow + preferencesTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionRemoveMarked + triggered() + MainWindow + removeMarkedTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionRemoveSelected + triggered() + MainWindow + removeSelectedTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionRevealSelected + triggered() + MainWindow + revealTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionRenameSelected + triggered() + MainWindow + renameTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionScan + triggered() + MainWindow + scanTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionClearIgnoreList + triggered() + MainWindow + clearIgnoreListTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionMarkAll + triggered() + MainWindow + markAllTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionMarkNone + triggered() + MainWindow + markNoneTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionMarkSelected + triggered() + MainWindow + markSelectedTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionInvertMarking + triggered() + MainWindow + markInvertTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionApplyFilter + triggered() + MainWindow + applyFilterTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionCancelFilter + triggered() + MainWindow + cancelFilterTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionShowHelp + triggered() + MainWindow + showHelpTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionAbout + triggered() + MainWindow + aboutTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionRegister + triggered() + MainWindow + registerTrigerred() + + + -1 + -1 + + + 314 + 256 + + + + + actionCheckForUpdate + triggered() + MainWindow + checkForUpdateTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + + directoriesTriggered() + scanTriggered() + actionsTriggered() + detailsTriggered() + preferencesTriggered() + deltaTriggered() + powerMarkerTriggered() + deleteTriggered() + moveTriggered() + copyTriggered() + removeMarkedTriggered() + removeSelectedTriggered() + addToIgnoreListTriggered() + makeReferenceTriggered() + openTriggered() + revealTriggered() + renameTriggered() + clearIgnoreListTriggered() + clearPictureCacheTriggered() + markAllTriggered() + markNoneTriggered() + markInvertTriggered() + markSelectedTriggered() + applyFilterTriggered() + cancelFilterTriggered() + showHelpTriggered() + aboutTriggered() + registerTrigerred() + checkForUpdateTriggered() + +
diff --git a/base/qt/preferences.py b/base/qt/preferences.py new file mode 100644 index 00000000..64ad64d5 --- /dev/null +++ b/base/qt/preferences.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python +# Unit Name: preferences +# Created By: Virgil Dupras +# Created On: 2009-05-03 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import QSettings, QVariant + +from hsutil.misc import tryint + +def variant_to_py(v): + value = None + ok = False + t = v.type() + if t == QVariant.String: + value = unicode(v.toString()) + ok = True # anyway + # might be bool or int, try them + if v == 'true': + value = True + elif value == 'false': + value = False + else: + value = tryint(value, value) + elif t == QVariant.Int: + value, ok = v.toInt() + elif t == QVariant.Bool: + value, ok = v.toBool(), True + elif t in (QVariant.List, QVariant.StringList): + value, ok = map(variant_to_py, v.toList()), True + if not ok: + raise TypeError() + return value + +class Preferences(object): + # (width, is_visible) + COLUMNS_DEFAULT_ATTRS = [] + + def __init__(self): + self.reset() + self.reset_columns() + + def _load_specific(self, settings, get): + # load prefs specific to the dg edition + pass + + def load(self): + self.reset() + settings = QSettings() + def get(name, default): + if settings.contains(name): + return variant_to_py(settings.value(name)) + else: + return default + + self.filter_hardness = get('FilterHardness', self.filter_hardness) + self.mix_file_kind = get('MixFileKind', self.mix_file_kind) + self.use_regexp = get('UseRegexp', self.use_regexp) + self.remove_empty_folders = get('RemoveEmptyFolders', self.remove_empty_folders) + self.destination_type = get('DestinationType', self.destination_type) + widths = get('ColumnsWidth', self.columns_width) + # only set nonzero values + for index, width in enumerate(widths[:len(self.columns_width)]): + if width > 0: + self.columns_width[index] = width + self.columns_visible = get('ColumnsVisible', self.columns_visible) + self.registration_code = get('RegistrationCode', self.registration_code) + self.registration_email = get('RegistrationEmail', self.registration_email) + self._load_specific(settings, get) + + def _reset_specific(self): + # reset prefs specific to the dg edition + pass + + def reset(self): + self.filter_hardness = 95 + self.mix_file_kind = True + self.use_regexp = False + self.remove_empty_folders = False + self.destination_type = 1 + self.registration_code = '' + self.registration_email = '' + self._reset_specific() + + def reset_columns(self): + self.columns_width = [width for width, _ in self.COLUMNS_DEFAULT_ATTRS] + self.columns_visible = [visible for _, visible in self.COLUMNS_DEFAULT_ATTRS] + + def _save_specific(self, settings, set_): + # save prefs specific to the dg edition + pass + + def save(self): + settings = QSettings() + def set_(name, value): + settings.setValue(name, QVariant(value)) + + set_('FilterHardness', self.filter_hardness) + set_('MixFileKind', self.mix_file_kind) + set_('UseRegexp', self.use_regexp) + set_('RemoveEmptyFolders', self.remove_empty_folders) + set_('DestinationType', self.destination_type) + set_('ColumnsWidth', self.columns_width) + set_('ColumnsVisible', self.columns_visible) + set_('RegistrationCode', self.registration_code) + set_('RegistrationEmail', self.registration_email) + self._save_specific(settings, set_) + diff --git a/base/qt/reg.py b/base/qt/reg.py new file mode 100644 index 00000000..59fd0bc3 --- /dev/null +++ b/base/qt/reg.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# Unit Name: reg +# Created By: Virgil Dupras +# Created On: 2009-05-09 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from hashlib import md5 + +from PyQt4.QtGui import QDialog + +from reg_submit_dialog import RegSubmitDialog +from reg_demo_dialog import RegDemoDialog + +class Registration(object): + def __init__(self, app): + self.app = app + + def ask_for_code(self): + dialog = RegSubmitDialog(self.app.main_window, self.app.is_code_valid) + result = dialog.exec_() + code = unicode(dialog.codeEdit.text()) + email = unicode(dialog.emailEdit.text()) + dialog.setParent(None) # free it + if result == QDialog.Accepted and self.app.is_code_valid(code, email): + self.app.set_registration(code, email) + return True + return False + + def show_nag(self): + dialog = RegDemoDialog(self.app.main_window, self) + dialog.exec_() + dialog.setParent(None) # free it + diff --git a/base/qt/reg_demo_dialog.py b/base/qt/reg_demo_dialog.py new file mode 100644 index 00000000..95280314 --- /dev/null +++ b/base/qt/reg_demo_dialog.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +# Unit Name: reg_demo_dialog +# Created By: Virgil Dupras +# Created On: 2009-05-10 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import SIGNAL, Qt, QUrl, QCoreApplication +from PyQt4.QtGui import QDialog, QMessageBox, QDesktopServices + +from reg_demo_dialog_ui import Ui_RegDemoDialog + +class RegDemoDialog(QDialog, Ui_RegDemoDialog): + def __init__(self, parent, reg): + flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint + QDialog.__init__(self, parent, flags) + self.reg = reg + self._setupUi() + + self.connect(self.enterCodeButton, SIGNAL('clicked()'), self.enterCodeClicked) + self.connect(self.purchaseButton, SIGNAL('clicked()'), self.purchaseClicked) + + def _setupUi(self): + self.setupUi(self) + # Stuff that can't be setup in the Designer + appname = QCoreApplication.instance().applicationName() + title = self.windowTitle() + title = title.replace('$appname', appname) + self.setWindowTitle(title) + title = self.titleLabel.text() + title = title.replace('$appname', appname) + self.titleLabel.setText(title) + desc = self.demoDescLabel.text() + desc = desc.replace('$appname', appname) + self.demoDescLabel.setText(desc) + + #--- Events + def enterCodeClicked(self): + if self.reg.ask_for_code(): + self.accept() + + def purchaseClicked(self): + url = QUrl('http://www.hardcoded.net/purchase.htm') + QDesktopServices.openUrl(url) + diff --git a/base/qt/reg_demo_dialog.ui b/base/qt/reg_demo_dialog.ui new file mode 100644 index 00000000..ef918225 --- /dev/null +++ b/base/qt/reg_demo_dialog.ui @@ -0,0 +1,140 @@ + + + RegDemoDialog + + + + 0 + 0 + 387 + 161 + + + + $appname Demo Version + + + + + + + 75 + true + + + + $appname Demo Version + + + + + + + You are currently running a demo version of $appname. This version has limited functionalities, and you need to buy it to have access to these functionalities. + + + true + + + + + + + In the demo version, only 10 duplicates per session can be sent to the recycle bin, moved or copied. + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 110 + 0 + + + + Try Demo + + + + + + + + 110 + 0 + + + + Enter Code + + + + + + + + 110 + 0 + + + + Purchase + + + + + + + + + + + tryButton + clicked() + RegDemoDialog + accept() + + + 112 + 161 + + + 201 + 94 + + + + + diff --git a/base/qt/reg_submit_dialog.py b/base/qt/reg_submit_dialog.py new file mode 100644 index 00000000..4ba680b6 --- /dev/null +++ b/base/qt/reg_submit_dialog.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# Unit Name: reg_submit_dialog +# Created By: Virgil Dupras +# Created On: 2009-05-09 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import SIGNAL, Qt, QUrl, QCoreApplication +from PyQt4.QtGui import QDialog, QMessageBox, QDesktopServices + +from reg_submit_dialog_ui import Ui_RegSubmitDialog + +class RegSubmitDialog(QDialog, Ui_RegSubmitDialog): + def __init__(self, parent, is_valid_func): + flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint + QDialog.__init__(self, parent, flags) + self._setupUi() + self.is_valid_func = is_valid_func + + self.connect(self.submitButton, SIGNAL('clicked()'), self.submitClicked) + self.connect(self.purchaseButton, SIGNAL('clicked()'), self.purchaseClicked) + + def _setupUi(self): + self.setupUi(self) + # Stuff that can't be setup in the Designer + appname = QCoreApplication.instance().applicationName() + prompt = self.promptLabel.text() + prompt = prompt.replace('$appname', appname) + self.promptLabel.setText(prompt) + + #--- Events + def purchaseClicked(self): + url = QUrl('http://www.hardcoded.net/purchase.htm') + QDesktopServices.openUrl(url) + + def submitClicked(self): + code = unicode(self.codeEdit.text()) + email = unicode(self.emailEdit.text()) + title = "Registration" + if self.is_valid_func(code, email): + msg = "This code is valid. Thanks!" + QMessageBox.information(self, title, msg) + self.accept() + else: + msg = "This code is invalid" + QMessageBox.warning(self, title, msg) + diff --git a/base/qt/reg_submit_dialog.ui b/base/qt/reg_submit_dialog.ui new file mode 100644 index 00000000..06de4191 --- /dev/null +++ b/base/qt/reg_submit_dialog.ui @@ -0,0 +1,149 @@ + + + RegSubmitDialog + + + + 0 + 0 + 365 + 134 + + + + Enter your registration code + + + + + + Please enter your $appname registration code and registered e-mail (the e-mail you used for the purchase), then press "Submit". + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + QLayout::SetNoConstraint + + + QFormLayout::ExpandingFieldsGrow + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + Registration code: + + + + + + + Registered e-mail: + + + + + + + + + + + + + + + + + Purchase + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Cancel + + + false + + + + + + + + 0 + 0 + + + + Submit + + + false + + + true + + + + + + + + + + + cancelButton + clicked() + RegSubmitDialog + reject() + + + 260 + 159 + + + 198 + 97 + + + + + diff --git a/base/qt/results_model.py b/base/qt/results_model.py new file mode 100644 index 00000000..d28d6da3 --- /dev/null +++ b/base/qt/results_model.py @@ -0,0 +1,175 @@ +#!/usr/bin/env python +# Unit Name: +# Created By: Virgil Dupras +# Created On: 2009-04-23 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import SIGNAL, Qt, QAbstractItemModel, QVariant, QModelIndex, QRect +from PyQt4.QtGui import QBrush, QStyledItemDelegate, QFont, QTreeView, QColor + +from tree_model import TreeNode, TreeModel + +class ResultNode(TreeNode): + def __init__(self, model, parent, row, dupe, group): + TreeNode.__init__(self, parent, row) + self.model = model + self.dupe = dupe + self.group = group + self._normalData = None + self._deltaData = None + + def _get_children(self): + children = [] + if self.dupe is self.group.ref: + for index, dupe in enumerate(self.group.dupes): + children.append(ResultNode(self.model, self, index, dupe, self.group)) + return children + + def reset(self): + self._normalData = None + self._deltaData = None + + @property + def normalData(self): + if self._normalData is None: + self._normalData = self.model._data.GetDisplayInfo(self.dupe, self.group, delta=False) + return self._normalData + + @property + def deltaData(self): + if self._deltaData is None: + self._deltaData = self.model._data.GetDisplayInfo(self.dupe, self.group, delta=True) + return self._deltaData + + +class ResultsDelegate(QStyledItemDelegate): + def initStyleOption(self, option, index): + QStyledItemDelegate.initStyleOption(self, option, index) + node = index.internalPointer() + if node.group.ref is node.dupe: + newfont = QFont(option.font) + newfont.setBold(True) + option.font = newfont + + +class ResultsModel(TreeModel): + def __init__(self, app): + self._app = app + self._results = app.results + self._data = app.data + self._delta_columns = app.DELTA_COLUMNS + self.delta = False + self._power_marker = False + TreeModel.__init__(self) + + def _root_nodes(self): + nodes = [] + if self.power_marker: + for index, dupe in enumerate(self._results.dupes): + group = self._results.get_group_of_duplicate(dupe) + nodes.append(ResultNode(self, None, index, dupe, group)) + else: + for index, group in enumerate(self._results.groups): + nodes.append(ResultNode(self, None, index, group.ref, group)) + return nodes + + def columnCount(self, parent): + return len(self._data.COLUMNS) + + def data(self, index, role): + if not index.isValid(): + return QVariant() + node = index.internalPointer() + if role == Qt.DisplayRole: + data = node.deltaData if self.delta else node.normalData + return QVariant(data[index.column()]) + elif role == Qt.CheckStateRole: + if index.column() == 0 and node.dupe is not node.group.ref: + state = Qt.Checked if self._results.is_marked(node.dupe) else Qt.Unchecked + return QVariant(state) + elif role == Qt.ForegroundRole: + if node.dupe is node.group.ref or node.dupe.is_ref: + return QVariant(QBrush(Qt.blue)) + elif self.delta and index.column() in self._delta_columns: + return QVariant(QBrush(QColor(255, 142, 40))) # orange + elif role == Qt.EditRole: + if index.column() == 0: + return QVariant(node.normalData[index.column()]) + return QVariant() + + def dupesForIndexes(self, indexes): + nodes = [index.internalPointer() for index in indexes] + return [node.dupe for node in nodes] + + def flags(self, index): + if not index.isValid(): + return Qt.ItemIsEnabled + flags = Qt.ItemIsEnabled | Qt.ItemIsSelectable + if index.column() == 0: + flags |= Qt.ItemIsUserCheckable | Qt.ItemIsEditable + return flags + + def headerData(self, section, orientation, role): + if orientation == Qt.Horizontal and role == Qt.DisplayRole and section < len(self._data.COLUMNS): + return QVariant(self._data.COLUMNS[section]['display']) + + return QVariant() + + def setData(self, index, value, role): + if not index.isValid(): + return False + node = index.internalPointer() + if role == Qt.CheckStateRole: + if index.column() == 0: + self._app.toggle_marking_for_dupes([node.dupe]) + return True + if role == Qt.EditRole: + if index.column() == 0: + value = unicode(value.toString()) + if self._app.rename_dupe(node.dupe, value): + node.reset() + return True + return False + + def sort(self, column, order): + if self.power_marker: + self._results.sort_dupes(column, order == Qt.AscendingOrder, self.delta) + else: + self._results.sort_groups(column, order == Qt.AscendingOrder) + self.reset() + + def toggleMarked(self, indexes): + assert indexes + dupes = self.dupesForIndexes(indexes) + self._app.toggle_marking_for_dupes(dupes) + + #--- Properties + @property + def power_marker(self): + return self._power_marker + + @power_marker.setter + def power_marker(self, value): + if value == self._power_marker: + return + self._power_marker = value + self.reset() + + +class ResultsView(QTreeView): + #--- Override + def keyPressEvent(self, event): + if event.text() == ' ': + self.model().toggleMarked(self.selectionModel().selectedRows()) + return + QTreeView.keyPressEvent(self, event) + + def setModel(self, model): + assert isinstance(model, ResultsModel) + QTreeView.setModel(self, model) + + #--- Public + def selectedDupes(self): + return self.model().dupesForIndexes(self.selectionModel().selectedRows()) + diff --git a/base/qt/tree_model.py b/base/qt/tree_model.py new file mode 100644 index 00000000..b3a994b3 --- /dev/null +++ b/base/qt/tree_model.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# Unit Name: tree_model +# Created By: Virgil Dupras +# Created On: 2009-05-04 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import Qt, QAbstractItemModel, QVariant, QModelIndex + +class TreeNode(object): + def __init__(self, parent, row): + self.parent = parent + self.row = row + self._children = None + + def _get_children(self): + raise NotImplementedError() + + @property + def children(self): + if self._children is None: + self._children = self._get_children() + return self._children + + +class TreeModel(QAbstractItemModel): + def __init__(self): + QAbstractItemModel.__init__(self) + self._nodes = None + + def _root_nodes(self): + raise NotImplementedError() + + def index(self, row, column, parent): + if not self.nodes: + return QModelIndex() + if not parent.isValid(): + return self.createIndex(row, column, self.nodes[row]) + node = parent.internalPointer() + return self.createIndex(row, column, node.children[row]) + + def parent(self, index): + if not index.isValid(): + return QModelIndex() + node = index.internalPointer() + if node.parent is None: + return QModelIndex() + else: + return self.createIndex(node.parent.row, 0, node.parent) + + def reset(self): + self._nodes = None + QAbstractItemModel.reset(self) + + def rowCount(self, parent): + if not parent.isValid(): + return len(self.nodes) + node = parent.internalPointer() + return len(node.children) + + @property + def nodes(self): + if self._nodes is None: + self._nodes = self._root_nodes() + return self._nodes + diff --git a/images/actions32.png b/images/actions32.png new file mode 100755 index 00000000..16d64fc1 Binary files /dev/null and b/images/actions32.png differ diff --git a/images/delta32.png b/images/delta32.png new file mode 100755 index 00000000..f7d95da0 Binary files /dev/null and b/images/delta32.png differ diff --git a/images/details32.png b/images/details32.png new file mode 100644 index 00000000..8ab245b4 Binary files /dev/null and b/images/details32.png differ diff --git a/images/dgme_logo.ico b/images/dgme_logo.ico new file mode 100644 index 00000000..e15f3ffd Binary files /dev/null and b/images/dgme_logo.ico differ diff --git a/images/dgme_logo_128.png b/images/dgme_logo_128.png new file mode 100644 index 00000000..187c21c8 Binary files /dev/null and b/images/dgme_logo_128.png differ diff --git a/images/dgme_logo_32.png b/images/dgme_logo_32.png new file mode 100644 index 00000000..88488462 Binary files /dev/null and b/images/dgme_logo_32.png differ diff --git a/images/dgpe_logo.ico b/images/dgpe_logo.ico new file mode 100644 index 00000000..01ea1b3f Binary files /dev/null and b/images/dgpe_logo.ico differ diff --git a/images/dgpe_logo_128.png b/images/dgpe_logo_128.png new file mode 100644 index 00000000..137b6396 Binary files /dev/null and b/images/dgpe_logo_128.png differ diff --git a/images/dgpe_logo_32.png b/images/dgpe_logo_32.png new file mode 100755 index 00000000..5384a81c Binary files /dev/null and b/images/dgpe_logo_32.png differ diff --git a/images/dgse_logo.ico b/images/dgse_logo.ico new file mode 100644 index 00000000..992c9280 Binary files /dev/null and b/images/dgse_logo.ico differ diff --git a/images/dgse_logo_128.png b/images/dgse_logo_128.png new file mode 100644 index 00000000..f50221b2 Binary files /dev/null and b/images/dgse_logo_128.png differ diff --git a/images/dgse_logo_32.png b/images/dgse_logo_32.png new file mode 100755 index 00000000..29d53d2d Binary files /dev/null and b/images/dgse_logo_32.png differ diff --git a/images/folder32.png b/images/folder32.png new file mode 100755 index 00000000..85070da7 Binary files /dev/null and b/images/folder32.png differ diff --git a/images/folderwin32.png b/images/folderwin32.png new file mode 100755 index 00000000..5e861a4b Binary files /dev/null and b/images/folderwin32.png differ diff --git a/images/gear.png b/images/gear.png new file mode 100755 index 00000000..41ff2dd6 Binary files /dev/null and b/images/gear.png differ diff --git a/images/power_marker32.png b/images/power_marker32.png new file mode 100755 index 00000000..48129026 Binary files /dev/null and b/images/power_marker32.png differ diff --git a/images/preferences32.png b/images/preferences32.png new file mode 100755 index 00000000..bdbc4051 Binary files /dev/null and b/images/preferences32.png differ diff --git a/me/cocoa/AppDelegate.h b/me/cocoa/AppDelegate.h new file mode 100644 index 00000000..89fb5b0f --- /dev/null +++ b/me/cocoa/AppDelegate.h @@ -0,0 +1,22 @@ +#import +#import "dgbase/AppDelegate.h" +#import "ResultWindow.h" +#import "DirectoryPanel.h" +#import "PyDupeGuru.h" + +@interface AppDelegate : AppDelegateBase +{ + IBOutlet NSButton *presetsButton; + IBOutlet NSPopUpButton *presetsPopup; + IBOutlet ResultWindow *result; + + DirectoryPanel *_directoryPanel; +} +- (IBAction)openWebsite:(id)sender; +- (IBAction)popupPresets:(id)sender; +- (IBAction)toggleDirectories:(id)sender; +- (IBAction)usePreset:(id)sender; + +- (DirectoryPanel *)directoryPanel; +- (PyDupeGuru *)py; +@end diff --git a/me/cocoa/AppDelegate.m b/me/cocoa/AppDelegate.m new file mode 100644 index 00000000..804999de --- /dev/null +++ b/me/cocoa/AppDelegate.m @@ -0,0 +1,158 @@ +#import "AppDelegate.h" +#import "cocoalib/ProgressController.h" +#import "cocoalib/RegistrationInterface.h" +#import "cocoalib/Utils.h" +#import "cocoalib/ValueTransformers.h" +#import "cocoalib/Dialogs.h" +#import "Consts.h" + +@implementation AppDelegate ++ (void)initialize +{ + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + NSMutableDictionary *d = [NSMutableDictionary dictionaryWithCapacity:10]; + [d setObject:i2n(3) forKey:@"scanType"]; + [d setObject:i2n(80) forKey:@"minMatchPercentage"]; + [d setObject:i2n(1) forKey:@"recreatePathType"]; + [d setObject:b2n(NO) forKey:@"wordWeighting"]; + [d setObject:b2n(NO) forKey:@"matchSimilarWords"]; + [d setObject:b2n(YES) forKey:@"mixFileKind"]; + [d setObject:b2n(NO) forKey:@"useRegexpFilter"]; + [d setObject:b2n(NO) forKey:@"removeEmptyFolders"]; + [d setObject:b2n(NO) forKey:@"debug"]; + [d setObject:b2n(NO) forKey:@"scanTagTrack"]; + [d setObject:b2n(YES) forKey:@"scanTagArtist"]; + [d setObject:b2n(YES) forKey:@"scanTagAlbum"]; + [d setObject:b2n(YES) forKey:@"scanTagTitle"]; + [d setObject:b2n(NO) forKey:@"scanTagGenre"]; + [d setObject:b2n(NO) forKey:@"scanTagYear"]; + [d setObject:[NSArray array] forKey:@"recentDirectories"]; + [d setObject:[NSArray array] forKey:@"columnsOrder"]; + [d setObject:[NSDictionary dictionary] forKey:@"columnsWidth"]; + [[NSUserDefaultsController sharedUserDefaultsController] setInitialValues:d]; + [ud registerDefaults:d]; +} + +- (id)init +{ + self = [super init]; + NSMutableIndexSet *i = [NSMutableIndexSet indexSetWithIndex:4]; + [i addIndex:5]; + VTIsIntIn *vtScanTypeIsNotContent = [[[VTIsIntIn alloc] initWithValues:i reverse:YES] autorelease]; + [NSValueTransformer setValueTransformer:vtScanTypeIsNotContent forName:@"vtScanTypeIsNotContent"]; + VTIsIntIn *vtScanTypeIsTag = [[[VTIsIntIn alloc] initWithValues:[NSIndexSet indexSetWithIndex:3] reverse:NO] autorelease]; + [NSValueTransformer setValueTransformer:vtScanTypeIsTag forName:@"vtScanTypeIsTag"]; + _directoryPanel = nil; + _appName = APPNAME; + return self; +} + +- (IBAction)openWebsite:(id)sender +{ + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.hardcoded.net/dupeguru_me"]]; +} + +- (IBAction)popupPresets:(id)sender +{ + [presetsPopup selectItem: nil]; + [[presetsPopup cell] performClickWithFrame:[sender frame] inView:[sender superview]]; +} + +- (IBAction)toggleDirectories:(id)sender +{ + [[self directoryPanel] toggleVisible:sender]; +} + +- (IBAction)usePreset:(id)sender +{ + NSUserDefaultsController *ud = [NSUserDefaultsController sharedUserDefaultsController]; + [ud revertToInitialValues:nil]; + NSUserDefaults *d = [ud defaults]; + switch ([sender tag]) + { + case 0: + { + [d setInteger:5 forKey:@"scanType"]; + break; + } + //case 1 is defaults + case 2: + { + [d setInteger:2 forKey:@"scanType"]; + break; + } + case 3: + { + [d setInteger:0 forKey:@"scanType"]; + [d setInteger:50 forKey:@"minMatchPercentage"]; + break; + } + case 4: + { + [d setInteger:0 forKey:@"scanType"]; + [d setInteger:50 forKey:@"minMatchPercentage"]; + [d setBool:YES forKey:@"matchSimilarWords"]; + [d setBool:YES forKey:@"wordWeighting"]; + break; + } + } +} + +- (DirectoryPanel *)directoryPanel +{ + if (!_directoryPanel) + _directoryPanel = [[DirectoryPanel alloc] initWithParentApp:self]; + return _directoryPanel; +} +- (PyDupeGuru *)py { return (PyDupeGuru *)py; } + +//Delegate +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification +{ + [[ProgressController mainProgressController] setWorker:py]; + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + //Restore Columns + NSArray *columnsOrder = [ud arrayForKey:@"columnsOrder"]; + NSDictionary *columnsWidth = [ud dictionaryForKey:@"columnsWidth"]; + if ([columnsOrder count]) + [result restoreColumnsPosition:columnsOrder widths:columnsWidth]; + //Reg stuff + if ([RegistrationInterface showNagWithApp:[self py] name:APPNAME limitDescription:LIMIT_DESC]) + [unlockMenuItem setTitle:@"Thanks for buying dupeGuru ME!"]; + //Restore results + [py loadIgnoreList]; + [py loadResults]; +} + +- (void)applicationWillBecomeActive:(NSNotification *)aNotification +{ + if (![[result window] isVisible]) + [result showWindow:NSApp]; +} + +- (void)applicationWillTerminate:(NSNotification *)aNotification +{ + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + [ud setObject: [result getColumnsOrder] forKey:@"columnsOrder"]; + [ud setObject: [result getColumnsWidth] forKey:@"columnsWidth"]; + [py saveIgnoreList]; + [py saveResults]; + int sc = [ud integerForKey:@"sessionCountSinceLastIgnorePurge"]; + if (sc >= 10) + { + sc = -1; + [py purgeIgnoreList]; + } + sc++; + [ud setInteger:sc forKey:@"sessionCountSinceLastIgnorePurge"]; + // NSApplication does not release nib instances objects, we must do it manually + // Well, it isn't needed because the memory is freed anyway (we are quitting the application + // But I need to release RecentDirectories so it saves the user defaults + [recentDirectories release]; +} + +- (void)recentDirecoryClicked:(NSString *)directory +{ + [[self directoryPanel] addDirectory:directory]; +} +@end diff --git a/me/cocoa/Consts.h b/me/cocoa/Consts.h new file mode 100644 index 00000000..94d203f7 --- /dev/null +++ b/me/cocoa/Consts.h @@ -0,0 +1,5 @@ +#import "dgbase/Consts.h" + +#define APPNAME @"dupeGuru ME" + +#define jobScanDeadTracks @"jobScanDeadTracks" \ No newline at end of file diff --git a/me/cocoa/DetailsPanel.h b/me/cocoa/DetailsPanel.h new file mode 100644 index 00000000..0d4c025d --- /dev/null +++ b/me/cocoa/DetailsPanel.h @@ -0,0 +1,13 @@ +#import +#import "cocoalib/PyApp.h" +#import "cocoalib/Table.h" + + +@interface DetailsPanel : NSWindowController +{ + IBOutlet TableView *detailsTable; +} +- (id)initWithPy:(PyApp *)aPy; + +- (void)refresh; +@end \ No newline at end of file diff --git a/me/cocoa/DetailsPanel.m b/me/cocoa/DetailsPanel.m new file mode 100644 index 00000000..1baac387 --- /dev/null +++ b/me/cocoa/DetailsPanel.m @@ -0,0 +1,16 @@ +#import "DetailsPanel.h" + +@implementation DetailsPanel +- (id)initWithPy:(PyApp *)aPy +{ + self = [super initWithWindowNibName:@"Details"]; + [self window]; //So the detailsTable is initialized. + [detailsTable setPy:aPy]; + return self; +} + +- (void)refresh +{ + [detailsTable reloadData]; +} +@end diff --git a/me/cocoa/DirectoryPanel.h b/me/cocoa/DirectoryPanel.h new file mode 100644 index 00000000..86b00388 --- /dev/null +++ b/me/cocoa/DirectoryPanel.h @@ -0,0 +1,8 @@ +#import +#import "dgbase/DirectoryPanel.h" + +@interface DirectoryPanel : DirectoryPanelBase +{ +} +- (IBAction)addiTunes:(id)sender; +@end diff --git a/me/cocoa/DirectoryPanel.m b/me/cocoa/DirectoryPanel.m new file mode 100644 index 00000000..0f9831ab --- /dev/null +++ b/me/cocoa/DirectoryPanel.m @@ -0,0 +1,23 @@ +#import "DirectoryPanel.h" + +@implementation DirectoryPanel +- (IBAction)addiTunes:(id)sender +{ + [self addDirectory:[@"~/Music/iTunes/iTunes Music" stringByExpandingTildeInPath]]; +} + +- (IBAction)popupAddDirectoryMenu:(id)sender +{ + NSMenu *m = [addButtonPopUp menu]; + while ([m numberOfItems] > 0) + [m removeItemAtIndex:0]; + NSMenuItem *mi = [m addItemWithTitle:@"Add New Directory..." action:@selector(askForDirectory:) keyEquivalent:@""]; + [mi setTarget:self]; + mi = [m addItemWithTitle:@"Add iTunes Directory" action:@selector(addiTunes:) keyEquivalent:@""]; + [mi setTarget:self]; + [m addItem:[NSMenuItem separatorItem]]; + [_recentDirectories fillMenu:m]; + [addButtonPopUp selectItem: nil]; + [[addButtonPopUp cell] performClickWithFrame:[sender frame] inView:[sender superview]]; +} +@end diff --git a/me/cocoa/English.lproj/Details.nib/classes.nib b/me/cocoa/English.lproj/Details.nib/classes.nib new file mode 100644 index 00000000..e1b7cb92 --- /dev/null +++ b/me/cocoa/English.lproj/Details.nib/classes.nib @@ -0,0 +1,18 @@ +{ + IBClasses = ( + { + CLASS = DetailsPanel; + LANGUAGE = ObjC; + OUTLETS = {detailsTable = NSTableView; }; + SUPERCLASS = NSWindowController; + }, + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + CLASS = TableView; + LANGUAGE = ObjC; + OUTLETS = {py = PyApp; }; + SUPERCLASS = NSTableView; + } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/me/cocoa/English.lproj/Details.nib/info.nib b/me/cocoa/English.lproj/Details.nib/info.nib new file mode 100644 index 00000000..3f14ee77 --- /dev/null +++ b/me/cocoa/English.lproj/Details.nib/info.nib @@ -0,0 +1,16 @@ + + + + + IBDocumentLocation + 432 54 356 240 0 0 1024 746 + IBFramework Version + 443.0 + IBOpenObjects + + 5 + + IBSystem Version + 8I127 + + diff --git a/me/cocoa/English.lproj/Details.nib/keyedobjects.nib b/me/cocoa/English.lproj/Details.nib/keyedobjects.nib new file mode 100644 index 00000000..e50621e9 Binary files /dev/null and b/me/cocoa/English.lproj/Details.nib/keyedobjects.nib differ diff --git a/me/cocoa/English.lproj/Directories.nib/classes.nib b/me/cocoa/English.lproj/Directories.nib/classes.nib new file mode 100644 index 00000000..dee61df7 --- /dev/null +++ b/me/cocoa/English.lproj/Directories.nib/classes.nib @@ -0,0 +1,64 @@ + + + + + IBClasses + + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + ACTIONS + + addiTunes + id + askForDirectory + id + changeDirectoryState + id + popupAddDirectoryMenu + id + removeSelectedDirectory + id + toggleVisible + id + + CLASS + DirectoryPanel + LANGUAGE + ObjC + OUTLETS + + addButtonPopUp + NSPopUpButton + directories + NSOutlineView + removeButton + NSButton + + SUPERCLASS + DirectoryPanelBase + + + CLASS + OutlineView + LANGUAGE + ObjC + OUTLETS + + py + PyApp + + SUPERCLASS + NSOutlineView + + + IBVersion + 1 + + diff --git a/me/cocoa/English.lproj/Directories.nib/info.nib b/me/cocoa/English.lproj/Directories.nib/info.nib new file mode 100644 index 00000000..77f19ce7 --- /dev/null +++ b/me/cocoa/English.lproj/Directories.nib/info.nib @@ -0,0 +1,20 @@ + + + + + IBFramework Version + 629 + IBLastKnownRelativeProjectPath + ../../dupeguru.xcodeproj + IBOldestOS + 5 + IBOpenObjects + + 5 + + IBSystem Version + 9B18 + targetFramework + IBCocoaFramework + + diff --git a/me/cocoa/English.lproj/Directories.nib/keyedobjects.nib b/me/cocoa/English.lproj/Directories.nib/keyedobjects.nib new file mode 100644 index 00000000..c541159e Binary files /dev/null and b/me/cocoa/English.lproj/Directories.nib/keyedobjects.nib differ diff --git a/me/cocoa/English.lproj/InfoPlist.strings b/me/cocoa/English.lproj/InfoPlist.strings new file mode 100644 index 00000000..b0430081 Binary files /dev/null and b/me/cocoa/English.lproj/InfoPlist.strings differ diff --git a/me/cocoa/English.lproj/MainMenu.nib/classes.nib b/me/cocoa/English.lproj/MainMenu.nib/classes.nib new file mode 100644 index 00000000..b3d34484 --- /dev/null +++ b/me/cocoa/English.lproj/MainMenu.nib/classes.nib @@ -0,0 +1,257 @@ + + + + + IBClasses + + + CLASS + NSSegmentedControl + LANGUAGE + ObjC + SUPERCLASS + NSControl + + + ACTIONS + + openWebsite + id + popupPresets + id + toggleDirectories + id + unlockApp + id + usePreset + id + + CLASS + AppDelegate + LANGUAGE + ObjC + OUTLETS + + defaultsController + NSUserDefaultsController + presetsButton + NSButton + presetsPopup + NSPopUpButton + py + PyDupeGuru + recentDirectories + RecentDirectories + result + ResultWindow + unlockMenuItem + NSMenuItem + + SUPERCLASS + AppDelegateBase + + + CLASS + PyApp + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + CLASS + MatchesView + LANGUAGE + ObjC + SUPERCLASS + OutlineView + + + CLASS + PyDupeGuruBase + LANGUAGE + ObjC + SUPERCLASS + PyApp + + + CLASS + PyDupeGuru + LANGUAGE + ObjC + SUPERCLASS + PyDupeGuruBase + + + ACTIONS + + changeDelta + id + changePowerMarker + id + clearIgnoreList + id + collapseAll + id + copyMarked + id + deleteMarked + id + expandAll + id + exportToXHTML + id + filter + id + ignoreSelected + id + markAll + id + markInvert + id + markNone + id + markSelected + id + markToggle + id + moveMarked + id + openSelected + id + refresh + id + removeDeadTracks + id + removeMarked + id + removeSelected + id + renameSelected + id + resetColumnsToDefault + id + revealSelected + id + showPreferencesPanel + id + startDuplicateScan + id + switchSelected + id + toggleColumn + id + toggleDelta + id + toggleDetailsPanel + id + togglePowerMarker + id + + CLASS + ResultWindow + LANGUAGE + ObjC + OUTLETS + + actionMenu + NSPopUpButton + actionMenuView + NSView + app + id + columnsMenu + NSMenu + deltaSwitch + NSSegmentedControl + deltaSwitchView + NSView + filterField + NSSearchField + filterFieldView + NSView + matches + MatchesView + pmSwitch + NSSegmentedControl + pmSwitchView + NSView + preferencesPanel + NSWindow + py + PyDupeGuru + stats + NSTextField + + SUPERCLASS + ResultWindowBase + + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + ACTIONS + + checkForUpdates + id + + CLASS + SUUpdater + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + ACTIONS + + clearMenu + id + menuClick + id + + CLASS + RecentDirectories + LANGUAGE + ObjC + OUTLETS + + delegate + id + menu + NSMenu + + SUPERCLASS + NSObject + + + CLASS + ResultWindowBase + LANGUAGE + ObjC + SUPERCLASS + NSWindowController + + + CLASS + OutlineView + LANGUAGE + ObjC + OUTLETS + + py + PyApp + + SUPERCLASS + NSOutlineView + + + IBVersion + 1 + + diff --git a/me/cocoa/English.lproj/MainMenu.nib/info.nib b/me/cocoa/English.lproj/MainMenu.nib/info.nib new file mode 100644 index 00000000..7cd1eddb --- /dev/null +++ b/me/cocoa/English.lproj/MainMenu.nib/info.nib @@ -0,0 +1,20 @@ + + + + + IBFramework Version + 629 + IBLastKnownRelativeProjectPath + ../../dupeguru.xcodeproj + IBOldestOS + 5 + IBOpenObjects + + 598 + + IBSystem Version + 9E17 + targetFramework + IBCocoaFramework + + diff --git a/me/cocoa/English.lproj/MainMenu.nib/keyedobjects.nib b/me/cocoa/English.lproj/MainMenu.nib/keyedobjects.nib new file mode 100644 index 00000000..649ce170 Binary files /dev/null and b/me/cocoa/English.lproj/MainMenu.nib/keyedobjects.nib differ diff --git a/me/cocoa/Info.plist b/me/cocoa/Info.plist new file mode 100644 index 00000000..97d43767 --- /dev/null +++ b/me/cocoa/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleHelpBookFolder + dupeguru_me_help + CFBundleHelpBookName + dupeGuru ME Help + CFBundleIconFile + dupeguru + CFBundleIdentifier + com.hardcoded_software.dupeguru_me + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + hsft + CFBundleVersion + 5.6.1 + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + SUFeedURL + http://www.hardcoded.net/updates/dupeguru_me.appcast + + diff --git a/me/cocoa/PyDupeGuru.h b/me/cocoa/PyDupeGuru.h new file mode 100644 index 00000000..04dfce20 --- /dev/null +++ b/me/cocoa/PyDupeGuru.h @@ -0,0 +1,15 @@ +#import +#import "dgbase/PyDupeGuru.h" + +@interface PyDupeGuru : PyDupeGuruBase +//Scanning options +- (void)setScanType:(NSNumber *)scan_type; +- (void)setMinWordCount:(NSNumber *)word_count; +- (void)setMinWordLength:(NSNumber *)word_length; +- (void)setWordWeighting:(NSNumber *)words_are_weighted; +- (void)setMatchSimilarWords:(NSNumber *)match_similar_words; +- (void)enable:(NSNumber *)enable scanForTag:(NSString *)tag; +- (void)scanDeadTracks; +- (void)removeDeadTracks; +- (int)deadTrackCount; +@end diff --git a/me/cocoa/ResultWindow.h b/me/cocoa/ResultWindow.h new file mode 100644 index 00000000..e421b99d --- /dev/null +++ b/me/cocoa/ResultWindow.h @@ -0,0 +1,56 @@ +#import +#import "cocoalib/Outline.h" +#import "dgbase/ResultWindow.h" +#import "DetailsPanel.h" +#import "DirectoryPanel.h" + +@interface ResultWindow : ResultWindowBase +{ + IBOutlet NSPopUpButton *actionMenu; + IBOutlet NSMenu *columnsMenu; + IBOutlet NSSearchField *filterField; + IBOutlet NSSegmentedControl *pmSwitch; + IBOutlet NSWindow *preferencesPanel; + IBOutlet NSTextField *stats; + + NSString *_lastAction; + DetailsPanel *_detailsPanel; + NSMutableArray *_resultColumns; + NSMutableIndexSet *_deltaColumns; +} +- (IBAction)changePowerMarker:(id)sender; +- (IBAction)clearIgnoreList:(id)sender; +- (IBAction)exportToXHTML:(id)sender; +- (IBAction)filter:(id)sender; +- (IBAction)ignoreSelected:(id)sender; +- (IBAction)markAll:(id)sender; +- (IBAction)markInvert:(id)sender; +- (IBAction)markNone:(id)sender; +- (IBAction)markSelected:(id)sender; +- (IBAction)markToggle:(id)sender; +- (IBAction)openSelected:(id)sender; +- (IBAction)refresh:(id)sender; +- (IBAction)removeDeadTracks:(id)sender; +- (IBAction)removeMarked:(id)sender; +- (IBAction)removeSelected:(id)sender; +- (IBAction)renameSelected:(id)sender; +- (IBAction)resetColumnsToDefault:(id)sender; +- (IBAction)revealSelected:(id)sender; +- (IBAction)showPreferencesPanel:(id)sender; +- (IBAction)startDuplicateScan:(id)sender; +- (IBAction)switchSelected:(id)sender; +- (IBAction)toggleColumn:(id)sender; +- (IBAction)toggleDelta:(id)sender; +- (IBAction)toggleDetailsPanel:(id)sender; +- (IBAction)togglePowerMarker:(id)sender; + +- (NSTableColumn *)getColumnForIdentifier:(int)aIdentifier title:(NSString *)aTitle width:(int)aWidth refCol:(NSTableColumn *)aColumn; +- (NSArray *)getColumnsOrder; +- (NSDictionary *)getColumnsWidth; +- (NSArray *)getSelected:(BOOL)aDupesOnly; +- (NSArray *)getSelectedPaths:(BOOL)aDupesOnly; +- (void)initResultColumns; +- (void)performPySelection:(NSArray *)aIndexPaths; +- (void)refreshStats; +- (void)restoreColumnsPosition:(NSArray *)aColumnsOrder widths:(NSDictionary *)aColumnsWidth; +@end diff --git a/me/cocoa/ResultWindow.m b/me/cocoa/ResultWindow.m new file mode 100644 index 00000000..540216e3 --- /dev/null +++ b/me/cocoa/ResultWindow.m @@ -0,0 +1,505 @@ +#import "ResultWindow.h" +#import "cocoalib/Dialogs.h" +#import "cocoalib/ProgressController.h" +#import "cocoalib/RegistrationInterface.h" +#import "cocoalib/Utils.h" +#import "AppDelegate.h" +#import "Consts.h" + +@implementation ResultWindow +/* Override */ +- (void)awakeFromNib +{ + [super awakeFromNib]; + _detailsPanel = nil; + _displayDelta = NO; + _powerMode = NO; + _deltaColumns = [[NSMutableIndexSet indexSetWithIndexesInRange:NSMakeRange(2,7)] retain]; + [_deltaColumns removeIndex:6]; + [deltaSwitch setSelectedSegment:0]; + [pmSwitch setSelectedSegment:0]; + [py setDisplayDeltaValues:b2n(_displayDelta)]; + [matches setTarget:self]; + [matches setDoubleAction:@selector(openSelected:)]; + [[actionMenu itemAtIndex:0] setImage:[NSImage imageNamed: @"gear"]]; + [self initResultColumns]; + [self refreshStats]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resultsMarkingChanged:) name:ResultsMarkingChangedNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(duplicateSelectionChanged:) name:DuplicateSelectionChangedNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resultsChanged:) name:ResultsChangedNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jobCompleted:) name:JobCompletedNotification object:nil]; + + NSToolbar *t = [[[NSToolbar alloc] initWithIdentifier:@"ResultWindowToolbar"] autorelease]; + [t setAllowsUserCustomization:YES]; + [t setAutosavesConfiguration:YES]; + [t setDisplayMode:NSToolbarDisplayModeIconAndLabel]; + [t setDelegate:self]; + [[self window] setToolbar:t]; +} + +/* Overrides */ +- (NSString *)logoImageName +{ + return @"dgme_logo32"; +} + +/* Actions */ + +- (IBAction)changePowerMarker:(id)sender +{ + _powerMode = [pmSwitch selectedSegment] == 1; + if (_powerMode) + [matches setTag:2]; + else + [matches setTag:0]; + [self expandAll:nil]; + [self outlineView:matches didClickTableColumn:nil]; +} + +- (IBAction)clearIgnoreList:(id)sender +{ + int i = n2i([py getIgnoreListCount]); + if (!i) + return; + if ([Dialogs askYesNo:[NSString stringWithFormat:@"Do you really want to remove all %d items from the ignore list?",i]] == NSAlertSecondButtonReturn) // NO + return; + [py clearIgnoreList]; +} + +- (IBAction)exportToXHTML:(id)sender +{ + NSString *xsltPath = [[NSBundle mainBundle] pathForResource:@"dg" ofType:@"xsl"]; + NSString *cssPath = [[NSBundle mainBundle] pathForResource:@"hardcoded" ofType:@"css"]; + NSString *exported = [py exportToXHTMLwithColumns:[self getColumnsOrder] xslt:xsltPath css:cssPath]; + [[NSWorkspace sharedWorkspace] openFile:exported]; +} + +- (IBAction)filter:(id)sender +{ + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + [py setEscapeFilterRegexp:b2n(!n2b([ud objectForKey:@"useRegexpFilter"]))]; + [py applyFilter:[filterField stringValue]]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)ignoreSelected:(id)sender +{ + NSArray *nodeList = [self getSelected:YES]; + if (![nodeList count]) + return; + if ([Dialogs askYesNo:[NSString stringWithFormat:@"All selected %d matches are going to be ignored in all subsequent scans. Continue?",[nodeList count]]] == NSAlertSecondButtonReturn) // NO + return; + [self performPySelection:[self getSelectedPaths:YES]]; + [py addSelectedToIgnoreList]; + [py removeSelected]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)markAll:(id)sender +{ + [py markAll]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsMarkingChangedNotification object:self]; +} + +- (IBAction)markInvert:(id)sender +{ + [py markInvert]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsMarkingChangedNotification object:self]; +} + +- (IBAction)markNone:(id)sender +{ + [py markNone]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsMarkingChangedNotification object:self]; +} + +- (IBAction)markSelected:(id)sender +{ + [self performPySelection:[self getSelectedPaths:YES]]; + [py toggleSelectedMark]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsMarkingChangedNotification object:self]; +} + +- (IBAction)markToggle:(id)sender +{ + OVNode *node = [matches itemAtRow:[matches clickedRow]]; + [self performPySelection:[NSArray arrayWithObject:p2a([node indexPath])]]; + [py toggleSelectedMark]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsMarkingChangedNotification object:self]; +} + +- (IBAction)openSelected:(id)sender +{ + [self performPySelection:[self getSelectedPaths:NO]]; + [py openSelected]; +} + +- (IBAction)refresh:(id)sender +{ + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)removeDeadTracks:(id)sender +{ + [(PyDupeGuru *)py scanDeadTracks]; +} + +- (IBAction)removeMarked:(id)sender +{ + int mark_count = [[py getMarkCount] intValue]; + if (!mark_count) + return; + if ([Dialogs askYesNo:[NSString stringWithFormat:@"You are about to remove %d files from results. Continue?",mark_count]] == NSAlertSecondButtonReturn) // NO + return; + [py removeMarked]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)removeSelected:(id)sender +{ + NSArray *nodeList = [self getSelected:YES]; + if (![nodeList count]) + return; + if ([Dialogs askYesNo:[NSString stringWithFormat:@"You are about to remove %d files from results. Continue?",[nodeList count]]] == NSAlertSecondButtonReturn) // NO + return; + [self performPySelection:[self getSelectedPaths:YES]]; + [py removeSelected]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)renameSelected:(id)sender +{ + int col = [matches columnWithIdentifier:@"0"]; + int row = [matches selectedRow]; + [matches editColumn:col row:row withEvent:[NSApp currentEvent] select:YES]; +} + +- (IBAction)resetColumnsToDefault:(id)sender +{ + NSMutableArray *columnsOrder = [NSMutableArray array]; + [columnsOrder addObject:@"0"]; + [columnsOrder addObject:@"2"]; + [columnsOrder addObject:@"3"]; + [columnsOrder addObject:@"4"]; + [columnsOrder addObject:@"16"]; + NSMutableDictionary *columnsWidth = [NSMutableDictionary dictionary]; + [columnsWidth setObject:i2n(214) forKey:@"0"]; + [columnsWidth setObject:i2n(63) forKey:@"2"]; + [columnsWidth setObject:i2n(50) forKey:@"3"]; + [columnsWidth setObject:i2n(50) forKey:@"4"]; + [columnsWidth setObject:i2n(57) forKey:@"16"]; + [self restoreColumnsPosition:columnsOrder widths:columnsWidth]; +} + +- (IBAction)revealSelected:(id)sender +{ + [self performPySelection:[self getSelectedPaths:NO]]; + [py revealSelected]; +} + +- (IBAction)showPreferencesPanel:(id)sender +{ + [preferencesPanel makeKeyAndOrderFront:sender]; +} + +- (IBAction)startDuplicateScan:(id)sender +{ + if ([matches numberOfRows] > 0) + { + if ([Dialogs askYesNo:@"Are you sure you want to start a new duplicate scan?"] == NSAlertSecondButtonReturn) // NO + return; + } + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + PyDupeGuru *_py = (PyDupeGuru *)py; + [_py setScanType:[ud objectForKey:@"scanType"]]; + [_py enable:[ud objectForKey:@"scanTagTrack"] scanForTag:@"track"]; + [_py enable:[ud objectForKey:@"scanTagArtist"] scanForTag:@"artist"]; + [_py enable:[ud objectForKey:@"scanTagAlbum"] scanForTag:@"album"]; + [_py enable:[ud objectForKey:@"scanTagTitle"] scanForTag:@"title"]; + [_py enable:[ud objectForKey:@"scanTagGenre"] scanForTag:@"genre"]; + [_py enable:[ud objectForKey:@"scanTagYear"] scanForTag:@"year"]; + [_py setMinMatchPercentage:[ud objectForKey:@"minMatchPercentage"]]; + [_py setWordWeighting:[ud objectForKey:@"wordWeighting"]]; + [_py setMixFileKind:[ud objectForKey:@"mixFileKind"]]; + [_py setMatchSimilarWords:[ud objectForKey:@"matchSimilarWords"]]; + int r = n2i([py doScan]); + [matches reloadData]; + [self refreshStats]; + if (r == 1) + [Dialogs showMessage:@"You cannot make a duplicate scan with only reference directories."]; + if (r == 3) + { + [Dialogs showMessage:@"The selected directories contain no scannable file."]; + [app toggleDirectories:nil]; + } +} + +- (IBAction)switchSelected:(id)sender +{ + [self performPySelection:[self getSelectedPaths:YES]]; + [py makeSelectedReference]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)toggleColumn:(id)sender +{ + NSMenuItem *mi = sender; + NSString *colId = [NSString stringWithFormat:@"%d",[mi tag]]; + NSTableColumn *col = [matches tableColumnWithIdentifier:colId]; + if (col == nil) + { + //Add Column + col = [_resultColumns objectAtIndex:[mi tag]]; + [matches addTableColumn:col]; + [mi setState:NSOnState]; + } + else + { + //Remove column + [matches removeTableColumn:col]; + [mi setState:NSOffState]; + } +} + +- (IBAction)toggleDelta:(id)sender +{ + if ([deltaSwitch selectedSegment] == 1) + [deltaSwitch setSelectedSegment:0]; + else + [deltaSwitch setSelectedSegment:1]; + [self changeDelta:sender]; +} + +- (IBAction)toggleDetailsPanel:(id)sender +{ + if (!_detailsPanel) + _detailsPanel = [[DetailsPanel alloc] initWithPy:py]; + if ([[_detailsPanel window] isVisible]) + [[_detailsPanel window] close]; + else + [[_detailsPanel window] orderFront:nil]; +} + +- (IBAction)togglePowerMarker:(id)sender +{ + if ([pmSwitch selectedSegment] == 1) + [pmSwitch setSelectedSegment:0]; + else + [pmSwitch setSelectedSegment:1]; + [self changePowerMarker:sender]; +} + +/* Public */ +- (NSTableColumn *)getColumnForIdentifier:(int)aIdentifier title:(NSString *)aTitle width:(int)aWidth refCol:(NSTableColumn *)aColumn +{ + NSNumber *n = [NSNumber numberWithInt:aIdentifier]; + NSTableColumn *col = [[NSTableColumn alloc] initWithIdentifier:[n stringValue]]; + [col setWidth:aWidth]; + [col setEditable:NO]; + [[col dataCell] setFont:[[aColumn dataCell] font]]; + [[col headerCell] setStringValue:aTitle]; + [col setResizingMask:NSTableColumnUserResizingMask]; + [col setSortDescriptorPrototype:[[NSSortDescriptor alloc] initWithKey:[n stringValue] ascending:YES]]; + return col; +} + +//Returns an array of identifiers, in order. +- (NSArray *)getColumnsOrder +{ + NSTableColumn *col; + NSString *colId; + NSMutableArray *result = [NSMutableArray array]; + NSEnumerator *e = [[matches tableColumns] objectEnumerator]; + while (col = [e nextObject]) + { + colId = [col identifier]; + [result addObject:colId]; + } + return result; +} + +- (NSDictionary *)getColumnsWidth +{ + NSMutableDictionary *result = [NSMutableDictionary dictionary]; + NSTableColumn *col; + NSString *colId; + NSNumber *width; + NSEnumerator *e = [[matches tableColumns] objectEnumerator]; + while (col = [e nextObject]) + { + colId = [col identifier]; + width = [NSNumber numberWithFloat:[col width]]; + [result setObject:width forKey:colId]; + } + return result; +} + +- (NSArray *)getSelected:(BOOL)aDupesOnly +{ + if (_powerMode) + aDupesOnly = NO; + NSIndexSet *indexes = [matches selectedRowIndexes]; + NSMutableArray *nodeList = [NSMutableArray array]; + OVNode *node; + int i = [indexes firstIndex]; + while (i != NSNotFound) + { + node = [matches itemAtRow:i]; + if (!aDupesOnly || ([node level] > 1)) + [nodeList addObject:node]; + i = [indexes indexGreaterThanIndex:i]; + } + return nodeList; +} + +- (NSArray *)getSelectedPaths:(BOOL)aDupesOnly +{ + NSMutableArray *r = [NSMutableArray array]; + NSArray *selected = [self getSelected:aDupesOnly]; + NSEnumerator *e = [selected objectEnumerator]; + OVNode *node; + while (node = [e nextObject]) + [r addObject:p2a([node indexPath])]; + return r; +} + +- (void)performPySelection:(NSArray *)aIndexPaths +{ + if (_powerMode) + [py selectPowerMarkerNodePaths:aIndexPaths]; + else + [py selectResultNodePaths:aIndexPaths]; +} + +- (void)initResultColumns +{ + NSTableColumn *refCol = [matches tableColumnWithIdentifier:@"0"]; + _resultColumns = [[NSMutableArray alloc] init]; + [_resultColumns addObject:[matches tableColumnWithIdentifier:@"0"]]; // File Name + [_resultColumns addObject:[self getColumnForIdentifier:1 title:@"Directory" width:120 refCol:refCol]]; + [_resultColumns addObject:[matches tableColumnWithIdentifier:@"2"]]; // Size + [_resultColumns addObject:[matches tableColumnWithIdentifier:@"3"]]; // Time + [_resultColumns addObject:[matches tableColumnWithIdentifier:@"4"]]; // Bitrate + [_resultColumns addObject:[self getColumnForIdentifier:5 title:@"Sample Rate" width:60 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:6 title:@"Kind" width:40 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:7 title:@"Creation" width:120 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:8 title:@"Modification" width:120 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:9 title:@"Title" width:120 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:10 title:@"Artist" width:120 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:11 title:@"Album" width:120 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:12 title:@"Genre" width:80 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:13 title:@"Year" width:40 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:14 title:@"Track Number" width:40 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:15 title:@"Comment" width:120 refCol:refCol]]; + [_resultColumns addObject:[matches tableColumnWithIdentifier:@"16"]]; // Match % + [_resultColumns addObject:[self getColumnForIdentifier:17 title:@"Words Used" width:120 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:18 title:@"Dupe Count" width:80 refCol:refCol]]; +} + +-(void)refreshStats +{ + [stats setStringValue:[py getStatLine]]; +} + +- (void)restoreColumnsPosition:(NSArray *)aColumnsOrder widths:(NSDictionary *)aColumnsWidth +{ + NSTableColumn *col; + NSString *colId; + NSNumber *width; + NSMenuItem *mi; + //Remove all columns + NSEnumerator *e = [[columnsMenu itemArray] objectEnumerator]; + while (mi = [e nextObject]) + { + if ([mi state] == NSOnState) + [self toggleColumn:mi]; + } + //Add columns and set widths + e = [aColumnsOrder objectEnumerator]; + while (colId = [e nextObject]) + { + if (![colId isEqual:@"mark"]) + { + col = [_resultColumns objectAtIndex:[colId intValue]]; + width = [aColumnsWidth objectForKey:[col identifier]]; + mi = [columnsMenu itemWithTag:[colId intValue]]; + if (width) + [col setWidth:[width floatValue]]; + [self toggleColumn:mi]; + } + } +} + +/* Delegate */ +- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item +{ + OVNode *node = item; + if ([[tableColumn identifier] isEqual:@"mark"]) + { + [cell setEnabled: [node isMarkable]]; + } + if ([cell isKindOfClass:[NSTextFieldCell class]]) + { + // Determine if the text color will be blue due to directory being reference. + NSTextFieldCell *textCell = cell; + if ([node isMarkable]) + [textCell setTextColor:[NSColor blackColor]]; + else + [textCell setTextColor:[NSColor blueColor]]; + if ((_displayDelta) && (_powerMode || ([node level] > 1))) + { + int i = [[tableColumn identifier] intValue]; + if ([_deltaColumns containsIndex:i]) + [textCell setTextColor:[NSColor orangeColor]]; + } + } +} + +/* Notifications */ +- (void)duplicateSelectionChanged:(NSNotification *)aNotification +{ + if (_detailsPanel) + [_detailsPanel refresh]; +} + +- (void)jobCompleted:(NSNotification *)aNotification +{ + [super jobCompleted:aNotification]; + id lastAction = [[ProgressController mainProgressController] jobId]; + if ([lastAction isEqualTo:jobScanDeadTracks]) + { + int deadTrackCount = [(PyDupeGuru *)py deadTrackCount]; + if (deadTrackCount > 0) + { + NSString *msg = @"Your iTunes Library contains %d dead tracks ready to be removed. Continue?"; + if ([Dialogs askYesNo:[NSString stringWithFormat:msg,deadTrackCount]] == NSAlertFirstButtonReturn) + [(PyDupeGuru *)py removeDeadTracks]; + } + else + { + [Dialogs showMessage:@"You have no dead tracks in your iTunes Library"]; + } + } +} + +- (void)outlineViewSelectionDidChange:(NSNotification *)notification +{ + [self performPySelection:[self getSelectedPaths:NO]]; + [py refreshDetailsWithSelected]; + [[NSNotificationCenter defaultCenter] postNotificationName:DuplicateSelectionChangedNotification object:self]; +} + +- (void)resultsChanged:(NSNotification *)aNotification +{ + [matches reloadData]; + [self expandAll:nil]; + [self outlineViewSelectionDidChange:nil]; + [self refreshStats]; +} + +- (void)resultsMarkingChanged:(NSNotification *)aNotification +{ + [matches invalidateMarkings]; + [self refreshStats]; +} +@end diff --git a/me/cocoa/dupeguru.icns b/me/cocoa/dupeguru.icns new file mode 100755 index 00000000..42f8641e Binary files /dev/null and b/me/cocoa/dupeguru.icns differ diff --git a/me/cocoa/dupeguru.xcodeproj/hsoft.mode1 b/me/cocoa/dupeguru.xcodeproj/hsoft.mode1 new file mode 100644 index 00000000..fd8387ad --- /dev/null +++ b/me/cocoa/dupeguru.xcodeproj/hsoft.mode1 @@ -0,0 +1,1376 @@ + + + + + ActivePerspectiveName + Project + AllowedModules + + + BundleLoadPath + + MaxInstances + n + Module + PBXSmartGroupTreeModule + Name + Groups and Files Outline View + + + BundleLoadPath + + MaxInstances + n + Module + PBXNavigatorGroup + Name + Editor + + + BundleLoadPath + + MaxInstances + n + Module + XCTaskListModule + Name + Task List + + + BundleLoadPath + + MaxInstances + n + Module + XCDetailModule + Name + File and Smart Group Detail Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXBuildResultsModule + Name + Detailed Build Results Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXProjectFindModule + Name + Project Batch Find Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXRunSessionModule + Name + Run Log + + + BundleLoadPath + + MaxInstances + n + Module + PBXBookmarksModule + Name + Bookmarks Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXClassBrowserModule + Name + Class Browser + + + BundleLoadPath + + MaxInstances + n + Module + PBXCVSModule + Name + Source Code Control Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXDebugBreakpointsModule + Name + Debug Breakpoints Tool + + + BundleLoadPath + + MaxInstances + n + Module + XCDockableInspector + Name + Inspector + + + BundleLoadPath + + MaxInstances + n + Module + PBXOpenQuicklyModule + Name + Open Quickly Tool + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugSessionModule + Name + Debugger + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugCLIModule + Name + Debug Console + + + Description + DefaultDescriptionKey + DockingSystemVisible + + Extension + mode1 + FavBarConfig + + PBXProjectModuleGUID + CE381CB409914B41003581CE + XCBarModuleItemNames + + XCBarModuleItems + + + FirstTimeWindowDisplayed + + Identifier + com.apple.perspectives.project.mode1 + MajorVersion + 31 + MinorVersion + 1 + Name + Default + Notifications + + OpenEditors + + PerspectiveWidths + + -1 + -1 + + Perspectives + + + ChosenToolbarItems + + active-executable-popup + action + active-buildstyle-popup + active-target-popup + buildOrClean + build-and-runOrDebug + com.apple.ide.PBXToolbarStopButton + get-info + toggle-editor + + ControllerClassBaseName + + IconName + WindowOfProjectWithEditor + Identifier + perspective.project + IsVertical + + Layout + + + BecomeActive + + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C08E77C0454961000C914BD + 1C37FABC05509CD000000102 + 1C37FABC05539CD112110102 + E2644B35053B69B200211256 + 1C37FABC04509CD000100104 + 1CC0EA4004350EF90044410B + 1CC0EA4004350EF90041110B + + PBXProjectModuleGUID + 1CE0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 194 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 29B97314FDCFA39411CA2CEA + 080E96DDFE201D6D7F000001 + 29B97315FDCFA39411CA2CEA + 29B97317FDCFA39411CA2CEA + 29B97323FDCFA39411CA2CEA + 1058C7A0FEA54F0111CA2CBB + CE1425880AFB718500BD5167 + 19C28FACFE9D520D11CA2CBB + 1C37FBAC04509CD000000102 + 1C37FABC05509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 37 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {194, 764}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + + XCSharingToken + com.apple.Xcode.GFSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {211, 782}} + GroupTreeTableConfiguration + + MainColumn + 194 + + RubberWindowFrame + 0 55 1372 823 0 0 1440 878 + + Module + PBXSmartGroupTreeModule + Proportion + 211pt + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CE0B20306471E060097A5F4 + PBXProjectModuleLabel + Info.plist + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1CE0B20406471E060097A5F4 + PBXProjectModuleLabel + Info.plist + _historyCapacity + 10 + bookmark + CE6D39470C9B111800C7FE6C + history + + CEEEF20D0BAD825F00F7AD7F + CEEEF3350BAD8AC700F7AD7F + CE7E210C0BB5B7DD00C69A50 + CE7E21360BB5BD8200C69A50 + CEE301FD0BF73B1900D6840C + CEE301FE0BF73B1900D6840C + CEE301FF0BF73B1900D6840C + CEE302000BF73B1900D6840C + CE6D38650C9B0E1A00C7FE6C + CE6D38680C9B0E1A00C7FE6C + + prevStack + + CE2CB4DA09AE70AA0015538F + CE9DA31409E03DC700B0AAC8 + CE962FD809E1A2310049C9D7 + CECD332A09FEDD9D00964507 + CEF3113D0A06AA42002EC022 + CE2AFF3E0A07838000443588 + CEEEF2130BAD825F00F7AD7F + CE6A176E0BB5A8310090A314 + CE6A176F0BB5A8310090A314 + + + SplitCount + 1 + + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {1156, 544}} + RubberWindowFrame + 0 55 1372 823 0 0 1440 878 + + Module + PBXNavigatorGroup + Proportion + 544pt + + + ContentConfiguration + + PBXProjectModuleGUID + 1CE0B20506471E060097A5F4 + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{0, 549}, {1156, 233}} + RubberWindowFrame + 0 55 1372 823 0 0 1440 878 + + Module + XCDetailModule + Proportion + 233pt + + + Proportion + 1156pt + + + Name + Project + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + XCModuleDock + PBXNavigatorGroup + XCDetailModule + + TableOfContents + + CE6D39480C9B111800C7FE6C + 1CE0B1FE06471DED0097A5F4 + CE6D39490C9B111800C7FE6C + 1CE0B20306471E060097A5F4 + 1CE0B20506471E060097A5F4 + + ToolbarConfiguration + xcode.toolbar.config.default + + + ControllerClassBaseName + + IconName + WindowOfProject + Identifier + perspective.morph + IsVertical + 0 + Layout + + + BecomeActive + 1 + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C08E77C0454961000C914BD + 1C37FABC05509CD000000102 + 1C37FABC05539CD112110102 + E2644B35053B69B200211256 + 1C37FABC04509CD000100104 + 1CC0EA4004350EF90044410B + 1CC0EA4004350EF90041110B + + PBXProjectModuleGUID + 11E0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 186 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 29B97314FDCFA39411CA2CEA + 1C37FABC05509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {186, 337}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + 1 + XCSharingToken + com.apple.Xcode.GFSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {203, 355}} + GroupTreeTableConfiguration + + MainColumn + 186 + + RubberWindowFrame + 373 269 690 397 0 0 1440 878 + + Module + PBXSmartGroupTreeModule + Proportion + 100% + + + Name + Morph + PreferredWidth + 300 + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + + TableOfContents + + 11E0B1FE06471DED0097A5F4 + + ToolbarConfiguration + xcode.toolbar.config.default.short + + + PerspectivesBarVisible + + ShelfIsVisible + + SourceDescription + file at '/System/Library/PrivateFrameworks/DevToolsInterface.framework/Versions/A/Resources/XCPerspectivesSpecificationMode1.xcperspec' + StatusbarIsVisible + + TimeStamp + 0.0 + ToolbarDisplayMode + 1 + ToolbarIsVisible + + ToolbarSizeMode + 1 + Type + Perspectives + UpdateMessage + The Default Workspace in this version of Xcode now includes support to hide and show the detail view (what has been referred to as the "Metro-Morph" feature). You must discard your current Default Workspace settings and update to the latest Default Workspace in order to gain this feature. Do you wish to update to the latest Workspace defaults for project '%@'? + WindowJustification + 5 + WindowOrderList + + /Users/hsoft/src/dupeguru_me_cocoa/dupeguru.xcodeproj + + WindowString + 0 55 1372 823 0 0 1440 878 + WindowTools + + + FirstTimeWindowDisplayed + + Identifier + windowTool.build + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CD0528F0623707200166675 + PBXProjectModuleLabel + + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {1024, 404}} + RubberWindowFrame + 289 192 1024 686 0 0 1440 878 + + Module + PBXNavigatorGroup + Proportion + 404pt + + + BecomeActive + + ContentConfiguration + + PBXProjectModuleGUID + XCMainBuildResultsModuleGUID + PBXProjectModuleLabel + Build + XCBuildResultsTrigger_Collapse + 1021 + XCBuildResultsTrigger_Open + 1011 + + GeometryConfiguration + + Frame + {{0, 409}, {1024, 236}} + RubberWindowFrame + 289 192 1024 686 0 0 1440 878 + + Module + PBXBuildResultsModule + Proportion + 236pt + + + Proportion + 645pt + + + Name + Build Results + ServiceClasses + + PBXBuildResultsModule + + StatusbarIsVisible + + TableOfContents + + CE381CCE09914BC8003581CE + CE6D38450C9B0D2500C7FE6C + 1CD0528F0623707200166675 + XCMainBuildResultsModuleGUID + + ToolbarConfiguration + xcode.toolbar.config.build + WindowString + 289 192 1024 686 0 0 1440 878 + WindowToolGUID + CE381CCE09914BC8003581CE + WindowToolIsVisible + + + + FirstTimeWindowDisplayed + + Identifier + windowTool.debugger + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + Debugger + + HorizontalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {150, 322}} + {{150, 0}, {874, 322}} + + + VerticalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {1024, 322}} + {{0, 322}, {1024, 323}} + + + + LauncherConfigVersion + 8 + PBXProjectModuleGUID + 1C162984064C10D400B95A72 + PBXProjectModuleLabel + Debug - GLUTExamples (Underwater) + + GeometryConfiguration + + DebugConsoleDrawerSize + {100, 120} + DebugConsoleVisible + None + DebugConsoleWindowFrame + {{200, 200}, {500, 300}} + DebugSTDIOWindowFrame + {{200, 200}, {500, 300}} + Frame + {{0, 0}, {1024, 645}} + RubberWindowFrame + 348 192 1024 686 0 0 1440 878 + + Module + PBXDebugSessionModule + Proportion + 645pt + + + Proportion + 645pt + + + Name + Debugger + ServiceClasses + + PBXDebugSessionModule + + StatusbarIsVisible + + TableOfContents + + 1CD10A99069EF8BA00B06720 + CE7E21210BB5BCA400C69A50 + 1C162984064C10D400B95A72 + CE7E21220BB5BCA400C69A50 + CE7E21230BB5BCA400C69A50 + CE7E21240BB5BCA400C69A50 + CE7E21250BB5BCA400C69A50 + CE7E21260BB5BCA400C69A50 + CE7E21270BB5BCA400C69A50 + + ToolbarConfiguration + xcode.toolbar.config.debug + WindowString + 348 192 1024 686 0 0 1440 878 + WindowToolGUID + 1CD10A99069EF8BA00B06720 + WindowToolIsVisible + + + + FirstTimeWindowDisplayed + + Identifier + windowTool.find + IsVertical + + Layout + + + Dock + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CDD528C0622207200134675 + PBXProjectModuleLabel + ResultWindow.m + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {1377, 620}} + RubberWindowFrame + 0 0 1377 878 0 0 1440 878 + + Module + PBXNavigatorGroup + Proportion + 1377pt + + + Proportion + 620pt + + + BecomeActive + + ContentConfiguration + + PBXProjectModuleGUID + 1CD0528E0623707200166675 + PBXProjectModuleLabel + Project Find + + GeometryConfiguration + + Frame + {{0, 625}, {1377, 212}} + RubberWindowFrame + 0 0 1377 878 0 0 1440 878 + + Module + PBXProjectFindModule + Proportion + 212pt + + + Proportion + 837pt + + + Name + Project Find + ServiceClasses + + PBXProjectFindModule + + StatusbarIsVisible + + TableOfContents + + 1C530D57069F1CE1000CFCEE + CE6A17790BB5A8310090A314 + CE6A177A0BB5A8310090A314 + 1CDD528C0622207200134675 + 1CD0528E0623707200166675 + + WindowString + 0 0 1377 878 0 0 1440 878 + WindowToolGUID + 1C530D57069F1CE1000CFCEE + WindowToolIsVisible + + + + Identifier + MENUSEPARATOR + + + FirstTimeWindowDisplayed + + Identifier + windowTool.debuggerConsole + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1C78EAAC065D492600B07095 + PBXProjectModuleLabel + Debugger Console + + GeometryConfiguration + + Frame + {{0, 0}, {440, 358}} + RubberWindowFrame + 72 414 440 400 0 0 1440 878 + + Module + PBXDebugCLIModule + Proportion + 358pt + + + Proportion + 359pt + + + Name + Debugger Console + ServiceClasses + + PBXDebugCLIModule + + StatusbarIsVisible + + TableOfContents + + CECD0ADE099294C1003DC359 + CE7E21280BB5BCA400C69A50 + 1C78EAAC065D492600B07095 + + WindowString + 72 414 440 400 0 0 1440 878 + WindowToolGUID + CECD0ADE099294C1003DC359 + WindowToolIsVisible + + + + FirstTimeWindowDisplayed + + Identifier + windowTool.run + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + LauncherConfigVersion + 3 + PBXProjectModuleGUID + 1CD0528B0623707200166675 + PBXProjectModuleLabel + Run + Runner + + HorizontalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {367, 168}} + {{0, 173}, {367, 270}} + + + VerticalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {406, 443}} + {{411, 0}, {517, 443}} + + + + + GeometryConfiguration + + Frame + {{0, 0}, {1024, 645}} + RubberWindowFrame + 262 127 1024 686 0 0 1440 878 + + Module + PBXRunSessionModule + Proportion + 645pt + + + Proportion + 645pt + + + Name + Run Log + ServiceClasses + + PBXRunSessionModule + + StatusbarIsVisible + + TableOfContents + + 1C0AD2B3069F1EA900FABCE6 + CECCEDD50BB6B39F00873A67 + 1CD0528B0623707200166675 + CECCEDD60BB6B39F00873A67 + + ToolbarConfiguration + xcode.toolbar.config.run + WindowString + 262 127 1024 686 0 0 1440 878 + WindowToolGUID + 1C0AD2B3069F1EA900FABCE6 + WindowToolIsVisible + + + + Identifier + windowTool.scm + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1C78EAB2065D492600B07095 + PBXProjectModuleLabel + <No Editor> + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1C78EAB3065D492600B07095 + + SplitCount + 1 + + StatusBarVisibility + 1 + + GeometryConfiguration + + Frame + {{0, 0}, {452, 0}} + RubberWindowFrame + 743 379 452 308 0 0 1280 1002 + + Module + PBXNavigatorGroup + Proportion + 0pt + + + BecomeActive + 1 + ContentConfiguration + + PBXProjectModuleGUID + 1CD052920623707200166675 + PBXProjectModuleLabel + SCM + + GeometryConfiguration + + ConsoleFrame + {{0, 259}, {452, 0}} + Frame + {{0, 7}, {452, 259}} + RubberWindowFrame + 743 379 452 308 0 0 1280 1002 + TableConfiguration + + Status + 30 + FileName + 199 + Path + 197.09500122070312 + + TableFrame + {{0, 0}, {452, 250}} + + Module + PBXCVSModule + Proportion + 262pt + + + Proportion + 266pt + + + Name + SCM + ServiceClasses + + PBXCVSModule + + StatusbarIsVisible + 1 + TableOfContents + + 1C78EAB4065D492600B07095 + 1C78EAB5065D492600B07095 + 1C78EAB2065D492600B07095 + 1CD052920623707200166675 + + ToolbarConfiguration + xcode.toolbar.config.scm + WindowString + 743 379 452 308 0 0 1280 1002 + + + FirstTimeWindowDisplayed + + Identifier + windowTool.breakpoints + IsVertical + + Layout + + + Dock + + + BecomeActive + + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C77FABC04509CD000000102 + + PBXProjectModuleGUID + 1CE0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + no + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 168 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 1C77FABC04509CD000000102 + 1C3E0DCA080725EA00A55177 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 2 + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {168, 350}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + + + GeometryConfiguration + + Frame + {{0, 0}, {185, 368}} + GroupTreeTableConfiguration + + MainColumn + 168 + + RubberWindowFrame + 52 435 744 409 0 0 1440 878 + + Module + PBXSmartGroupTreeModule + Proportion + 185pt + + + ContentConfiguration + + PBXProjectModuleGUID + 1CA1AED706398EBD00589147 + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{190, 0}, {554, 368}} + RubberWindowFrame + 52 435 744 409 0 0 1440 878 + + Module + XCDetailModule + Proportion + 554pt + + + Proportion + 368pt + + + MajorVersion + 2 + MinorVersion + 0 + Name + Breakpoints + ServiceClasses + + PBXSmartGroupTreeModule + XCDetailModule + + StatusbarIsVisible + + TableOfContents + + CE6B28F20AFB890700508D93 + CE6B28F30AFB890700508D93 + 1CE0B1FE06471DED0097A5F4 + 1CA1AED706398EBD00589147 + + ToolbarConfiguration + xcode.toolbar.config.breakpoints + WindowString + 52 435 744 409 0 0 1440 878 + WindowToolGUID + CE6B28F20AFB890700508D93 + WindowToolIsVisible + + + + Identifier + windowTool.debugAnimator + Layout + + + Dock + + + Module + PBXNavigatorGroup + Proportion + 100% + + + Proportion + 100% + + + Name + Debug Visualizer + ServiceClasses + + PBXNavigatorGroup + + StatusbarIsVisible + 1 + ToolbarConfiguration + xcode.toolbar.config.debugAnimator + WindowString + 100 100 700 500 0 0 1280 1002 + + + Identifier + windowTool.bookmarks + Layout + + + Dock + + + Module + PBXBookmarksModule + Proportion + 100% + + + Proportion + 100% + + + Name + Bookmarks + ServiceClasses + + PBXBookmarksModule + + StatusbarIsVisible + 0 + WindowString + 538 42 401 187 0 0 1280 1002 + + + Identifier + windowTool.classBrowser + Layout + + + Dock + + + BecomeActive + 1 + ContentConfiguration + + OptionsSetName + Hierarchy, all classes + PBXProjectModuleGUID + 1CA6456E063B45B4001379D8 + PBXProjectModuleLabel + Class Browser - NSObject + + GeometryConfiguration + + ClassesFrame + {{0, 0}, {374, 96}} + ClassesTreeTableConfiguration + + PBXClassNameColumnIdentifier + 208 + PBXClassBookColumnIdentifier + 22 + + Frame + {{0, 0}, {630, 331}} + MembersFrame + {{0, 105}, {374, 395}} + MembersTreeTableConfiguration + + PBXMemberTypeIconColumnIdentifier + 22 + PBXMemberNameColumnIdentifier + 216 + PBXMemberTypeColumnIdentifier + 97 + PBXMemberBookColumnIdentifier + 22 + + PBXModuleWindowStatusBarHidden2 + 1 + RubberWindowFrame + 385 179 630 352 0 0 1440 878 + + Module + PBXClassBrowserModule + Proportion + 332pt + + + Proportion + 332pt + + + Name + Class Browser + ServiceClasses + + PBXClassBrowserModule + + StatusbarIsVisible + 0 + TableOfContents + + 1C0AD2AF069F1E9B00FABCE6 + 1C0AD2B0069F1E9B00FABCE6 + 1CA6456E063B45B4001379D8 + + ToolbarConfiguration + xcode.toolbar.config.classbrowser + WindowString + 385 179 630 352 0 0 1440 878 + WindowToolGUID + 1C0AD2AF069F1E9B00FABCE6 + WindowToolIsVisible + 0 + + + + diff --git a/me/cocoa/dupeguru.xcodeproj/project.pbxproj b/me/cocoa/dupeguru.xcodeproj/project.pbxproj new file mode 100644 index 00000000..da9f71bb --- /dev/null +++ b/me/cocoa/dupeguru.xcodeproj/project.pbxproj @@ -0,0 +1,563 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 44; + objects = { + +/* Begin PBXAppleScriptBuildPhase section */ + CE6B288A0AFB7FC900508D93 /* AppleScript */ = { + isa = PBXAppleScriptBuildPhase; + buildActionMask = 2147483647; + contextName = ""; + files = ( + ); + isSharedContext = 0; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXAppleScriptBuildPhase section */ + +/* Begin PBXBuildFile section */ + 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; }; + 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; + 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; + 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; + CE073F6309CAE1A3005C1D2F /* dupeguru_me_help in Resources */ = {isa = PBXBuildFile; fileRef = CE073F5409CAE1A3005C1D2F /* dupeguru_me_help */; }; + CE12149E0AC86DB900E93983 /* dg.xsl in Resources */ = {isa = PBXBuildFile; fileRef = CE12149C0AC86DB900E93983 /* dg.xsl */; }; + CE12149F0AC86DB900E93983 /* hardcoded.css in Resources */ = {isa = PBXBuildFile; fileRef = CE12149D0AC86DB900E93983 /* hardcoded.css */; }; + CE1425890AFB718500BD5167 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE1425880AFB718500BD5167 /* Sparkle.framework */; }; + CE14259F0AFB719300BD5167 /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CE1425880AFB718500BD5167 /* Sparkle.framework */; }; + CE381C9609914ACE003581CE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CE381C9409914ACE003581CE /* AppDelegate.m */; }; + CE381C9C09914ADF003581CE /* ResultWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CE381C9A09914ADF003581CE /* ResultWindow.m */; }; + CE381D0509915304003581CE /* dg_cocoa.plugin in Resources */ = {isa = PBXBuildFile; fileRef = CE381CF509915304003581CE /* dg_cocoa.plugin */; }; + CE3AA46709DB207900DB3A21 /* Directories.nib in Resources */ = {isa = PBXBuildFile; fileRef = CE3AA46509DB207900DB3A21 /* Directories.nib */; }; + CE515DF30FC6C12E00EC695D /* Dialogs.m in Sources */ = {isa = PBXBuildFile; fileRef = CE515DE10FC6C12E00EC695D /* Dialogs.m */; }; + CE515DF40FC6C12E00EC695D /* HSErrorReportWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CE515DE30FC6C12E00EC695D /* HSErrorReportWindow.m */; }; + CE515DF50FC6C12E00EC695D /* Outline.m in Sources */ = {isa = PBXBuildFile; fileRef = CE515DE50FC6C12E00EC695D /* Outline.m */; }; + CE515DF60FC6C12E00EC695D /* ProgressController.m in Sources */ = {isa = PBXBuildFile; fileRef = CE515DE70FC6C12E00EC695D /* ProgressController.m */; }; + CE515DF70FC6C12E00EC695D /* RecentDirectories.m in Sources */ = {isa = PBXBuildFile; fileRef = CE515DEA0FC6C12E00EC695D /* RecentDirectories.m */; }; + CE515DF80FC6C12E00EC695D /* RegistrationInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = CE515DEC0FC6C12E00EC695D /* RegistrationInterface.m */; }; + CE515DF90FC6C12E00EC695D /* Table.m in Sources */ = {isa = PBXBuildFile; fileRef = CE515DEE0FC6C12E00EC695D /* Table.m */; }; + CE515DFA0FC6C12E00EC695D /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = CE515DF00FC6C12E00EC695D /* Utils.m */; }; + CE515DFB0FC6C12E00EC695D /* ValueTransformers.m in Sources */ = {isa = PBXBuildFile; fileRef = CE515DF20FC6C12E00EC695D /* ValueTransformers.m */; }; + CE515E020FC6C13E00EC695D /* ErrorReportWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE515DFC0FC6C13E00EC695D /* ErrorReportWindow.xib */; }; + CE515E030FC6C13E00EC695D /* progress.nib in Resources */ = {isa = PBXBuildFile; fileRef = CE515DFE0FC6C13E00EC695D /* progress.nib */; }; + CE515E040FC6C13E00EC695D /* registration.nib in Resources */ = {isa = PBXBuildFile; fileRef = CE515E000FC6C13E00EC695D /* registration.nib */; }; + CE515E1D0FC6C19300EC695D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CE515E160FC6C19300EC695D /* AppDelegate.m */; }; + CE515E1E0FC6C19300EC695D /* DirectoryPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = CE515E190FC6C19300EC695D /* DirectoryPanel.m */; }; + CE515E1F0FC6C19300EC695D /* ResultWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CE515E1C0FC6C19300EC695D /* ResultWindow.m */; }; + CE68EE6809ABC48000971085 /* DirectoryPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = CE68EE6609ABC48000971085 /* DirectoryPanel.m */; }; + CE848A1909DD85810004CB44 /* Consts.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = CE848A1809DD85810004CB44 /* Consts.h */; }; + CECA899909DB12CA00A3D774 /* Details.nib in Resources */ = {isa = PBXBuildFile; fileRef = CECA899709DB12CA00A3D774 /* Details.nib */; }; + CECA899C09DB132E00A3D774 /* DetailsPanel.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = CECA899A09DB132E00A3D774 /* DetailsPanel.h */; }; + CECA899D09DB132E00A3D774 /* DetailsPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = CECA899B09DB132E00A3D774 /* DetailsPanel.m */; }; + CED2A6880A05102700AC4C3F /* power_marker32.png in Resources */ = {isa = PBXBuildFile; fileRef = CED2A6870A05102600AC4C3F /* power_marker32.png */; }; + CED2A6970A05128900AC4C3F /* dgme_logo32.png in Resources */ = {isa = PBXBuildFile; fileRef = CED2A6960A05128900AC4C3F /* dgme_logo32.png */; }; + CEEB135209C837A2004D2330 /* dupeguru.icns in Resources */ = {isa = PBXBuildFile; fileRef = CEEB135109C837A2004D2330 /* dupeguru.icns */; }; + CEF7823809C8AA0200EF38FF /* gear.png in Resources */ = {isa = PBXBuildFile; fileRef = CEF7823709C8AA0200EF38FF /* gear.png */; }; + CEFC294609C89E3D00D9F998 /* folder32.png in Resources */ = {isa = PBXBuildFile; fileRef = CEFC294509C89E3D00D9F998 /* folder32.png */; }; + CEFC295509C89FF200D9F998 /* details32.png in Resources */ = {isa = PBXBuildFile; fileRef = CEFC295309C89FF200D9F998 /* details32.png */; }; + CEFC295609C89FF200D9F998 /* preferences32.png in Resources */ = {isa = PBXBuildFile; fileRef = CEFC295409C89FF200D9F998 /* preferences32.png */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + CECC02B709A36E8200CC0A94 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + CE14259F0AFB719300BD5167 /* Sparkle.framework in CopyFiles */, + CECA899C09DB132E00A3D774 /* DetailsPanel.h in CopyFiles */, + CE848A1909DD85810004CB44 /* Consts.h in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; + 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; + 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; + 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; }; + 29B97319FDCFA39411CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/MainMenu.nib; sourceTree = ""; }; + 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; + 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; + 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; }; + 8D1107320486CEB800E47090 /* dupeGuru ME.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "dupeGuru ME.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + CE073F5409CAE1A3005C1D2F /* dupeguru_me_help */ = {isa = PBXFileReference; lastKnownFileType = folder; name = dupeguru_me_help; path = help/dupeguru_me_help; sourceTree = ""; }; + CE12149C0AC86DB900E93983 /* dg.xsl */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text.xml; name = dg.xsl; path = w3/dg.xsl; sourceTree = SOURCE_ROOT; }; + CE12149D0AC86DB900E93983 /* hardcoded.css */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text; name = hardcoded.css; path = w3/hardcoded.css; sourceTree = SOURCE_ROOT; }; + CE1425880AFB718500BD5167 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = /Library/Frameworks/Sparkle.framework; sourceTree = ""; }; + CE381C9409914ACE003581CE /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = SOURCE_ROOT; }; + CE381C9509914ACE003581CE /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = SOURCE_ROOT; }; + CE381C9A09914ADF003581CE /* ResultWindow.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = ResultWindow.m; sourceTree = SOURCE_ROOT; }; + CE381C9B09914ADF003581CE /* ResultWindow.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = ResultWindow.h; sourceTree = SOURCE_ROOT; }; + CE381CF509915304003581CE /* dg_cocoa.plugin */ = {isa = PBXFileReference; lastKnownFileType = folder; name = dg_cocoa.plugin; path = py/dist/dg_cocoa.plugin; sourceTree = SOURCE_ROOT; }; + CE3AA46609DB207900DB3A21 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/Directories.nib; sourceTree = ""; }; + CE515DE00FC6C12E00EC695D /* Dialogs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Dialogs.h; path = cocoalib/Dialogs.h; sourceTree = SOURCE_ROOT; }; + CE515DE10FC6C12E00EC695D /* Dialogs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Dialogs.m; path = cocoalib/Dialogs.m; sourceTree = SOURCE_ROOT; }; + CE515DE20FC6C12E00EC695D /* HSErrorReportWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HSErrorReportWindow.h; path = cocoalib/HSErrorReportWindow.h; sourceTree = SOURCE_ROOT; }; + CE515DE30FC6C12E00EC695D /* HSErrorReportWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HSErrorReportWindow.m; path = cocoalib/HSErrorReportWindow.m; sourceTree = SOURCE_ROOT; }; + CE515DE40FC6C12E00EC695D /* Outline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Outline.h; path = cocoalib/Outline.h; sourceTree = SOURCE_ROOT; }; + CE515DE50FC6C12E00EC695D /* Outline.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Outline.m; path = cocoalib/Outline.m; sourceTree = SOURCE_ROOT; }; + CE515DE60FC6C12E00EC695D /* ProgressController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ProgressController.h; path = cocoalib/ProgressController.h; sourceTree = SOURCE_ROOT; }; + CE515DE70FC6C12E00EC695D /* ProgressController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ProgressController.m; path = cocoalib/ProgressController.m; sourceTree = SOURCE_ROOT; }; + CE515DE80FC6C12E00EC695D /* PyApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PyApp.h; path = cocoalib/PyApp.h; sourceTree = SOURCE_ROOT; }; + CE515DE90FC6C12E00EC695D /* RecentDirectories.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RecentDirectories.h; path = cocoalib/RecentDirectories.h; sourceTree = SOURCE_ROOT; }; + CE515DEA0FC6C12E00EC695D /* RecentDirectories.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RecentDirectories.m; path = cocoalib/RecentDirectories.m; sourceTree = SOURCE_ROOT; }; + CE515DEB0FC6C12E00EC695D /* RegistrationInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegistrationInterface.h; path = cocoalib/RegistrationInterface.h; sourceTree = SOURCE_ROOT; }; + CE515DEC0FC6C12E00EC695D /* RegistrationInterface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RegistrationInterface.m; path = cocoalib/RegistrationInterface.m; sourceTree = SOURCE_ROOT; }; + CE515DED0FC6C12E00EC695D /* Table.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Table.h; path = cocoalib/Table.h; sourceTree = SOURCE_ROOT; }; + CE515DEE0FC6C12E00EC695D /* Table.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Table.m; path = cocoalib/Table.m; sourceTree = SOURCE_ROOT; }; + CE515DEF0FC6C12E00EC695D /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Utils.h; path = cocoalib/Utils.h; sourceTree = SOURCE_ROOT; }; + CE515DF00FC6C12E00EC695D /* Utils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Utils.m; path = cocoalib/Utils.m; sourceTree = SOURCE_ROOT; }; + CE515DF10FC6C12E00EC695D /* ValueTransformers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueTransformers.h; path = cocoalib/ValueTransformers.h; sourceTree = SOURCE_ROOT; }; + CE515DF20FC6C12E00EC695D /* ValueTransformers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ValueTransformers.m; path = cocoalib/ValueTransformers.m; sourceTree = SOURCE_ROOT; }; + CE515DFD0FC6C13E00EC695D /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = cocoalib/English.lproj/ErrorReportWindow.xib; sourceTree = ""; }; + CE515DFF0FC6C13E00EC695D /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = cocoalib/English.lproj/progress.nib; sourceTree = ""; }; + CE515E010FC6C13E00EC695D /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = cocoalib/English.lproj/registration.nib; sourceTree = ""; }; + CE515E150FC6C19300EC695D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = dgbase/AppDelegate.h; sourceTree = SOURCE_ROOT; }; + CE515E160FC6C19300EC695D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = dgbase/AppDelegate.m; sourceTree = SOURCE_ROOT; }; + CE515E170FC6C19300EC695D /* Consts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Consts.h; path = dgbase/Consts.h; sourceTree = SOURCE_ROOT; }; + CE515E180FC6C19300EC695D /* DirectoryPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DirectoryPanel.h; path = dgbase/DirectoryPanel.h; sourceTree = SOURCE_ROOT; }; + CE515E190FC6C19300EC695D /* DirectoryPanel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DirectoryPanel.m; path = dgbase/DirectoryPanel.m; sourceTree = SOURCE_ROOT; }; + CE515E1A0FC6C19300EC695D /* PyDupeGuru.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PyDupeGuru.h; path = dgbase/PyDupeGuru.h; sourceTree = SOURCE_ROOT; }; + CE515E1B0FC6C19300EC695D /* ResultWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ResultWindow.h; path = dgbase/ResultWindow.h; sourceTree = SOURCE_ROOT; }; + CE515E1C0FC6C19300EC695D /* ResultWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ResultWindow.m; path = dgbase/ResultWindow.m; sourceTree = SOURCE_ROOT; }; + CE68EE6509ABC48000971085 /* DirectoryPanel.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = DirectoryPanel.h; sourceTree = SOURCE_ROOT; }; + CE68EE6609ABC48000971085 /* DirectoryPanel.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = DirectoryPanel.m; sourceTree = SOURCE_ROOT; }; + CE848A1809DD85810004CB44 /* Consts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Consts.h; sourceTree = ""; }; + CECA899809DB12CA00A3D774 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/Details.nib; sourceTree = ""; }; + CECA899A09DB132E00A3D774 /* DetailsPanel.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = DetailsPanel.h; sourceTree = ""; }; + CECA899B09DB132E00A3D774 /* DetailsPanel.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = DetailsPanel.m; sourceTree = ""; }; + CED2A6870A05102600AC4C3F /* power_marker32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = power_marker32.png; path = images/power_marker32.png; sourceTree = SOURCE_ROOT; }; + CED2A6960A05128900AC4C3F /* dgme_logo32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = dgme_logo32.png; path = images/dgme_logo32.png; sourceTree = SOURCE_ROOT; }; + CEEB135109C837A2004D2330 /* dupeguru.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = dupeguru.icns; sourceTree = ""; }; + CEF7823709C8AA0200EF38FF /* gear.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = gear.png; path = images/gear.png; sourceTree = ""; }; + CEFC294509C89E3D00D9F998 /* folder32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = folder32.png; path = images/folder32.png; sourceTree = SOURCE_ROOT; }; + CEFC295309C89FF200D9F998 /* details32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = details32.png; path = images/details32.png; sourceTree = SOURCE_ROOT; }; + CEFC295409C89FF200D9F998 /* preferences32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = preferences32.png; path = images/preferences32.png; sourceTree = SOURCE_ROOT; }; + CEFF18A009A4D387005E6321 /* PyDupeGuru.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = PyDupeGuru.h; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8D11072E0486CEB800E47090 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, + CE1425890AFB718500BD5167 /* Sparkle.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 080E96DDFE201D6D7F000001 /* Classes */ = { + isa = PBXGroup; + children = ( + CE381C9509914ACE003581CE /* AppDelegate.h */, + CE381C9409914ACE003581CE /* AppDelegate.m */, + CE848A1809DD85810004CB44 /* Consts.h */, + CECA899A09DB132E00A3D774 /* DetailsPanel.h */, + CECA899B09DB132E00A3D774 /* DetailsPanel.m */, + CE68EE6509ABC48000971085 /* DirectoryPanel.h */, + CE68EE6609ABC48000971085 /* DirectoryPanel.m */, + CEFF18A009A4D387005E6321 /* PyDupeGuru.h */, + CE381C9B09914ADF003581CE /* ResultWindow.h */, + CE381C9A09914ADF003581CE /* ResultWindow.m */, + ); + name = Classes; + sourceTree = ""; + }; + 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = { + isa = PBXGroup; + children = ( + CE1425880AFB718500BD5167 /* Sparkle.framework */, + 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */, + ); + name = "Linked Frameworks"; + sourceTree = ""; + }; + 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 29B97324FDCFA39411CA2CEA /* AppKit.framework */, + 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */, + 29B97325FDCFA39411CA2CEA /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; + 19C28FACFE9D520D11CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 8D1107320486CEB800E47090 /* dupeGuru ME.app */, + ); + name = Products; + sourceTree = ""; + }; + 29B97314FDCFA39411CA2CEA /* dupeguru */ = { + isa = PBXGroup; + children = ( + 080E96DDFE201D6D7F000001 /* Classes */, + CE515E140FC6C17900EC695D /* dgbase */, + CE515DDD0FC6C09400EC695D /* cocoalib */, + 29B97315FDCFA39411CA2CEA /* Other Sources */, + 29B97317FDCFA39411CA2CEA /* Resources */, + 29B97323FDCFA39411CA2CEA /* Frameworks */, + 19C28FACFE9D520D11CA2CBB /* Products */, + ); + name = dupeguru; + sourceTree = ""; + }; + 29B97315FDCFA39411CA2CEA /* Other Sources */ = { + isa = PBXGroup; + children = ( + 29B97316FDCFA39411CA2CEA /* main.m */, + ); + name = "Other Sources"; + sourceTree = ""; + }; + 29B97317FDCFA39411CA2CEA /* Resources */ = { + isa = PBXGroup; + children = ( + CE073F5409CAE1A3005C1D2F /* dupeguru_me_help */, + CE381CF509915304003581CE /* dg_cocoa.plugin */, + CEFC294309C89E0000D9F998 /* images */, + CE12149B0AC86DB900E93983 /* w3 */, + CEEB135109C837A2004D2330 /* dupeguru.icns */, + 8D1107310486CEB800E47090 /* Info.plist */, + 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */, + CECA899709DB12CA00A3D774 /* Details.nib */, + CE3AA46509DB207900DB3A21 /* Directories.nib */, + 29B97318FDCFA39411CA2CEA /* MainMenu.nib */, + ); + name = Resources; + sourceTree = ""; + }; + 29B97323FDCFA39411CA2CEA /* Frameworks */ = { + isa = PBXGroup; + children = ( + 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */, + 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */, + ); + name = Frameworks; + sourceTree = ""; + }; + CE12149B0AC86DB900E93983 /* w3 */ = { + isa = PBXGroup; + children = ( + CE12149C0AC86DB900E93983 /* dg.xsl */, + CE12149D0AC86DB900E93983 /* hardcoded.css */, + ); + path = w3; + sourceTree = SOURCE_ROOT; + }; + CE515DDD0FC6C09400EC695D /* cocoalib */ = { + isa = PBXGroup; + children = ( + CE515DFC0FC6C13E00EC695D /* ErrorReportWindow.xib */, + CE515DFE0FC6C13E00EC695D /* progress.nib */, + CE515E000FC6C13E00EC695D /* registration.nib */, + CE515DE00FC6C12E00EC695D /* Dialogs.h */, + CE515DE10FC6C12E00EC695D /* Dialogs.m */, + CE515DE20FC6C12E00EC695D /* HSErrorReportWindow.h */, + CE515DE30FC6C12E00EC695D /* HSErrorReportWindow.m */, + CE515DE40FC6C12E00EC695D /* Outline.h */, + CE515DE50FC6C12E00EC695D /* Outline.m */, + CE515DE60FC6C12E00EC695D /* ProgressController.h */, + CE515DE70FC6C12E00EC695D /* ProgressController.m */, + CE515DE80FC6C12E00EC695D /* PyApp.h */, + CE515DE90FC6C12E00EC695D /* RecentDirectories.h */, + CE515DEA0FC6C12E00EC695D /* RecentDirectories.m */, + CE515DEB0FC6C12E00EC695D /* RegistrationInterface.h */, + CE515DEC0FC6C12E00EC695D /* RegistrationInterface.m */, + CE515DED0FC6C12E00EC695D /* Table.h */, + CE515DEE0FC6C12E00EC695D /* Table.m */, + CE515DEF0FC6C12E00EC695D /* Utils.h */, + CE515DF00FC6C12E00EC695D /* Utils.m */, + CE515DF10FC6C12E00EC695D /* ValueTransformers.h */, + CE515DF20FC6C12E00EC695D /* ValueTransformers.m */, + ); + name = cocoalib; + sourceTree = ""; + }; + CE515E140FC6C17900EC695D /* dgbase */ = { + isa = PBXGroup; + children = ( + CE515E150FC6C19300EC695D /* AppDelegate.h */, + CE515E160FC6C19300EC695D /* AppDelegate.m */, + CE515E170FC6C19300EC695D /* Consts.h */, + CE515E180FC6C19300EC695D /* DirectoryPanel.h */, + CE515E190FC6C19300EC695D /* DirectoryPanel.m */, + CE515E1A0FC6C19300EC695D /* PyDupeGuru.h */, + CE515E1B0FC6C19300EC695D /* ResultWindow.h */, + CE515E1C0FC6C19300EC695D /* ResultWindow.m */, + ); + name = dgbase; + sourceTree = ""; + }; + CEFC294309C89E0000D9F998 /* images */ = { + isa = PBXGroup; + children = ( + CED2A6960A05128900AC4C3F /* dgme_logo32.png */, + CED2A6870A05102600AC4C3F /* power_marker32.png */, + CEF7823709C8AA0200EF38FF /* gear.png */, + CEFC295309C89FF200D9F998 /* details32.png */, + CEFC295409C89FF200D9F998 /* preferences32.png */, + CEFC294509C89E3D00D9F998 /* folder32.png */, + ); + name = images; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8D1107260486CEB800E47090 /* dupeguru */ = { + isa = PBXNativeTarget; + buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "dupeguru" */; + buildPhases = ( + 8D1107290486CEB800E47090 /* Resources */, + 8D11072C0486CEB800E47090 /* Sources */, + 8D11072E0486CEB800E47090 /* Frameworks */, + CECC02B709A36E8200CC0A94 /* CopyFiles */, + CE6B288A0AFB7FC900508D93 /* AppleScript */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = dupeguru; + productInstallPath = "$(HOME)/Applications"; + productName = dupeguru; + productReference = 8D1107320486CEB800E47090 /* dupeGuru ME.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 29B97313FDCFA39411CA2CEA /* Project object */ = { + isa = PBXProject; + buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "dupeguru" */; + compatibilityVersion = "Xcode 3.0"; + hasScannedForEncodings = 1; + mainGroup = 29B97314FDCFA39411CA2CEA /* dupeguru */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8D1107260486CEB800E47090 /* dupeguru */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8D1107290486CEB800E47090 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */, + 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */, + CE381D0509915304003581CE /* dg_cocoa.plugin in Resources */, + CE073F6309CAE1A3005C1D2F /* dupeguru_me_help in Resources */, + CEEB135209C837A2004D2330 /* dupeguru.icns in Resources */, + CEFC294609C89E3D00D9F998 /* folder32.png in Resources */, + CEFC295509C89FF200D9F998 /* details32.png in Resources */, + CEFC295609C89FF200D9F998 /* preferences32.png in Resources */, + CEF7823809C8AA0200EF38FF /* gear.png in Resources */, + CECA899909DB12CA00A3D774 /* Details.nib in Resources */, + CE3AA46709DB207900DB3A21 /* Directories.nib in Resources */, + CED2A6880A05102700AC4C3F /* power_marker32.png in Resources */, + CED2A6970A05128900AC4C3F /* dgme_logo32.png in Resources */, + CE12149E0AC86DB900E93983 /* dg.xsl in Resources */, + CE12149F0AC86DB900E93983 /* hardcoded.css in Resources */, + CE515E020FC6C13E00EC695D /* ErrorReportWindow.xib in Resources */, + CE515E030FC6C13E00EC695D /* progress.nib in Resources */, + CE515E040FC6C13E00EC695D /* registration.nib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8D11072C0486CEB800E47090 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D11072D0486CEB800E47090 /* main.m in Sources */, + CE381C9609914ACE003581CE /* AppDelegate.m in Sources */, + CE381C9C09914ADF003581CE /* ResultWindow.m in Sources */, + CE68EE6809ABC48000971085 /* DirectoryPanel.m in Sources */, + CECA899D09DB132E00A3D774 /* DetailsPanel.m in Sources */, + CE515DF30FC6C12E00EC695D /* Dialogs.m in Sources */, + CE515DF40FC6C12E00EC695D /* HSErrorReportWindow.m in Sources */, + CE515DF50FC6C12E00EC695D /* Outline.m in Sources */, + CE515DF60FC6C12E00EC695D /* ProgressController.m in Sources */, + CE515DF70FC6C12E00EC695D /* RecentDirectories.m in Sources */, + CE515DF80FC6C12E00EC695D /* RegistrationInterface.m in Sources */, + CE515DF90FC6C12E00EC695D /* Table.m in Sources */, + CE515DFA0FC6C12E00EC695D /* Utils.m in Sources */, + CE515DFB0FC6C12E00EC695D /* ValueTransformers.m in Sources */, + CE515E1D0FC6C19300EC695D /* AppDelegate.m in Sources */, + CE515E1E0FC6C19300EC695D /* DirectoryPanel.m in Sources */, + CE515E1F0FC6C19300EC695D /* ResultWindow.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 089C165DFE840E0CC02AAC07 /* English */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + 29B97318FDCFA39411CA2CEA /* MainMenu.nib */ = { + isa = PBXVariantGroup; + children = ( + 29B97319FDCFA39411CA2CEA /* English */, + ); + name = MainMenu.nib; + sourceTree = SOURCE_ROOT; + }; + CE3AA46509DB207900DB3A21 /* Directories.nib */ = { + isa = PBXVariantGroup; + children = ( + CE3AA46609DB207900DB3A21 /* English */, + ); + name = Directories.nib; + sourceTree = ""; + }; + CE515DFC0FC6C13E00EC695D /* ErrorReportWindow.xib */ = { + isa = PBXVariantGroup; + children = ( + CE515DFD0FC6C13E00EC695D /* English */, + ); + name = ErrorReportWindow.xib; + sourceTree = SOURCE_ROOT; + }; + CE515DFE0FC6C13E00EC695D /* progress.nib */ = { + isa = PBXVariantGroup; + children = ( + CE515DFF0FC6C13E00EC695D /* English */, + ); + name = progress.nib; + sourceTree = SOURCE_ROOT; + }; + CE515E000FC6C13E00EC695D /* registration.nib */ = { + isa = PBXVariantGroup; + children = ( + CE515E010FC6C13E00EC695D /* English */, + ); + name = registration.nib; + sourceTree = SOURCE_ROOT; + }; + CECA899709DB12CA00A3D774 /* Details.nib */ = { + isa = PBXVariantGroup; + children = ( + CECA899809DB12CA00A3D774 /* English */, + ); + name = Details.nib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + C01FCF4B08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(FRAMEWORK_SEARCH_PATHS)", + "$(SRCROOT)/../../../cocoalib/build/Release", + "\"$(SRCROOT)/../../base/cocoa/build/Release\"", + ); + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Applications"; + PRODUCT_NAME = dupeGuru; + WRAPPER_EXTENSION = app; + ZERO_LINK = YES; + }; + name = Debug; + }; + C01FCF4C08A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ( + "$(FRAMEWORK_SEARCH_PATHS)", + "$(SRCROOT)/../../../cocoalib/build/Release", + "\"$(SRCROOT)/../../base/cocoa/build/Release\"", + ); + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_MODEL_TUNING = G5; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Applications"; + PRODUCT_NAME = "dupeGuru ME"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; + C01FCF4F08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_C_LANGUAGE_STANDARD = c99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.4; + PREBINDING = NO; + SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; + }; + name = Debug; + }; + C01FCF5008A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + i386, + ppc, + ); + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.4; + PREBINDING = NO; + SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; + STRIP_INSTALLED_PRODUCT = NO; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "dupeguru" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4B08A954540054247B /* Debug */, + C01FCF4C08A954540054247B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C01FCF4E08A954540054247B /* Build configuration list for PBXProject "dupeguru" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4F08A954540054247B /* Debug */, + C01FCF5008A954540054247B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; +} diff --git a/me/cocoa/gen.py b/me/cocoa/gen.py new file mode 100644 index 00000000..45ae1e20 --- /dev/null +++ b/me/cocoa/gen.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +import os + +print "Generating help" +os.chdir('help') +os.system('python -u gen.py') +os.system('/Developer/Applications/Utilities/Help\\ Indexer.app/Contents/MacOS/Help\\ Indexer dupeguru_me_help') +os.chdir('..') + +print "Generating py plugin" +os.chdir('py') +os.system('python -u gen.py') +os.chdir('..') \ No newline at end of file diff --git a/me/cocoa/main.m b/me/cocoa/main.m new file mode 100644 index 00000000..c5f30658 --- /dev/null +++ b/me/cocoa/main.m @@ -0,0 +1,21 @@ +// +// main.m +// dupeguru +// +// Created by Virgil Dupras on 2006/02/01. +// Copyright __MyCompanyName__ 2006. All rights reserved. +// + +#import + +int main(int argc, char *argv[]) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSString *pluginPath = [[NSBundle mainBundle] + pathForResource:@"dg_cocoa" + ofType:@"plugin"]; + NSBundle *pluginBundle = [NSBundle bundleWithPath:pluginPath]; + [pluginBundle load]; + [pool release]; + return NSApplicationMain(argc, (const char **) argv); +} diff --git a/me/cocoa/py/dg_cocoa.py b/me/cocoa/py/dg_cocoa.py new file mode 100644 index 00000000..53413c71 --- /dev/null +++ b/me/cocoa/py/dg_cocoa.py @@ -0,0 +1,225 @@ +#!/usr/bin/env python +import objc +from AppKit import * + +from dupeguru import app_me_cocoa, scanner + +# Fix py2app imports which chokes on relative imports +from dupeguru import app, app_cocoa, data, directories, engine, export, ignore, results, scanner +from hsfs import auto, manual, stats, tree, utils, music +from hsfs.phys import music +from hsmedia import aiff, flac, genres, id3v1, id3v2, mp4, mpeg, ogg, wma + +class PyApp(NSObject): + pass #fake class + +class PyDupeGuru(PyApp): + def init(self): + self = super(PyDupeGuru,self).init() + self.app = app_me_cocoa.DupeGuruME() + return self + + #---Directories + def addDirectory_(self,directory): + return self.app.AddDirectory(directory) + + def removeDirectory_(self,index): + self.app.RemoveDirectory(index) + + def setDirectory_state_(self,node_path,state): + self.app.SetDirectoryState(node_path,state) + + #---Results + def clearIgnoreList(self): + self.app.scanner.ignore_list.Clear() + + def doScan(self): + return self.app.start_scanning() + + def exportToXHTMLwithColumns_xslt_css_(self,column_ids,xslt_path,css_path): + return self.app.ExportToXHTML(column_ids,xslt_path,css_path) + + def loadIgnoreList(self): + self.app.LoadIgnoreList() + + def loadResults(self): + self.app.load() + + def markAll(self): + self.app.results.mark_all() + + def markNone(self): + self.app.results.mark_none() + + def markInvert(self): + self.app.results.mark_invert() + + def purgeIgnoreList(self): + self.app.PurgeIgnoreList() + + def toggleSelectedMark(self): + self.app.ToggleSelectedMarkState() + + def saveIgnoreList(self): + self.app.SaveIgnoreList() + + def saveResults(self): + self.app.Save() + + def refreshDetailsWithSelected(self): + self.app.RefreshDetailsWithSelected() + + def selectResultNodePaths_(self,node_paths): + self.app.SelectResultNodePaths(node_paths) + + def selectPowerMarkerNodePaths_(self,node_paths): + self.app.SelectPowerMarkerNodePaths(node_paths) + + #---Actions + def addSelectedToIgnoreList(self): + self.app.AddSelectedToIgnoreList() + + def applyFilter_(self, filter): + self.app.ApplyFilter(filter) + + def deleteMarked(self): + self.app.delete_marked() + + def makeSelectedReference(self): + self.app.MakeSelectedReference() + + def copyOrMove_markedTo_recreatePath_(self,copy,destination,recreate_path): + self.app.copy_or_move_marked(copy, destination, recreate_path) + + def openSelected(self): + self.app.OpenSelected() + + def removeDeadTracks(self): + self.app.remove_dead_tracks() + + def removeMarked(self): + self.app.results.perform_on_marked(lambda x:True, True) + + def removeSelected(self): + self.app.RemoveSelected() + + def renameSelected_(self,newname): + return self.app.RenameSelected(newname) + + def revealSelected(self): + self.app.RevealSelected() + + def scanDeadTracks(self): + self.app.scan_dead_tracks() + + #---Misc + def sortDupesBy_ascending_(self,key,asc): + self.app.sort_dupes(key,asc) + + def sortGroupsBy_ascending_(self,key,asc): + self.app.sort_groups(key,asc) + + #---Information + @objc.signature('i@:') + def deadTrackCount(self): + return len(self.app.dead_tracks) + + def getIgnoreListCount(self): + return len(self.app.scanner.ignore_list) + + def getMarkCount(self): + return self.app.results.mark_count + + def getStatLine(self): + return self.app.stat_line + + def getOperationalErrorCount(self): + return self.app.last_op_error_count + + #---Data + @objc.signature('i@:i') + def getOutlineViewMaxLevel_(self, tag): + return self.app.GetOutlineViewMaxLevel(tag) + + @objc.signature('@@:i@') + def getOutlineView_childCountsForPath_(self, tag, node_path): + return self.app.GetOutlineViewChildCounts(tag, node_path) + + def getOutlineView_valuesForIndexes_(self,tag,node_path): + return self.app.GetOutlineViewValues(tag,node_path) + + def getOutlineView_markedAtIndexes_(self,tag,node_path): + return self.app.GetOutlineViewMarked(tag,node_path) + + def getTableViewCount_(self,tag): + return self.app.GetTableViewCount(tag) + + def getTableViewMarkedIndexes_(self,tag): + return self.app.GetTableViewMarkedIndexes(tag) + + def getTableView_valuesForRow_(self,tag,row): + return self.app.GetTableViewValues(tag,row) + + #---Properties + def setMinMatchPercentage_(self, percentage): + self.app.scanner.min_match_percentage = int(percentage) + + def setScanType_(self, scan_type): + try: + self.app.scanner.scan_type = [ + scanner.SCAN_TYPE_FILENAME, + scanner.SCAN_TYPE_FIELDS, + scanner.SCAN_TYPE_FIELDS_NO_ORDER, + scanner.SCAN_TYPE_TAG, + scanner.SCAN_TYPE_CONTENT, + scanner.SCAN_TYPE_CONTENT_AUDIO + ][scan_type] + except IndexError: + pass + + def setWordWeighting_(self, words_are_weighted): + self.app.scanner.word_weighting = words_are_weighted + + def setMixFileKind_(self, mix_file_kind): + self.app.scanner.mix_file_kind = mix_file_kind + + def setDisplayDeltaValues_(self, display_delta_values): + self.app.display_delta_values = display_delta_values + + def setMatchSimilarWords_(self, match_similar_words): + self.app.scanner.match_similar_words = match_similar_words + + def setEscapeFilterRegexp_(self, escape_filter_regexp): + self.app.options['escape_filter_regexp'] = escape_filter_regexp + + def setRemoveEmptyFolders_(self, remove_empty_folders): + self.app.options['clean_empty_dirs'] = remove_empty_folders + + def enable_scanForTag_(self, enable, scan_tag): + if enable: + self.app.scanner.scanned_tags.add(scan_tag) + else: + self.app.scanner.scanned_tags.discard(scan_tag) + + #---Worker + def getJobProgress(self): + return self.app.progress.last_progress + + def getJobDesc(self): + return self.app.progress.last_desc + + def cancelJob(self): + self.app.progress.job_cancelled = True + + #---Registration + @objc.signature('i@:') + def isRegistered(self): + return self.app.registered + + @objc.signature('i@:@@') + def isCodeValid_withEmail_(self, code, email): + return self.app.is_code_valid(code, email) + + def setRegisteredCode_andEmail_(self, code, email): + self.app.set_registration(code, email) + diff --git a/me/cocoa/py/gen.py b/me/cocoa/py/gen.py new file mode 100644 index 00000000..6195927d --- /dev/null +++ b/me/cocoa/py/gen.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +import os +import os.path as op +import shutil + +from hsutil.build import print_and_do + +os.chdir('dupeguru') +print_and_do('python gen.py') +os.chdir('..') + +if op.exists('build'): + shutil.rmtree('build') +if op.exists('dist'): + shutil.rmtree('dist') + +print_and_do('python -u setup.py py2app') \ No newline at end of file diff --git a/me/cocoa/py/setup.py b/me/cocoa/py/setup.py new file mode 100644 index 00000000..af81b3ed --- /dev/null +++ b/me/cocoa/py/setup.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +from distutils.core import setup +import py2app + +from hsutil.build import move_testdata_out, put_testdata_back + +move_log = move_testdata_out() +try: + setup( + plugin = ['dg_cocoa.py'], + ) +finally: + put_testdata_back(move_log) diff --git a/me/cocoa/w3/dg.xsl b/me/cocoa/w3/dg.xsl new file mode 100644 index 00000000..4f982fce --- /dev/null +++ b/me/cocoa/w3/dg.xsl @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + indented + + + + + + + + + + + + + + + + + + + + + + + + + + + + dupeGuru Results + + + +

dupeGuru Results

+ + + + + +
+ + +
+ +
\ No newline at end of file diff --git a/me/cocoa/w3/hardcoded.css b/me/cocoa/w3/hardcoded.css new file mode 100644 index 00000000..ed243bcc --- /dev/null +++ b/me/cocoa/w3/hardcoded.css @@ -0,0 +1,71 @@ +BODY +{ + background-color:white; +} + +BODY,A,P,UL,TABLE,TR,TD +{ + font-family:Tahoma,Arial,sans-serif; + font-size:10pt; + color: #4477AA; +} + +TABLE +{ + background-color: #225588; + margin-left: auto; + margin-right: auto; + width: 90%; +} + +TR +{ + background-color: white; +} + +TH +{ + font-weight: bold; + color: black; + background-color: #C8D6E5; +} + +TH TD +{ + color:black; +} + +TD +{ + padding-left: 2pt; +} + +TD.rightelem +{ + text-align:right; + /*padding-left:0pt;*/ + padding-right: 2pt; + width: 17%; +} + +TD.indented +{ + padding-left: 12pt; +} + +H1 +{ + font-family:"Courier New",monospace; + color:#6699CC; + font-size:18pt; + color:#6da500; + border-color: #70A0CF; + border-width: 1pt; + border-style: solid; + margin-top: 16pt; + margin-left: 5%; + margin-right: 5%; + padding-top: 2pt; + padding-bottom:2pt; + text-align: center; +} \ No newline at end of file diff --git a/me/help/changelog.yaml b/me/help/changelog.yaml new file mode 100644 index 00000000..db4644f2 --- /dev/null +++ b/me/help/changelog.yaml @@ -0,0 +1,542 @@ +- date: 2009-05-30 + version: 5.6.1 + description: | + * Fixed a bug causing a GUI freeze at the beginning of a scan with a lot of files. + * Fixed a bug that sometimes caused a crash when an action was cancelled, and then started again. +- date: 2009-05-23 + version: 5.6.0 + description: | + * Converted the Windows GUI to Qt. + * Improved the reliability of the scanning process. +- date: 2009-03-28 + version: 5.5.2 + description: | + * **Fixed** an occasional crash caused by permission issues. + * **Fixed** a bug where the "X discarded" notice would show a too large number of discarded duplicates. +- date: 2008-09-28 + version: 5.5.1 + description: | + * **Improved** support for AIFF files. + * **Improved** Remove Dead Tracks in iTunes for very large library (Mac OS X). +- date: 2008-09-10 + description: "
    \n\t\t\t\t\t\t
  • Added support for AIFF files.
  • \n\t\ + \t\t\t\t\t
  • Added a notice in the status bar when matches were discarded\ + \ during the scan.
  • \n\t\t\t\t\t\t
  • Improved duplicate prioritization\ + \ (smartly chooses which file you will keep).
  • \n\t\t\t\t\t\t
  • Improved\ + \ scan progress feedback.
  • \n\t\t\t\t\t\t
  • Improved responsiveness\ + \ of the user interface for certain actions.
  • \n\t\t
" + version: 5.5.0 +- date: 2008-08-07 + description: "
    \n\t\t\t\t\t\t
  • Improved the \"Remove Dead Tracks in\ + \ iTunes\" feature.
  • \n\t\t\t\t\t\t
  • Improved the speed of results\ + \ loading and saving.
  • \n\t\t\t\t\t\t
  • Fixed a crash sometimes occurring\ + \ during duplicate deletion.
  • \n\t\t
" + version: 5.4.3 +- date: 2008-06-20 + description: "
    \n\t\t\t\t\t\t
  • Improved unicode handling for filenames\ + \ and tags. dupeGuru ME will now find a lot more duplicates if your files have\ + \ non-ascii characters in it.
  • \n\t\t\t\t\t\t
  • Improved MPEG files\ + \ duration detection.
  • \n\t\t\t\t\t\t
  • Fixed \"Clear Ignore List\"\ + \ crash in Windows.
  • \n\t\t
" + version: 5.4.2 +- date: 2008-01-15 + description: "
    \n\t\t\t\t\t\t
  • Improved scan, delete and move speed\ + \ in situations where there were a lot of duplicates.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ occasional crashes when moving a lot of files at once.
  • \n\t\t \ + \
" + version: 5.4.1 +- date: 2007-12-06 + description: "
    \n\t\t\t\t\t\t
  • Added customizable tag scans.
  • \n\t\ + \t\t\t\t\t
  • Improved the handling of low memory situations.
  • \n\t\t\ + \t\t\t\t
  • Improved the directory panel. The \"Remove\" button changes\ + \ to \"Put Back\" when an excluded directory is selected.
  • \n\t\t \ + \
" + version: 5.4.0 +- date: 2007-11-26 + description: "
    \n\t\t\t\t\t\t
  • Added the \"Remove empty folders\" option.
  • \n\ + \t\t\t\t\t\t
  • Fixed results load/save issues.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ occasional status bar inaccuracies when the results are filtered.
  • \n\t\t\ + \
" + version: 5.3.2 +- date: 2007-08-12 + description: "
    \n\t\t\t\t\t\t
  • Fixed a crash with copy and move.
  • \n\ + \t\t
" + version: 5.3.1 +- date: 2007-07-01 + description: "
    \n\t\t\t\t\t\t
  • Added post scan filtering.
  • \n\t\t\ + \t\t\t\t
  • Fixed a small issue with AAC decoding.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ issues with the rename feature under Windows
  • \n\t\t\t\t\t\t
  • Fixed\ + \ some user interface annoyances under Windows
  • \n\t\t
" + version: 5.3.0 +- date: 2007-03-31 + description: "
    \n\t\t\t\t\t\t
  • Fixed a crash sometimes happening while\ + \ loading results.
  • \n\t\t
" + version: 5.2.7 +- date: 2007-03-25 + description: "
    \n\t\t\t\t\t\t
  • Improved UI responsiveness (using threads)\ + \ under Mac OS X.
  • \n\t\t\t\t\t\t
  • Improved result load/save speed\ + \ and memory usage.
  • \n\t\t\t\t\t\t
  • Fixed a \"bad file descriptor\"\ + \ error occasionally popping up.
  • \n\t\t\t\t\t\t
  • Fixed a bug with\ + \ non-latin directory names.
  • \n\t\t\t\t\t\t
  • Fixed a column mixup\ + \ under Windows. The Artist column couldn't be shown.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ a bug causing the sorting under Power Marker mode not to work under Mac OS X.
  • \n\ + \t\t
" + version: 5.2.6 +- date: 2007-02-14 + description: "
    \n\t\t\t\t\t\t
  • Added Re-orderable columns. In fact,\ + \ I re-added the feature which was lost in the C# conversion in 5.2.0 (Windows).
  • \n\ + \t\t\t\t\t\t
  • Changed the behavior of the scanning engine when setting\ + \ the hardness to 100. It will now only match files that have their words in the\ + \ same order.
  • \n\t\t\t\t\t\t
  • Fixed a bug with all the Delete/Move/Copy\ + \ actions with certain kinds of files.
  • \n\t\t
" + version: 5.2.5 +- date: 2007-01-10 + description: "
    \n\t\t\t\t\t\t
  • Fixed a bug with the Move action.
  • \n\ + \t\t\t\t\t\t
  • Fixed a \"ghosting\" bug. Dupes deleted by dupeGuru would\ + \ sometimes come back in subsequent scans (Windows).
  • \n\t\t\t\t\t\t
  • Fixed\ + \ a bug introduced in the last version that caused the status bar not to update\ + \ when dupes were marked (Windows).
  • \n\t\t
" + version: 5.2.4 +- date: 2007-01-04 + description: "
    \n\t\t\t\t\t\t
  • Fixed bugs sometimes making dupeGuru\ + \ crash when marking a dupe (Windows).
  • \n\t\t\t\t\t\t
  • Fixed some\ + \ minor visual glitches (Windows).
  • \n\t\t
" + version: 5.2.3 +- date: 2006-12-21 + description: "
    \n\t\t\t\t\t\t
  • Improved Id3v2.4 tags decoding to support\ + \ some malformed tags that iTunes sometimes produce.
  • \n\t\t\t\t\t\t
  • Improved\ + \ the rename file dialog to exclude the extension from the original selection\ + \ (so when you start typing your new filename, it doesn't overwrite it) (Windows).
  • \n\ + \t\t\t\t\t\t
  • Changed some menu key shortcuts that created conflicts\ + \ (Windows).
  • \n\t\t\t\t\t\t
  • Fixed a bug preventing files from \"\ + reference\" directories to be displayed in blue in the results (Windows).
  • \n\ + \t\t\t\t\t\t
  • Fixed a bug preventing some files to be sent to the recycle\ + \ bin (Windows).
  • \n\t\t\t\t\t\t
  • Fixed a bug with the \"Remove\"\ + \ button of the directories panel (Windows).
  • \n\t\t\t\t\t\t
  • Fixed\ + \ a bug in the packaging preventing certain Windows configurations to start dupeGuru\ + \ at all.
  • \n\t\t
" + version: 5.2.2 +- date: 2006-11-18 + description: "
    \n\t\t\t\t\t\t
  • Fixed a bug with directory states.
  • \n\ + \t\t
" + version: 5.2.1 +- date: 2006-11-17 + description: "
    \n\t\t\t\t\t\t
  • Changed the Windows interface. It is\ + \ now .NET based.
  • \n\t\t\t\t\t\t
  • Added an auto-update feature to\ + \ the windows version.
  • \n\t\t\t\t\t\t
  • Changed the way power marking\ + \ works. It is now a mode instead of a separate window.
  • \n\t\t\t\t\t\t
  • Removed\ + \ the min word length/count options. These came from Mp3 Filter, and just aren't\ + \ used anymore. Word weighting does pretty much the same job.
  • \n\t\t\t\t\t\ + \t
  • Fixed a bug sometimes making delete and move operations stall.
  • \n\ + \t\t
" + version: 5.2.0 +- date: 2006-11-03 + description: "
    \n\t\t\t\t\t\t
  • Added an auto-update feature in the Mac\ + \ OS X version (with Sparkle).
  • \n\t\t\t\t\t\t
  • Added a \"Remove Dead\ + \ Tracks in iTunes\" feature in the Mac OS X version.
  • \n\t\t\t\t\t\t
  • Improved\ + \ speed and memory usage of the scanning engine, especially when the scan results\ + \ in a lot of duplicates.
  • \n\t\t\t\t\t\t
  • Improved VBR mp3 support.
  • \n\ + \t\t\t\t\t\t
  • Fixed a bug preventing some duplicate reports to be created\ + \ correctly under Windows.
  • \n\t\t
" + version: 5.1.2 +- date: 2006-09-29 + description: "
    \n\t\t\t\t\t\t
  • Fixed a bug (no, not the same as in 5.1.0)\ + \ preventing some duplicates to be found, especially in huge collections.
  • \n\ + \t\t
" + version: 5.1.1 +- date: 2006-09-26 + description: "
    \n\t\t\t\t\t\t
  • Added XHTML export feature.
  • \n\t\t\ + \t\t\t\t
  • Fixed a bug preventing some duplicates to be found when using\ + \ the \"Filename - Fields (No Order)\" scan method.
  • \n\t\t
" + version: 5.1.0 +- date: 2006-08-30 + description: "
    \n\t\t\t\t\t\t
  • Added sticky columns.
  • \n\t\t\t\t\t\ + \t
  • Fixed an issue with file caching between scans.
  • \n\t\t\t\t\t\t\ +
  • Fixed an issue preventing some duplicates from being deleted/moved/copied.
  • \n\ + \t\t
" + version: 5.0.11 +- date: 2006-08-27 + description: "
    \n\t\t\t\t\t\t
  • Fixed an issue with ignore list and unicode.
  • \n\ + \t\t\t\t\t\t
  • Fixed an issue with file attribute fetching sometimes causing\ + \ dupeGuru ME to crash.
  • \n\t\t\t\t\t\t
  • Fixed an issue in the directories\ + \ panel under Windows.
  • \n\t\t
" + version: 5.0.10 +- date: 2006-08-17 + description: "
    \n\t\t\t\t\t\t
  • Fixed an issue in the duplicate seeking\ + \ engine preventing some duplicates to be found.
  • \n\t\t\t\t\t\t
  • (Yeah,\ + \ I'm in a bug fixing frenzy right now :) )
  • \n\t\t
" + version: 5.0.9 +- date: 2006-08-16 + description: "
    \n\t\t\t\t\t\t
  • Fixed an issue with the new track column\ + \ occasionally causing crash.
  • \n\t\t\t\t\t\t
  • Fixed an issue with\ + \ the handling of corrupted files that occasionally caused crash.
  • \n\t\t \ + \
" + version: 5.0.8 +- date: 2006-08-12 + description: "
    \n\t\t\t\t\t\t
  • Improved unicode support.
  • \n\t\t\t\ + \t\t\t
  • Improved the \"Reveal in Finder\" (\"Open Containing Folder\"\ + \ in Windows) feature so it selects the file in the folder it opens.
  • \n\t\t\ + \
" + version: 5.0.7 +- date: 2006-08-08 + description: "
    \n\t\t\t\t\t\t
  • Added the the Track Number detail column.
  • \n\ + \t\t\t\t\t\t
  • Improved the ignore list system.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ a bug in the mp3 metadata decoding unit.
  • \n\t\t\t\t\t\t
  • dupeGuru Music\ + \ Edition is now a Universal application on Mac OS X.
  • \n\t\t
" + version: 5.0.6 +- date: 2006-07-28 + description: "
    \n\t\t\t\t\t\t
  • Improved VBR mp3 metadata decoding.
  • \n\ + \t\t\t\t\t\t
  • Fixed an issue that occasionally made dupeGuru ME crash\ + \ on startup.
  • \n\t\t
" + version: 5.0.5 +- date: 2006-06-26 + description: "
    \n\t\t\t\t\t\t
  • Fixed an issue with Move and Copy features.
  • \n\ + \t\t
" + version: 5.0.4 +- date: 2006-06-17 + description: "
    \n\t\t\t\t\t\t
  • Improved duplicate scanning speed.
  • \n\ + \t\t\t\t\t\t
  • Added a warning that a file couldn't be renamed if a file\ + \ with the same name already exists.
  • \n\t\t
" + version: 5.0.3 +- date: 2006-06-06 + description: "
    \n\t\t\t\t\t\t
  • Added \"Rename Selected\" feature.
  • \n\ + \t\t \t
  • Improved MP3 metadata decoding.
  • \n\t\t\t\t\t\t\ +
  • Fixed some minor issues with \"Reload Last Results\" feature.
  • \n\ + \t\t\t\t\t\t
  • Fixed ignore list issues.
  • \n\t\t
" + version: 5.0.2 +- date: 2006-05-26 + description: "
    \n\t\t \t
  • Fixed occasional progress bar woes\ + \ under Windows.
  • \n\t\t\t\t\t\t
  • Nothing has been changed in the Mac OS\ + \ X version, but I want to keep version in sync.
  • \n\t\t
" + version: 5.0.1 +- date: 2006-05-19 + description: "
    \n\t\t
  • Complete rewrite
  • \n\t\t\t\t\t\t\ +
  • Changed \"Mp3 Filter\" name to \"dupeGuru Music Edition\"
  • \n\t\t\t\t\t\ + \t
  • Now runs on Mac OS X.
  • \n\t\t
" + version: 5.0.0 +- date: 2006-04-13 + description: "
    \n\t\t
  • *fixed* a critical bug introduced\ + \ in 4.2.5: Files couldn't be deleted anymore!
  • \n\t\t
  • *fixed*\ + \ some more issues with WMA decoding.
  • \n\t\t
  • *fixed*\ + \ an issue with profile wizard.
  • \n\t\t
" + version: 4.2.6 +- date: 2006-04-11 + description: "
    \n\t\t
  • *added* a test zone in the Exclusions\ + \ profile section.
  • \n\t\t
  • *fixed* a bug with exclusion\ + \ patterns.
  • \n\t\t
  • *fixed* an issue occuring when\ + \ reading some kinds of WMA files.
  • \n\t\t
" + version: 4.2.5 +- date: 2006-02-16 + description: "
    \n\t\t
  • *fixed* MPL occasional issues\ + \ when saving.
  • \n\t\t
  • *fixed* m4p (protected AAC\ + \ files) bitrate reading.
  • \n\t\t
" + version: 4.2.4 +- date: 2005-10-15 + description: "
    \n\t\t
  • *improved* Added the \"Add Custom\ + \ Extension\" button in the File Priority section of the profile editor.
  • \n\ + \t\t
" + version: 4.2.3 +- date: 2005-10-07 + description: "
    \n\t\t
  • *improved* Results management\ + \ by adding the possibility to remove selected (not only checked) duplicates from\ + \ the list.
  • \n\t\t
  • *fixed* An issue with the \"\ + Switch with reference\" feature.
  • \n\t\t
  • *fixed*\ + \ A stability issue with the result pane.
  • \n\t\t
" + version: 4.2.2 +- date: 2005-09-06 + description: "
    \n\t\t
  • *fixed* A little bug with M4A/M4P\ + \ support.
  • \n\t\t
" + version: 4.2.1 +- date: 2005-08-30 + description: "
    \n\t\t
  • *added* M4A/M4P (iTunes format)\ + \ support.
  • \n\t\t
  • *added* \"Field order doesn't\ + \ matter\" option in Comparison Options.
  • \n\t\t
  • *added*\ + \ A \"Open directory containing this file\" option in the result window's context\ + \ menu.
  • \n\t\t \t
  • *fixed* Some bugs with the \"Load last\ + \ results\" function.
  • \n\t\t
" + version: 4.2.0 +- date: 2005-03-22 + description: "
    \n\t\t \t
  • *fixed* Nasty bug in the wizard\ + \ system.
  • \n\t\t \t
  • *fixed* Yet another nasty bug in\ + \ the Move/Copy option of the result pane.
  • \n\t\t
" + version: 4.1.5 +- date: 2004-11-10 + description: "
    \n\t\t \t
  • *added* \"Load last results\" function.
  • \n\ + \t\t \t
  • *added* Customizable columns in the results window.
  • \n\ + \t\t \t
  • *fixed* A bug related to special characters in the\ + \ XML profiles.
  • \n\t\t \t
  • *fixed* The result window scroll\ + \ didn't move properly on \"Switch with ref.\".
  • \n\t\t \t
  • *fixed*\ + \ A bug with the WMA plugin.
  • \n\t\t
" + version: 4.1.4 +- date: 2004-10-30 + description: "
    \n\t\t \t
  • *added* Profile summary in the\ + \ main window.
  • \n\t\t \t
  • *added* An (Artist + title)\ + \ ID3 tag comparison type.
  • \n\t\t \t
  • *improved* The profile\ + \ system by making it XML based.
  • \n\t\t
" + version: 4.1.3 +- date: 2004-09-28 + description: "
    \n\t\t \t
  • *improved* Changed the ID3 tag\ + \ comparison from (Artist + Title) to (Artist + Title + Album).
  • \n\t\t \ + \
" + version: 4.1.2 +- date: 2004-09-22 + description: "
    \n\t\t \t
  • *fixed* A couple of bugs.
  • \n\ + \t\t
" + version: 4.1.1 +- date: 2004-08-28 + description: "
    \n\t\t \t
  • *added* A \"special selection\"\ + \ wizard in the results window.
  • \n\t\t \t
  • *improved*\ + \ Changed the File content comparison system.
  • \n\t\t \t
  • *fixed*\ + \ A sorting bug in the directory tree displays
  • \n\t\t
" + version: 4.1.0 +- date: 2004-08-10 + description: "
    \n\t\t \t
  • *improved* Redesigned the configuration\ + \ wizard (again!).
  • \n\t\t
" + version: 4.0.6 +- date: 2004-07-23 + description: "
    \n\t\t \t
  • *improved* Redesigned the profile\ + \ directory frame.
  • \n\t\t
  • *fixed* A quite big bug\ + \ with file priority system.
  • \n\t\t
  • *fixed* A bug\ + \ with offline registration.
  • \n\t\t
" + version: 4.0.5 +- date: 2004-07-15 + description: "
    \n\t\t
  • *fixed* A couple of minor bugs\ + \ with profile directories/priorities.
  • \n\t\t
  • *improved*\ + \ Reduced, thus clarified, most of the text in the profile wizard.
  • \n\t\t\ + \
" + version: 4.0.4 +- date: 2004-07-12 + description: "
    \n\t\t
  • *fixed* An issue with \"Similar\ + \ word threshold\" setting, and boosted it's performance.
  • \n\t\t \ + \
  • *fixed* Some issues with the registering system.
  • \n\t\t\ + \
" + version: 4.0.3 +- date: 2004-07-10 + description: "
    \n\t\t
  • *fixed* A couple of obscure bugs.
  • \n\ + \t\t
  • *improved* Changed a couple of minor things in\ + \ this help file.
  • \n\t\t
" + version: 4.0.2 +- date: 2004-07-07 + description: "
    \n\t\t
  • *fixed* A couple of issues with\ + \ the configuration wizard.
  • \n\t\t
  • *fixed* A bug\ + \ with the View Details button when not using WinXP.
  • \n\t\t
" + version: 4.0.1 +- date: 2004-07-05 + description: Mp3 Filter has been rebuilt from scratch for this version. It features + a completely new interface, a profile system and a redesigned configuration wizard. + version: 4.0.0 +- date: 2002-12-31 + description: I never made a history entry for this version, although it has been + the version that went without changes for the most time (1 year and a half). I + also lost track of when I made it, but a quick fix (3.20.0.5) has been made on + 2002/12/31. + version: '3.20' +- date: 2002-08-14 + description: Enhanced the Mp3 List system with locking and improved searching. + version: '3.16' +- date: 2002-08-13 + description: Added Wizard, tips and installation program. + version: '3.15' +- date: 2002-08-12 + description: Added funny animation plugin and Windows Explorer shell extension. + version: '3.14' +- date: 2002-08-11 + description: Minor bugfixes + changed the Edit tag interface. + version: '3.12' +- date: 2002-08-10 + description: Added Import list feature + first 5kb of the files comparison. + version: '3.11' +- date: 2002-07-26 + description: Added extension plugins. + version: '3.10' +- date: 2002-01-30 + description: 'Fixed the ID3 Tag editor a bit. Changed the way comparison works: + it now can use ID3 Tags.' + version: '3.01' +- date: 2002-01-29 + description: The interface simply has been C-O-M-P-L-E-T-E-L-Y redesigned. Customization + level is at it's maximum, too cool. + version: '3.00' +- date: 2002-01-28 + description: Added some speed ONCE AGAIN, improved the memory management and added + a "favourite directories" feature. I also removed some confusing options. The + final result is quite cute! + version: '2.21' +- date: 2002-01-27 + description: Interface has been COMPLETELY rebuilt. Now there are MUCH more place + for everything! Several minor bugs has also been fixed Added mass ID3 tag editing. + version: '2.20' +- date: 2001-12-02 + description: Shareware again. Fixed some major bugs. Rebuilt (again) the mp3 list + system, it's now much more flexible. Added a configuration wizard. Added a renameing + preview. Well, it's a good update after all eh! + version: '2.10' +- date: 2001-12-01 + description: Added multi-language support. Added a "Send to recycle bin" option. + Enhanced rename feature. Corrected some bugs with rename function. Enhanced list + search function. + version: '2.01' +- date: 2001-11-30 + description: "As 11 Sept 2001 entered in the History, the release date of this program\ + \ will too! Ok, here is the list of Mp3 Filter version 2.00 godly features:\r\n\ + \r\n* **SPEED!!!!!!!!!!!!** Forget about what I said before. Previous versions\ + \ were TURTLES compared to that one. (Imagine what other programs are eh! :P).\ + \ What took 1 minute take 3-5 seconds now, and the more files you have to compare\ + \ together, the better will be the files/time ratio will be!\r\n* Multi-list system.\ + \ It is now easier than ever to exchange lists with your friends and select songs!\r\ + \n* Cuter interface." + version: '2.00' +- date: 2001-06-29 + description: There was some stability issues with the internal player I was using. + Mp3 Filter is now using Winamp. Thus, all files playable by Winamp are now playable + by Mp3 Filter. Fixed some minor bugs. Changed the way word exclusion system work. + AND added a song selection system. Now you can select songs from your mp3 list + and copy them to your hard drive without having to worry about where are these + songs. + version: '1.61' +- date: 2001-06-28 + description: 'The main theme of this update is efficiency. Mp3 Filter v1.53 was + already pure speed, you will NOT believe this version''s one. 60% faster on ALL + comparisons! Do not search for God anymore, you found Him and He even got an e-mail + adress: cathedly@hotmail.com :P. Ok, to tell you the truth I did not make Mp3 + Filter 60 % faster, I made it 60% less slow. My previous algorithm wasn''t bad, + but I thought about another one (this one) that has much better performances. + ALSO: Created an option form. Changed the results display (Added some info along + with the results (size,length,bitrate). Added a word excluding system. Also added + a backup system (Instead of deleting it, you can now move your file to the Mp3 + Filter backup directory (Mp3 filter does not compare files in the backup directory).' + version: '1.60' +- date: 2001-06-27 + description: Damnit, big update. Added the conditional file searching, file copying, + and rethought the Mp3List system. That new Mp3List system is damn cool! It load + instantly, even with HUGE lists, and it reduces the comparing time with list by + 30 godly % !!! You're not gonna believe it! This program is now PURE SPEED! + version: '1.53' +- date: 2001-05-05 + description: Quite cool update too. This version now can check if new versions are + available. I also grouped all options in the same menu. I moved the search function. + This function is now a lot cooler. Instead of giving you a list of matching results, + it shows you, in the Mp3 List Stats form, where the song is by positioning itself + in the List Tree. + version: '1.52' +- date: 2001-05-04 + description: Waa! I'm so happy! I implemented a poll system to Mp3 Filter! Now you + can answer my questions directly on the program! I can't wait to see if you, people, + will answer! + version: '1.51' +- date: 2001-05-03 + description: 'MAJOR UPDATE. This one is quite cool :). You ever used the "Edit Mp3 + List" feature? I improved it a lot. Now, when you add a CD to your list, it not + only saves the CD name, but it also saves the whole CD directory system. So when + you use ''Edit Mp3 List'' now, you can browse your CDs as if you would browse + anything. (There''s only one problem: you must REbuild your mp3 list to make it + fit with v1.5)' + version: '1.50' +- date: 2001-05-02 + description: Added an equalizer. This equalizer has been a good reason to add an + INI file to the program to store changed parameters. + version: '1.46' +- date: 2001-05-01 + description: Added a Banlist to the program. You write down a list of unwanted songs + in your ban list and start a scan. This function will not compare as the rest + does. If ALL words contained in a banlist line are in a filename, it will match. + version: '1.45' +- date: 2001-04-30 + description: I made the Mp3 Filter window to minimize when it compares so it can + do it faster (a LOT faster). I also modified the program so it checks the playlist + integrity each time there's a file deleted after a comparison). There was a bug + with the v1.43. When you had the ID3 Tag window up and you closed the program, + it would crash. Fixed that. + version: '1.44' +- date: 2001-04-29 + description: I noticed some days ago that people who had a good resolution but the + option to enlarge the icons on, Mp3 Filter had some big problems to display its + main form right. Since you cant resize the form without having the objects in + to resize too, I had to fix it. I also implemented a MUCH faster file searching + system. It takes less than 2 seconds to find all mp3 on my hard disk now. + version: '1.43' +- date: 2001-04-09 + description: Added some fun and useful feats. First, I made a cute playlist right-click + menu with Play File, Edit Tag, Locate, Remove from list and delete from disk. + I also added a recursive function to add songs to the playlist (Why didn't I think + about it before?? I have no clue...). I also made the Shuffle thing less.... random. + (It builds a random list and play it, so before a song play again, all songs will + be played (I added that feat some time after v1.41 release, but I didn't thought + that it worth a version change, so I only announce it on 1.42)) + version: '1.42' +- date: 2001-04-08 + description: I can't avoid it. there is always some bugs after a major update. I + didn't thought about the fact that it was possible to make a playlist with unplayable + files :) fixed that. + version: '1.41' +- date: 2001-04-07 + description: MAJOR UPDATE! You wanted a playlist. You got it in this version. Those + big buttons were ugly? Made a cute standard menu. You didn't seem to want to buy + that program. I gave up. Here is it. Freeware again. + version: '1.40' +- date: 2001-03-16 + description: Made it possible to play files that are listed after a "Find all Mp3 + on this drive". It also tells what song is currently playing on the main title + bar. + version: '1.36' +- date: 2001-03-15 + description: Added a system icon. Wow! it almost looks like winamp! + version: '1.35' +- date: 2001-03-14 + description: Added music progress bar and made the music playing continuous. + version: '1.34' +- date: 2001-03-13 + description: Added mass renaming functions. + version: '1.33' +- date: 2001-03-12 + description: Fixed some bugs with those useful function :) (and made the program + shareware) + version: '1.32' +- date: 2001-03-11 + description: Added some useful functions. + version: '1.31' +- date: 2001-03-10 + description: MAJOR CHANGE. yeah! I scrapped those radio buttons, and extended the + "recurse" function. Now, you only have 2 choices. Or you compare with your list, + or you compare within the folder (and sub-folders). With that system, you can + tell the program to just compare ALL mp3 in your hard drive. You just have to + select your drive root, and press "Find dupe files in this folder" having "Recurse" + checked. + version: '1.30' +- date: 2001-03-09 + description: Added the Music Control panel. I just love it. do you? + version: '1.23' +- date: 2001-03-08 + description: Fixed some inaccuracy with folder to folder comparison. (Will I be + done fixing someday??) and made mp3 search slightly faster. + version: '1.22' +- date: 2001-03-07 + description: Added Mp3 Player (Didn't know it was so easy to include in a program! + I woulda done this before if I knew...) and ID3 Tag Editor. Hum, The Mp3 Player + has some problems reading some mp3s... know that. + version: '1.21' +- date: 2001-03-04 + description: When I removed the "find mp3 in my list" thing, some people told me + it was useful. However, I still think that the old way to search mp3 was too messed + up, so I just added a little textbox and a search button for quick search. + version: '1.20' +- date: 2001-03-03 + description: Damnit! why didn't I see it? There was a bug with displaying the right + filename on the result boxes with List comparing. The results were switched! Thus, + deleting was impossible after a List compare. Corrected it in 1.18. + version: '1.18' +- date: 2001-03-03 + description: "When I read Yippee review (www.yippee.net thanks for review), I tried\ + \ to somewhat improve it. What changed? This:\r\n\r\n* Compare engine is less\ + \ strict. if one word contains the other, it now match (now, \"Limp Bizkit\" and\ + \ \"Limp Bizkitt\" would match)\r\n* Removed some useless features to simplify\ + \ the interface. \"Save as...\" (why did I put this on???) and \"Find file in\ + \ my list\" (Easier to find a song with \"Edit List\")\r\n* Added some hints to\ + \ buttons and some explicative labels.\r\n* \"List Stats\" changed to \"Edit\ + \ List\" so you don't have to \"hard change\" your mp3 list." + version: '1.19' +- date: 2001-02-06 + description: I never thought that a software history would be useful for such a + small program, but since Mp3 filter won't stop improving, I decided to start it. + So 1.17 is the base version. + version: '1.17' diff --git a/me/help/gen.py b/me/help/gen.py new file mode 100644 index 00000000..7fa6be01 --- /dev/null +++ b/me/help/gen.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python + +import os + +from web import generate_help + +generate_help.main('.', 'dupeguru_me_help', force_render=True) \ No newline at end of file diff --git a/me/help/skeleton/hardcoded.css b/me/help/skeleton/hardcoded.css new file mode 100644 index 00000000..a3b17c5b --- /dev/null +++ b/me/help/skeleton/hardcoded.css @@ -0,0 +1,409 @@ +/***************************************************** + General settings +*****************************************************/ + +BODY +{ + background-color:white; +} + +BODY,A,P,UL,TABLE,TR,TD +{ + font-family:Tahoma,Arial,sans-serif; + font-size:10pt; + color: #4477AA;/*darker than 5588bb for the sake of the eyes*/ +} + +/***************************************************** + "A" settings +*****************************************************/ + +A +{ + color: #ae322b; + text-decoration:underline; + font-weight:bold; +} + +A.glossaryword {color:#A0A0A0;} + +A.noline +{ + text-decoration: none; +} + + +/***************************************************** + Menu and mainframe settings +*****************************************************/ + +.maincontainer +{ + display:block; + margin-left:7%; + margin-right:7%; + padding-left:5px; + padding-right:0px; + border-color:#CCCCCC; + border-style:solid; + border-width:2px; + border-right-width:0px; + border-bottom-width:0px; + border-top-color:#ae322b; + vertical-align:top; +} + +TD.menuframe +{ + width:30%; +} + +.menu +{ + margin:4px 4px 4px 4px; + margin-top: 16pt; + border-color:gray; + border-width:1px; + border-style:dotted; + padding-top:10pt; + padding-bottom:10pt; + padding-right:6pt; +} + +.submenu +{ + list-style-type: none; + margin-left:26pt; + margin-top:0pt; + margin-bottom:0pt; + padding-left:0pt; +} + +A.menuitem,A.menuitem_selected +{ + font-size:14pt; + font-family:Tahoma,Arial,sans-serif; + font-weight:normal; + padding-left:10pt; + color:#5588bb; + margin-right:2pt; + margin-left:4pt; + text-decoration:none; +} + +A.menuitem_selected +{ + font-weight:bold; +} + +A.submenuitem +{ + font-family:Tahoma,Arial,sans-serif; + font-weight:normal; + color:#5588bb; + text-decoration:none; +} + +.titleline +{ + border-width:3px; + border-style:solid; + border-left-width:0px; + border-right-width:0px; + border-top-width:0px; + border-color:#CCCCCC; + margin-left:28pt; + margin-right:2pt; + line-height:1px; + padding-top:0px; + margin-top:0px; + display:block; +} + +.titledescrip +{ + text-align:left; + display:block; + margin-left:26pt; + color:#ae322b; +} + +.mainlogo +{ + display:block; + margin-left:8%; + margin-top:4pt; + margin-bottom:4pt; +} + +/***************************************************** + IMG settings +*****************************************************/ + +IMG +{ + border-style:none; +} + +IMG.smallbutton +{ + margin-right: 20px; + float:none; +} + +IMG.floating +{ + float:left; + margin-right: 4pt; + margin-bottom: 4pt; +} + +IMG.lefticon +{ + vertical-align: middle; + padding-right: 2pt; +} + +IMG.righticon +{ + vertical-align: middle; + padding-left: 2pt; +} + +/***************************************************** + TABLE settings +*****************************************************/ + +TABLE +{ + border-style:none; +} + +TABLE.box +{ + width: 90%; + margin-left:5%; +} + +TABLE.centered +{ + margin-left: auto; + margin-right: auto; +} + +TABLE.hardcoded +{ + background-color: #225588; + margin-left: auto; + margin-right: auto; + width: 90%; +} + +TR { background-color: transparent; } + +TABLE.hardcoded TR { background-color: white } + +TABLE.hardcoded TR.header +{ + font-weight: bold; + color: black; + background-color: #C8D6E5; +} + +TABLE.hardcoded TR.header TD {color:black;} + +TABLE.hardcoded TD { padding-left: 2pt; } + +TD.minimelem { + padding-right:0px; + padding-left:0px; + text-align:center; +} + +TD.rightelem +{ + text-align:right; + /*padding-left:0pt;*/ + padding-right: 2pt; + width: 17%; +} + +/***************************************************** + P settings +*****************************************************/ + +p,.sub{text-align:justify;} +.centered{text-align:center;} +.sub +{ + padding-left: 16pt; + padding-right:16pt; +} + +.Note, .ContactInfo +{ + border-color: #ae322b; + border-width: 1pt; + border-style: dashed; + text-align:justify; + padding: 2pt 2pt 2pt 2pt; + margin-bottom:4pt; + margin-top:8pt; + list-style-position:inside; +} + +.ContactInfo +{ + width:60%; + margin-left:5%; +} + +.NewsItem +{ + border-color:#ae322b; + border-style: solid; + border-right:none; + border-top:none; + border-left:none; + border-bottom-width:1px; + text-align:justify; + padding-left:4pt; + padding-right:4pt; + padding-bottom:8pt; +} + +/***************************************************** + Lists settings +*****************************************************/ +UL.plain +{ + list-style-type: none; + padding-left:0px; + margin-left:0px; +} + +LI.plain +{ + list-style-type: none; +} + +LI.section +{ + padding-top: 6pt; +} + +UL.longtext LI +{ + border-color: #ae322b; + border-width:0px; + border-top-width:1px; + border-style:solid; + margin-top:12px; +} + +/* + with UL.longtext LI, there can be anything between + the UL and the LI, and it will still make the + lontext thing, I must break it with this hack +*/ +UL.longtext UL LI +{ + border-style:none; + margin-top:2px; +} + + +/***************************************************** + Titles settings +*****************************************************/ + +H1,H2,H3 +{ + font-family:"Courier New",monospace; + color:#5588bb; +} + +H1 +{ + font-size:18pt; + color: #ae322b; + border-color: #70A0CF; + border-width: 1pt; + border-style: solid; + margin-top: 16pt; + margin-left: 5%; + margin-right: 5%; + padding-top: 2pt; + padding-bottom:2pt; + text-align: center; +} + +H2 +{ + border-color: #ae322b; + border-bottom-width: 2px; + border-top-width: 0pt; + border-left-width: 2px; + border-right-width: 0pt; + border-bottom-color: #cccccc; + border-style: solid; + margin-top: 16pt; + margin-left: 0pt; + margin-right: 0pt; + padding-bottom:3pt; + padding-left:5pt; + text-align: left; + font-size:16pt; +} + +H3 +{ + display:block; + color:#ae322b; + border-color: #70A0CF; + border-bottom-width: 2px; + border-top-width: 0pt; + border-left-width: 0pt; + border-right-width: 0pt; + border-style: dashed; + margin-top: 12pt; + margin-left: 0pt; + margin-bottom: 4pt; + width:auto; + padding-bottom:3pt; + padding-right:2pt; + padding-left:2pt; + text-align: left; + font-weight:bold; +} + + +/***************************************************** + Misc. classes +*****************************************************/ +.longtext:first-letter {font-size: 150%} + +.price, .loweredprice, .specialprice {font-weight:bold;} + +.loweredprice {text-decoration:line-through} + +.specialprice {color:red} + +form +{ + margin:0px; +} + +.program_summary +{ + float:right; + margin: 32pt; + margin-top:0pt; + margin-bottom:0pt; +} + +.screenshot +{ + float:left; + margin: 8pt; +} \ No newline at end of file diff --git a/me/help/skeleton/images/hs_title.png b/me/help/skeleton/images/hs_title.png new file mode 100644 index 00000000..07bd89c6 Binary files /dev/null and b/me/help/skeleton/images/hs_title.png differ diff --git a/me/help/templates/base_dg.mako b/me/help/templates/base_dg.mako new file mode 100644 index 00000000..7767c49f --- /dev/null +++ b/me/help/templates/base_dg.mako @@ -0,0 +1,14 @@ +<%inherit file="/base_help.mako"/> +${next.body()} + +<%def name="menu()"><% +self.menuitem('intro.htm', 'Introduction', 'Introduction to dupeGuru') +self.menuitem('quick_start.htm', 'Quick Start', 'Quickly get into the action') +self.menuitem('directories.htm', 'Directories', 'Managing dupeGuru directories') +self.menuitem('preferences.htm', 'Preferences', 'Setting dupeGuru preferences') +self.menuitem('results.htm', 'Results', 'Time to delete these duplicates!') +self.menuitem('power_marker.htm', 'Power Marker', 'Take control of your duplicates') +self.menuitem('faq.htm', 'F.A.Q.', 'Frequently Asked Questions') +self.menuitem('versions.htm', 'Version History', 'Changes dupeGuru went through') +self.menuitem('credits.htm', 'Credits', 'People who contributed to dupeGuru') +%> \ No newline at end of file diff --git a/me/help/templates/credits.mako b/me/help/templates/credits.mako new file mode 100644 index 00000000..a170ec3d --- /dev/null +++ b/me/help/templates/credits.mako @@ -0,0 +1,20 @@ +<%! + title = 'Credits' + selected_menu_item = 'Credits' +%> +<%inherit file="/base_dg.mako"/> +Below is the list of people who contributed, directly or indirectly to dupeGuru. + +${self.credit('Virgil Dupras', 'Developer', "That's me, Hardcoded Software founder", 'www.hardcoded.net', 'hsoft@hardcoded.net')} + +${self.credit('Python', 'Programming language', "The bestest of the bests", 'www.python.org')} + +${self.credit('PyObjC', 'Python-to-Cocoa bridge', "Used for the Mac OS X version", 'pyobjc.sourceforge.net')} + +${self.credit('PyQt', 'Python-to-Qt bridge', "Used for the Windows version", 'www.riverbankcomputing.co.uk')} + +${self.credit('Qt', 'GUI Toolkit', "Used for the Windows version", 'www.qtsoftware.com')} + +${self.credit('Sparkle', 'Auto-update library', "Used for the Mac OS X version", 'andymatuschak.org/pages/sparkle')} + +${self.credit('You', 'dupeGuru user', "What would I do without you?")} diff --git a/me/help/templates/directories.mako b/me/help/templates/directories.mako new file mode 100644 index 00000000..e75b47bd --- /dev/null +++ b/me/help/templates/directories.mako @@ -0,0 +1,24 @@ +<%! + title = 'Directories' + selected_menu_item = 'Directories' +%> +<%inherit file="/base_dg.mako"/> + +There is a panel in dupeGuru called **Directories**. You can open it by clicking on the **Directories** button. This directory contains the list of the directories that will be scanned when you click on **Start Scanning**. + +This panel is quite straightforward to use. If you want to add a directory, click on **Add**. If you added directories before, a popup menu with a list of recent directories you added will pop. You can click on one of them to add it directly to your list. If you click on the first item of the popup menu, **Add New Directory...**, you will be prompted for a directory to add. If you never added a directory, no menu will pop and you will directly be prompted for a new directory to add. + +To remove a directory, select the directory to remove and click on **Remove**. If a subdirectory is selected when you click remove, the selected directory will be set to **excluded** state (see below) instead of being removed. + +Directory states +----- + +Every directory can be in one of these 3 states: + +* **Normal:** Duplicates found in these directories can be deleted. +* **Reference:** Duplicates found in this directory **cannot** be deleted. Files in reference directories will be in a blue color in the results. +* **Excluded:** Files in this directory will not be included in the scan. + +The default state of a directory is, of course, **Normal**. You can use **Reference** state for a directory if you want to be sure that you won't delete any file from it. + +When you set the state of a directory, all subdirectories of this directory automatically inherit this state unless you explicitly set a subdirectory's state. diff --git a/me/help/templates/faq.mako b/me/help/templates/faq.mako new file mode 100644 index 00000000..13e2e601 --- /dev/null +++ b/me/help/templates/faq.mako @@ -0,0 +1,67 @@ +<%! + title = 'dupeGuru ME F.A.Q.' + selected_menu_item = 'F.A.Q.' +%> +<%inherit file="/base_dg.mako"/> + +<%text filter="md"> +### What is dupeGuru Music Edition? + +dupeGuru Music Edition is a tool to find duplicate songs in your music collection. It can base its scan on filenames, tags or content. The filename and tag scans feature a fuzzy matching algorithm that can find duplicate filenames or tags even when they are not exactly the same. + +### What makes it better than other duplicate scanners? + +The scanning engine is extremely flexible. You can tweak it to really get the kind of results you want. You can read more about dupeGuru tweaking option at the [Preferences page](preferences.htm). + +### How safe is it to use dupeGuru ME? + +Very safe. dupeGuru has been designed to make sure you don't delete files you didn't mean to delete. First, there is the reference directory system that lets you define directories where you absolutely **don't** want dupeGuru to let you delete files there, and then there is the group reference system that makes sure that you will **always** keep at least one member of the duplicate group. + +### What are the demo limitations of dupeGuru ME? + +In demo mode, you can only perform actions (delete/copy/move) on 10 duplicates per session. + +### The mark box of a file I want to delete is disabled. What must I do? + +You cannot mark the reference (The first file) of a duplicate group. However, what you can do is to promote a duplicate file to reference. Thus, if a file you want to mark is reference, select a duplicate file in the group that you want to promote to reference, and click on **Actions-->Make Selected Reference**. If the reference file is from a reference directory (filename written in blue letters), you cannot remove it from the reference position. + +### I have a directory from which I really don't want to delete files. + +If you want to be sure that dupeGuru will never delete file from a particular directory, just open the **Directories panel**, select that directory, and set its state to **Reference**. + +### What is this '(X discarded)' notice in the status bar? + +In some cases, some matches are not included in the final results for security reasons. Let me use an example. We have 3 file: A, B and C. We scan them using a low filter hardness. The scanner determines that A matches with B, A matches with C, but B does **not** match with C. Here, dupeGuru has kind of a problem. It cannot create a duplicate group with A, B and C in it because not all files in the group would match together. It could create 2 groups: one A-B group and then one A-C group, but it will not, for security reasons. Lets think about it: If B doesn't match with C, it probably means that either B, C or both are not actually duplicates. If there would be 2 groups (A-B and A-C), you would end up delete both B and C. And if one of them is not a duplicate, that is really not what you want to do, right? So what dupeGuru does in a case like this is to discard the A-C match (and adds a notice in the status bar). Thus, if you delete B and re-run a scan, you will have a A-C match in your next results. + +### I want to mark all files from a specific directory. What can I do? + +Enable the [Power Marker](power_marker.htm) mode and click on the Directory column to sort your duplicates by Directory. It will then be easy for you to select all duplicates from the same directory, and then press Space to mark all selected duplicates. + +### I want to remove all songs that are more than 3 seconds away from their reference file. What can I do? + +* Enable the [Power Marker](power_marker.htm) mode. +* Enable the **Delta Values** mode. +* Click on the "Time" column to sort the results by time. +* Select all duplicates below -00:03. +* Click on **Remove Selected from Results**. +* Select all duplicates over 00:03. +* Click on **Remove Selected from Results**. + +### I want to make my highest bitrate songs reference files. What can I do? + +* Enable the [Power Marker](power_marker.htm) mode. +* Enable the **Delta Values** mode. +* Click on the "Bitrate" column to sort the results by bitrate. +* Click on the "Bitrate" column again to reverse the sort order (see Power Marker page to know why). +* Select all duplicates over 0. +* Click on **Make Selected Reference**. + +### I don't want [live] and [remix] versions of my songs counted as duplicates. How do I do that? + +If your comparison threshold is low enough, you will probably end up with live and remix versions of your songs in your results. There's nothing you can do to prevent that, but there's something you can do to easily remove them from your results after the scan: post-scan filtering. If, for example, you want to remove every song with anything inside square brackets []: + +* **Windows**: Click on **Actions --> Apply Filter**, then type "[*]", then click OK. +* **Mac OS X**: Type "[*]" in the "Filter" field in the toolbar. +* Click on **Mark --> Mark All**. +* Click on **Actions --> Remove Selected from Results**. + \ No newline at end of file diff --git a/me/help/templates/intro.mako b/me/help/templates/intro.mako new file mode 100644 index 00000000..2381895d --- /dev/null +++ b/me/help/templates/intro.mako @@ -0,0 +1,13 @@ +<%! + title = 'Introduction to dupeGuru ME' + selected_menu_item = 'introduction' +%> +<%inherit file="/base_dg.mako"/> + +dupeGuru Music Edition is a tool to find duplicate files on your computer. It can scan either filenames or contents. The filename scan features a fuzzy matching algorithm that can find duplicate filenames even when they are not exactly the same. + +Although dupeGuru can easily be used without documentation, reading this file will help you to master it. If you are looking for guidance for your first duplicate scan, you can take a look at the [Quick Start](quick_start.htm) section. + +It is a good idea to keep dupeGuru updated. You can download the latest version on the [dupeGuru ME homepage](http://www.hardcoded.net/dupeguru_me/). + +<%def name="meta()"> diff --git a/me/help/templates/power_marker.mako b/me/help/templates/power_marker.mako new file mode 100644 index 00000000..26078f3d --- /dev/null +++ b/me/help/templates/power_marker.mako @@ -0,0 +1,33 @@ +<%! + title = 'Power Marker' + selected_menu_item = 'Power Marker' +%> +<%inherit file="/base_dg.mako"/> + +You will probably not use the Power Marker feature very often, but if you get into a situation where you need it, you will be pretty happy that this feature exists. + +What is it? +----- + +When the Power Marker mode is enabled, the duplicates are shown without their respective reference file. You can select, mark and sort this list, just like in normal mode. + +So, what is it for? +----- + +The dupeGuru results, when in normal mode, are sorted according to duplicate groups' **reference file**. This means that if you want, for example, to mark all duplicates with the "exe" extension, you cannot just sort the results by "Kind" to have all exe duplicates together because a group can be composed of more than one kind of files. That is where Power Marker comes into play. To mark all your "exe" duplicates, you just have to: + +* Enable the Power marker mode. +* Add the "Kind" column with the "Columns" menu. +* Click on that "Kind" column to sort the list by kind. +* Locate the first duplicate with a "exe" kind. +* Select it. +* Scroll down the list to locate the last duplicate with a "exe" kind. +* Hold Shift and click on it. +* Press Space to mark all selected duplicates. + +Power Marker and delta values +----- + +The Power Marker unveil its true power when you use it with the **Delta Values** switch turned on. When you turn it on, relative values will be displayed instead of absolute ones. So if, for example, you want to remove from your results all duplicates that are more than 300 KB away from their reference, you could sort the Power Marker by Size, select all duplicates under -300 in the Size column, delete them, and then do the same for duplicates over 300 at the bottom of the list. + +You could also use it to change the reference priority of your duplicate list. When you make a fresh scan, if there are no reference directories, the reference file of every group is the biggest file. If you want to change that, for example, to the latest modification time, you can sort the Power Marker by modification time in **descending** order, select all duplicates with a modification time delta value higher than 0 and click on **Make Selected Reference**. The reason why you must make the sort order descending is because if 2 files among the same duplicate group are selected when you click on **Make Selected Reference**, only the first of the list will be made reference, the other will be ignored. And since you want the last modified file to be reference, having the sort order descending assures you that the first item of the list will be the last modified. diff --git a/me/help/templates/preferences.mako b/me/help/templates/preferences.mako new file mode 100644 index 00000000..52006d49 --- /dev/null +++ b/me/help/templates/preferences.mako @@ -0,0 +1,36 @@ +<%! + title = 'Preferences' + selected_menu_item = 'Preferences' +%> +<%inherit file="/base_dg.mako"/> + +**Scan Type:** This option determines what aspect of the files will be compared in the duplicate scan. The nature of the duplicate scan varies greatly depending on what you select for this option. + +* **Filename:** Every song will have its filename split into words, and then every word will be compared to compute a matching percentage. If this percentage is higher or equal to the **Filter Hardness** (see below for more details), dupeGuru will consider the 2 songs duplicates. +* **Filename - Fields:** Like **Filename**, except that once filename have been split into words, these words are then grouped into fields. The field separator is " - ". The final matching percentage will be the lowest matching percentage among the fields. Thus, "An Artist - The Title" and "An Artist - Other Title" would have a matching percentage of 50 (With a **Filename** scan, it would be 75). +* **Filename - Fields (No Order):** Like **Filename - Fields**, except that field order doesn't matter. For example, "An Artist - The Title" and "The Title - An Artist" would have a matching percentage of 100 instead of 0. +* **Tags:** This method reads the tag (metadata) of every song and compare their fields. This method, like the **Filename - Fields**, considers the lowest matching field as its final matching percentage. +* **Content:** This scan method use the actual content of the songs to determine which are duplicates. For 2 songs to match with this method, they must have the **exact same content**. +* **Audio Content:** Same as content, but only the audio content is compared (without metadata). + +**Filter Hardness:** If you chose a filename or tag based scan type, this option determines how similar two filenames/tags must be for dupeGuru to consider them duplicates. If the filter hardness is, for example 80, it means that 80% of the words of two filenames must match. To determine the matching percentage, dupeGuru first counts the total number of words in **both** filenames, then count the number of words matching (every word matching count as 2), and then divide the number of words matching by the total number of words. If the result is higher or equal to the filter hardness, we have a duplicate match. For example, "a b c d" and "c d e" have a matching percentage of 57 (4 words matching, 7 total words). + +**Tags to scan:** When using the **Tags** scan type, you can select the tags that will be used for comparison. + +**Word weighting:** If you chose a filename or tag based scan type, this option slightly changes how matching percentage is calculated. With word weighting, instead of having a value of 1 in the duplicate count and total word count, every word have a value equal to the number of characters they have. With word weighting, "ab cde fghi" and "ab cde fghij" would have a matching percentage of 53% (19 total characters, 10 characters matching (4 for "ab" and 6 for "cde")). + +**Match similar words:** If you turn this option on, similar words will be counted as matches. For example "The White Stripes" and "The White Stripe" would have a match % of 100 instead of 66 with that option turned on. **Warning:** Use this option with caution. It is likely that you will get a lot of false positives in your results when turning it on. However, it will help you to find duplicates that you wouldn't have found otherwise. The scan process also is significantly slower with this option turned on. + +**Can mix file kind:** If you check this box, duplicate groups are allowed to have files with different extensions. If you don't check it, well, they aren't! + +**Use regular expressions when filtering:** If you check this box, the filtering feature will treat your filter query as a **regular expression**. Explaining them is beyond the scope of this document. A good place to start learning it is . + +**Remove empty folders after delete or move:** When this option is enabled, folders are deleted after a file is deleted or moved and the folder is empty. + +**Copy and Move:** Determines how the Copy and Move operations (in the Action menu) will behave. + +* **Right in destination:** All files will be sent directly in the selected destination, without trying to recreate the source path at all. +* **Recreate relative path:** The source file's path will be re-created in the destination directory up to the root selection in the Directories panel. For example, if you added "/Users/foobar/Music" to your Directories panel and you move "/Users/foobar/Music/Artist/Album/the_song.mp3" to the destination "/Users/foobar/MyDestination", the final destination for the file will be "/Users/foobar/MyDestination/Artist/Album" ("/Users/foobar/Music" has been trimmed from source's path in the final destination.). +* **Recreate absolute path:** The source file's path will be re-created in the destination directory in it's entirety. For example, if you move "/Users/foobar/Music/Artist/Album/the_song.mp3" to the destination "/Users/foobar/MyDestination", the final destination for the file will be "/Users/foobar/MyDestination/Users/foobar/Music/Artist/Album". + +In all cases, dupeGuru nicely handles naming conflicts by prepending a number to the destination filename if the filename already exists in the destination. diff --git a/me/help/templates/quick_start.mako b/me/help/templates/quick_start.mako new file mode 100644 index 00000000..dde33c65 --- /dev/null +++ b/me/help/templates/quick_start.mako @@ -0,0 +1,18 @@ +<%! + title = 'Quick Start' + selected_menu_item = 'Quick Start' +%> +<%inherit file="/base_dg.mako"/> + +To get you quickly started with dupeGuru, let's just make a standard scan using default preferences. + +* Click on **Directories**. +* Click on **Add**. +* Choose a directory you want to scan for duplicates. +* Click on **Start Scanning**. +* Wait until the scan process is over. +* Look at every duplicate (The files that are indented) and verify that it is indeed a duplicate to the group's reference (The file above the duplicate that is not indented and have a disabled mark box). +* If a file is a false duplicate, select it and click on **Actions-->Remove Selected from Results**. +* Once you are sure that there is no false duplicate in your results, click on **Edit-->Mark All**, and then **Actions-->Send Marked to Recycle bin**. + +That is only a basic scan. There are a lot of tweaking you can do to get different results and several methods of examining and modifying your results. To know about them, just read the rest of this help file. diff --git a/me/help/templates/results.mako b/me/help/templates/results.mako new file mode 100644 index 00000000..53aa176f --- /dev/null +++ b/me/help/templates/results.mako @@ -0,0 +1,73 @@ +<%! + title = 'Results' + selected_menu_item = 'Results' +%> +<%inherit file="/base_dg.mako"/> + +When dupeGuru is finished scanning for duplicates, it will show its results in the form of duplicate group list. + +About duplicate groups +----- + +A duplicate group is a group of files that all match together. Every group has a **reference file** and one or more **duplicate files**. The reference file is the first file of the group. Its mark box is disabled. Below it, and indented, are the duplicate files. + +You can mark duplicate files, but you can never mark the reference file of a group. This is a security measure to prevent dupeGuru from deleting not only duplicate files, but their reference. You sure don't want that, do you? + +What determines which files are reference and which files are duplicates is first their directory state. A files from a reference directory will always be reference in a duplicate group. If all files are from a normal directory, the size determine which file will be the reference of a duplicate group. dupeGuru assumes that you always want to keep the biggest file, so the biggest files will take the reference position. + +You can change the reference file of a group manually. To do so, select the duplicate file you want to promote to reference, and click on **Actions-->Make Selected Reference**. + +Reviewing results +----- + +Although you can just click on **Edit-->Mark All** and then **Actions-->Send Marked to Recycle bin** to quickly delete all duplicate files in your results, it is always recommended to review all duplicates before deleting them. + +To help you reviewing the results, you can bring up the **Details panel**. This panel shows all the details of the currently selected file as well as its reference's details. This is very handy to quickly determine if a duplicate really is a duplicate. You can also double-click on a file to open it with its associated application. + +If you have more false duplicates than true duplicates (If your filter hardness is very low), the best way to proceed would be to review duplicates, mark true duplicates and then click on **Actions-->Send Marked to Recycle bin**. If you have more true duplicates than false duplicates, you can instead mark all files that are false duplicates, and use **Actions-->Remove Marked from Results**. + +Marking and Selecting +----- + +A **marked** duplicate is a duplicate with the little box next to it having a check-mark. A **selected** duplicate is a duplicate being highlighted. The multiple selection actions can be performed in dupeGuru in the standard way (Shift/Command/Control click). You can toggle all selected duplicates' mark state by pressing **space**. + +Delta Values +----- + +If you turn this switch on, some columns will display the value relative to the duplicate's reference instead of the absolute values. These delta values will also be displayed in a different color so you can spot them easily. For example, if a duplicate is 1.2 MB and its reference is 1.4 MB, the Size column will display -0.2 MB. This option is a killer feature when combined with the [Power Marker](power_marker.htm). + +Filtering +----- + +dupeGuru supports post-scan filtering. With it, you can narrow down your results so you can perform actions on a subset of it. For example, you could easily mark all duplicates with their filename containing "copy" from your results using the filter. + +**Windows:** To use the filtering feature, click on Actions --> Apply Filter, write down the filter you want to apply and click OK. To go back to unfiltered results, click on Actions --> Cancel Filter. + +**Mac OS X:** To use the filtering feature, type your filter in the "Filter" search field in the toolbar. To go back to unfiltered result, blank out the field, or click on the "X". + +In simple mode (the default mode), whatever you type as the filter is the string used to perform the actual filtering, with the exception of one wildcard: **\***. Thus, if you type "[*]" as your filter, it will match anything with [] brackets in it, whatever is in between those brackets. + +For more advanced filtering, you can turn "Use regular expressions when filtering" on. The filtering feature will then use **regular expressions**. A regular expression is a language for matching text. Explaining them is beyond the scope of this document. A good place to start learning it is . + +Matches are case insensitive in both simple and regexp mode. + +For the filter to match, your regular expression don't have to match the whole filename, it just have to contain a string matching the expression. + +You might notice that not all duplicates in the filtered results will match your filter. That is because as soon as one single duplicate in a group matches the filter, the whole group stays in the results so you can have a better view of the duplicate's context. However, non-matching duplicates are in "reference mode". Therefore, you can perform actions like Mark All and be sure to only mark filtered duplicates. + +Action Menu +----- + +* **Start Duplicate Scan:** Starts a new duplicate scan. +* **Clear Ignore List:** Remove all ignored matches you added. You have to start a new scan for the newly cleared ignore list to be effective. +* **Export Results to XHTML:** Take the current results, and create an XHTML file out of it. The columns that are visible when you click on this button will be the columns present in the XHTML file. The file will automatically be opened in your default browser. +* **Send Marked to Trash:** Send all marked duplicates to trash, obviously. +* **Move Marked to...:** Prompt you for a destination, and then move all marked files to that destination. Source file's path might be re-created in destination, depending on the "Copy and Move" preference. +* **Copy Marked to...:** Prompt you for a destination, and then copy all marked files to that destination. Source file's path might be re-created in destination, depending on the "Copy and Move" preference. +* **Remove Marked from Results:** Remove all marked duplicates from results. The actual files will not be touched and will stay where they are. +* **Remove Selected from Results:** Remove all selected duplicates from results. Note that all selected reference files will be ignored, only duplicates can be removed with this action. +* **Make Selected Reference:** Promote all selected duplicates to reference. If a duplicate is a part of a group having a reference file coming from a reference directory (in blue color), no action will be taken for this duplicate. If more than one duplicate among the same group are selected, only the first of each group will be promoted. +* **Add Selected to Ignore List:** This first removes all selected duplicates from results, and then add the match of that duplicate and the current reference in the ignore list. This match will not come up again in further scan. The duplicate itself might come back, but it will be matched with another reference file. You can clear the ignore list with the Clear Ignore List command. +* **Open Selected with Default Application:** Open the file with the application associated with selected file's type. +* **Reveal Selected in Finder:** Open the folder containing selected file. +* **Rename Selected:** Prompts you for a new name, and then rename the selected file. diff --git a/me/help/templates/versions.mako b/me/help/templates/versions.mako new file mode 100644 index 00000000..946cbaa1 --- /dev/null +++ b/me/help/templates/versions.mako @@ -0,0 +1,9 @@ +<%! + title = 'dupeGuru ME version history' + selected_menu_item = 'Version History' +%> +<%inherit file="/base_dg.mako"/> + +A large part of this version history is not serious (especially before v3), but it is always interesting to remember that I learnt most of what I know about designing/implementing/supporting a software through that. + +${self.output_changelogs(changelog)} \ No newline at end of file diff --git a/me/qt/app.py b/me/qt/app.py new file mode 100644 index 00000000..65314e2b --- /dev/null +++ b/me/qt/app.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# Unit Name: app +# Created By: Virgil Dupras +# Created On: 2009-05-21 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import hsfs.phys.music + +from dupeguru import data_me, scanner + +from base.app import DupeGuru as DupeGuruBase +from details_dialog import DetailsDialog +from preferences import Preferences +from preferences_dialog import PreferencesDialog + +class DupeGuru(DupeGuruBase): + LOGO_NAME = 'logo_me' + NAME = 'dupeGuru Music Edition' + VERSION = '5.6.1' + DELTA_COLUMNS = frozenset([2, 3, 4, 5, 7, 8]) + + def __init__(self): + DupeGuruBase.__init__(self, data_me, appid=1) + + def _setup(self): + self.scanner = scanner.ScannerME() + self.directories.dirclass = hsfs.phys.music.Directory + DupeGuruBase._setup(self) + + def _update_options(self): + DupeGuruBase._update_options(self) + self.scanner.min_match_percentage = self.prefs.filter_hardness + self.scanner.scan_type = self.prefs.scan_type + self.scanner.word_weighting = self.prefs.word_weighting + self.scanner.match_similar_words = self.prefs.match_similar + scanned_tags = set() + if self.prefs.scan_tag_track: + scanned_tags.add('track') + if self.prefs.scan_tag_artist: + scanned_tags.add('artist') + if self.prefs.scan_tag_album: + scanned_tags.add('album') + if self.prefs.scan_tag_title: + scanned_tags.add('title') + if self.prefs.scan_tag_genre: + scanned_tags.add('genre') + if self.prefs.scan_tag_year: + scanned_tags.add('year') + self.scanner.scanned_tags = scanned_tags + + def _create_details_dialog(self, parent): + return DetailsDialog(parent, self) + + def _create_preferences(self): + return Preferences() + + def _create_preferences_dialog(self, parent): + return PreferencesDialog(parent, self) + diff --git a/me/qt/app_win.py b/me/qt/app_win.py new file mode 100644 index 00000000..697f8335 --- /dev/null +++ b/me/qt/app_win.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# Unit Name: app_win +# Created By: Virgil Dupras +# Created On: 2009-05-21 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import winshell + +import app + +class DupeGuru(app.DupeGuru): + @staticmethod + def _recycle_dupe(dupe): + winshell.delete_file(unicode(dupe.path), no_confirm=True) + diff --git a/me/qt/build.py b/me/qt/build.py new file mode 100644 index 00000000..6e7e8b5f --- /dev/null +++ b/me/qt/build.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# Unit Name: build +# Created By: Virgil Dupras +# Created On: 2009-05-22 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +# On Windows, PyInstaller is used to build an exe (py2exe creates a very bad looking icon) +# The release version is outdated. Use at least r672 on http://svn.pyinstaller.org/trunk + +import os +import os.path as op +import shutil + +from hsutil.build import print_and_do +from app import DupeGuru + +# Removing build and dist +if op.exists('build'): + shutil.rmtree('build') +if op.exists('dist'): + shutil.rmtree('dist') + +version = DupeGuru.VERSION +versioncomma = version.replace('.', ', ') + ', 0' +verinfo = open('verinfo').read() +verinfo = verinfo.replace('$versioncomma', versioncomma).replace('$version', version) +fp = open('verinfo_tmp', 'w') +fp.write(verinfo) +fp.close() +print_and_do("python C:\\Python26\\pyinstaller\\Build.py dgme.spec") +os.remove('verinfo_tmp') + +print_and_do("xcopy /Y C:\\src\\vs_comp\\msvcrt dist") +print_and_do("xcopy /Y /S /I help\\dupeguru_me_help dist\\help") + +aicom = '"\\Program Files\\Caphyon\\Advanced Installer\\AdvancedInstaller.com"' +shutil.copy('installer.aip', 'installer_tmp.aip') # this is so we don'a have to re-commit installer.aip at every version change +print_and_do('%s /edit installer_tmp.aip /SetVersion %s' % (aicom, version)) +print_and_do('%s /build installer_tmp.aip -force' % aicom) +os.remove('installer_tmp.aip') \ No newline at end of file diff --git a/me/qt/details_dialog.py b/me/qt/details_dialog.py new file mode 100644 index 00000000..b680309c --- /dev/null +++ b/me/qt/details_dialog.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# Unit Name: details_dialog +# Created By: Virgil Dupras +# Created On: 2009-04-27 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import Qt +from PyQt4.QtGui import QDialog + +from base.details_table import DetailsModel +from details_dialog_ui import Ui_DetailsDialog + +class DetailsDialog(QDialog, Ui_DetailsDialog): + def __init__(self, parent, app): + QDialog.__init__(self, parent, Qt.Tool) + self.app = app + self.setupUi(self) + self.model = DetailsModel(app) + self.tableView.setModel(self.model) diff --git a/me/qt/details_dialog.ui b/me/qt/details_dialog.ui new file mode 100644 index 00000000..c0557003 --- /dev/null +++ b/me/qt/details_dialog.ui @@ -0,0 +1,53 @@ + + + DetailsDialog + + + + 0 + 0 + 502 + 295 + + + + + 250 + 250 + + + + Details + + + + 0 + + + 0 + + + + + true + + + QAbstractItemView::SelectRows + + + false + + + + + + + + DetailsTable + QTableView +
base.details_table
+
+
+ + +
diff --git a/me/qt/dgme.spec b/me/qt/dgme.spec new file mode 100644 index 00000000..4d47e350 --- /dev/null +++ b/me/qt/dgme.spec @@ -0,0 +1,19 @@ +# -*- mode: python -*- +a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), 'start.py'], + pathex=['C:\\src\\dupeguru\\me\\qt']) +pyz = PYZ(a.pure) +exe = EXE(pyz, + a.scripts, + exclude_binaries=1, + name=os.path.join('build\\pyi.win32\\dupeGuru ME', 'dupeGuru ME.exe'), + debug=False, + strip=False, + upx=True, + console=False , icon='base\\images\\dgme_logo.ico', version='verinfo_tmp') +coll = COLLECT( exe, + a.binaries, + a.zipfiles, + a.datas, + strip=False, + upx=True, + name=os.path.join('dist')) diff --git a/me/qt/gen.py b/me/qt/gen.py new file mode 100644 index 00000000..9edb6040 --- /dev/null +++ b/me/qt/gen.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +# Unit Name: gen +# Created By: Virgil Dupras +# Created On: 2009-05-22 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import os + +from hsutil.build import print_and_do + +os.chdir('dupeguru') +print_and_do('python gen.py') +os.chdir('..') + +os.chdir('base') +print_and_do('python gen.py') +os.chdir('..') + +print_and_do("pyuic4 details_dialog.ui > details_dialog_ui.py") +print_and_do("pyuic4 preferences_dialog.ui > preferences_dialog_ui.py") + +os.chdir('help') +print_and_do('python gen.py') +os.chdir('..') diff --git a/me/qt/installer.aip b/me/qt/installer.aip new file mode 100644 index 00000000..51cfc4d9 --- /dev/null +++ b/me/qt/installer.aip @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/me/qt/preferences.py b/me/qt/preferences.py new file mode 100644 index 00000000..bdb4c914 --- /dev/null +++ b/me/qt/preferences.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +# Unit Name: preferences +# Created By: Virgil Dupras +# Created On: 2009-05-17 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from dupeguru.scanner import (SCAN_TYPE_FILENAME, SCAN_TYPE_FIELDS, SCAN_TYPE_FIELDS_NO_ORDER, + SCAN_TYPE_TAG, SCAN_TYPE_CONTENT, SCAN_TYPE_CONTENT_AUDIO) + +from base.preferences import Preferences as PreferencesBase + +class Preferences(PreferencesBase): + # (width, is_visible) + COLUMNS_DEFAULT_ATTRS = [ + (200, True), # name + (180, True), # path + (60, True), # size + (60, True), # Time + (50, True), # Bitrate + (60, False), # Sample Rate + (40, False), # Kind + (120, False), # creation + (120, False), # modification + (120, False), # Title + (120, False), # Artist + (120, False), # Album + (80, False), # Genre + (40, False), # Year + (40, False), # Track Number + (120, False), # Comment + (60, True), # match % + (120, False), # Words Used + (80, False), # dupe count + ] + + def _load_specific(self, settings, get): + self.scan_type = get('ScanType', self.scan_type) + self.word_weighting = get('WordWeighting', self.word_weighting) + self.match_similar = get('MatchSimilar', self.match_similar) + self.scan_tag_track = get('ScanTagTrack', self.scan_tag_track) + self.scan_tag_artist = get('ScanTagArtist', self.scan_tag_artist) + self.scan_tag_album = get('ScanTagAlbum', self.scan_tag_album) + self.scan_tag_title = get('ScanTagTitle', self.scan_tag_title) + self.scan_tag_genre = get('ScanTagGenre', self.scan_tag_genre) + self.scan_tag_year = get('ScanTagYear', self.scan_tag_year) + + def _reset_specific(self): + self.filter_hardness = 80 + self.scan_type = SCAN_TYPE_TAG + self.word_weighting = True + self.match_similar = False + self.scan_tag_track = False + self.scan_tag_artist = True + self.scan_tag_album = True + self.scan_tag_title = True + self.scan_tag_genre = False + self.scan_tag_year = False + + def _save_specific(self, settings, set_): + set_('ScanType', self.scan_type) + set_('WordWeighting', self.word_weighting) + set_('MatchSimilar', self.match_similar) + set_('ScanTagTrack', self.scan_tag_track) + set_('ScanTagArtist', self.scan_tag_artist) + set_('ScanTagAlbum', self.scan_tag_album) + set_('ScanTagTitle', self.scan_tag_title) + set_('ScanTagGenre', self.scan_tag_genre) + set_('ScanTagYear', self.scan_tag_year) + diff --git a/me/qt/preferences_dialog.py b/me/qt/preferences_dialog.py new file mode 100644 index 00000000..0ec53364 --- /dev/null +++ b/me/qt/preferences_dialog.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python +# Unit Name: preferences_dialog +# Created By: Virgil Dupras +# Created On: 2009-04-29 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import SIGNAL, Qt +from PyQt4.QtGui import QDialog, QDialogButtonBox + +from dupeguru.scanner import (SCAN_TYPE_FILENAME, SCAN_TYPE_FIELDS, SCAN_TYPE_FIELDS_NO_ORDER, + SCAN_TYPE_TAG, SCAN_TYPE_CONTENT, SCAN_TYPE_CONTENT_AUDIO) + +from preferences_dialog_ui import Ui_PreferencesDialog +import preferences + +SCAN_TYPE_ORDER = [ + SCAN_TYPE_FILENAME, + SCAN_TYPE_FIELDS, + SCAN_TYPE_FIELDS_NO_ORDER, + SCAN_TYPE_TAG, + SCAN_TYPE_CONTENT, + SCAN_TYPE_CONTENT_AUDIO, +] + +class PreferencesDialog(QDialog, Ui_PreferencesDialog): + def __init__(self, parent, app): + flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint + QDialog.__init__(self, parent, flags) + self.app = app + self._setupUi() + + self.connect(self.buttonBox, SIGNAL('clicked(QAbstractButton*)'), self.buttonClicked) + + def _setupUi(self): + self.setupUi(self) + + def load(self, prefs=None): + if prefs is None: + prefs = self.app.prefs + self.filterHardnessSlider.setValue(prefs.filter_hardness) + self.filterHardnessLabel.setNum(prefs.filter_hardness) + scan_type_index = SCAN_TYPE_ORDER.index(prefs.scan_type) + self.scanTypeComboBox.setCurrentIndex(scan_type_index) + setchecked = lambda cb, b: cb.setCheckState(Qt.Checked if b else Qt.Unchecked) + setchecked(self.tagTrackBox, prefs.scan_tag_track) + setchecked(self.tagArtistBox, prefs.scan_tag_artist) + setchecked(self.tagAlbumBox, prefs.scan_tag_album) + setchecked(self.tagTitleBox, prefs.scan_tag_title) + setchecked(self.tagGenreBox, prefs.scan_tag_genre) + setchecked(self.tagYearBox, prefs.scan_tag_year) + setchecked(self.matchSimilarBox, prefs.match_similar) + setchecked(self.wordWeightingBox, prefs.word_weighting) + setchecked(self.mixFileKindBox, prefs.mix_file_kind) + setchecked(self.useRegexpBox, prefs.use_regexp) + setchecked(self.removeEmptyFoldersBox, prefs.remove_empty_folders) + self.copyMoveDestinationComboBox.setCurrentIndex(prefs.destination_type) + + def save(self): + prefs = self.app.prefs + prefs.filter_hardness = self.filterHardnessSlider.value() + prefs.scan_type = SCAN_TYPE_ORDER[self.scanTypeComboBox.currentIndex()] + ischecked = lambda cb: cb.checkState() == Qt.Checked + prefs.scan_tag_track = ischecked(self.tagTrackBox) + prefs.scan_tag_artist = ischecked(self.tagArtistBox) + prefs.scan_tag_album = ischecked(self.tagAlbumBox) + prefs.scan_tag_title = ischecked(self.tagTitleBox) + prefs.scan_tag_genre = ischecked(self.tagGenreBox) + prefs.scan_tag_year = ischecked(self.tagYearBox) + prefs.match_similar = ischecked(self.matchSimilarBox) + prefs.word_weighting = ischecked(self.wordWeightingBox) + prefs.mix_file_kind = ischecked(self.mixFileKindBox) + prefs.use_regexp = ischecked(self.useRegexpBox) + prefs.remove_empty_folders = ischecked(self.removeEmptyFoldersBox) + prefs.destination_type = self.copyMoveDestinationComboBox.currentIndex() + + def resetToDefaults(self): + self.load(preferences.Preferences()) + + #--- Events + def buttonClicked(self, button): + role = self.buttonBox.buttonRole(button) + if role == QDialogButtonBox.ResetRole: + self.resetToDefaults() + diff --git a/me/qt/preferences_dialog.ui b/me/qt/preferences_dialog.ui new file mode 100644 index 00000000..9eefc864 --- /dev/null +++ b/me/qt/preferences_dialog.ui @@ -0,0 +1,434 @@ + + + PreferencesDialog + + + + 0 + 0 + 350 + 322 + + + + Preferences + + + false + + + true + + + + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Scan Type: + + + + + + + + Filename + + + + + Filename - Fields + + + + + Filename - Fields (No Order) + + + + + Tags + + + + + Contents + + + + + Audio Contents + + + + + + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Filter Hardness: + + + + + + + 0 + + + + + 12 + + + + + + 0 + 0 + + + + 1 + + + 100 + + + true + + + Qt::Horizontal + + + + + + + + 21 + 0 + + + + 100 + + + + + + + + + 0 + + + + + More Results + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Less Results + + + + + + + + + + + + + + 0 + 40 + + + + + + 0 + 0 + 91 + 17 + + + + Tags to scan: + + + + + + 10 + 20 + 51 + 21 + + + + Track + + + + + + 60 + 20 + 51 + 21 + + + + Artist + + + + + + 110 + 20 + 61 + 21 + + + + Album + + + + + + 170 + 20 + 51 + 21 + + + + Title + + + + + + 220 + 20 + 61 + 21 + + + + Genre + + + + + + 280 + 20 + 51 + 21 + + + + Year + + + + + + + + Word weighting + + + + + + + Match similar words + + + + + + + Can mix file kind + + + + + + + Use regular expressions when filtering + + + + + + + Remove empty folders on delete or move + + + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Copy and Move: + + + + + + + + 0 + 0 + + + + + Right in destination + + + + + Recreate relative path + + + + + Recreate absolute path + + + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults + + + + + + + + + filterHardnessSlider + valueChanged(int) + filterHardnessLabel + setNum(int) + + + 182 + 26 + + + 271 + 26 + + + + + buttonBox + accepted() + PreferencesDialog + accept() + + + 182 + 228 + + + 182 + 124 + + + + + buttonBox + rejected() + PreferencesDialog + reject() + + + 182 + 228 + + + 182 + 124 + + + + + diff --git a/me/qt/profile.py b/me/qt/profile.py new file mode 100644 index 00000000..195b1775 --- /dev/null +++ b/me/qt/profile.py @@ -0,0 +1,20 @@ +import sys +import cProfile +import pstats + +from PyQt4.QtCore import QCoreApplication +from PyQt4.QtGui import QApplication + +if sys.platform == 'win32': + from app_win import DupeGuru +else: + from app import DupeGuru + +if __name__ == "__main__": + app = QApplication(sys.argv) + QCoreApplication.setOrganizationName('Hardcoded Software') + QCoreApplication.setApplicationName('dupeGuru Music Edition') + dgapp = DupeGuru() + cProfile.run('app.exec_()', '/tmp/prof') + p = pstats.Stats('/tmp/prof') + p.sort_stats('time').print_stats() \ No newline at end of file diff --git a/me/qt/start.py b/me/qt/start.py new file mode 100644 index 00000000..d4315875 --- /dev/null +++ b/me/qt/start.py @@ -0,0 +1,20 @@ +import sys + +from PyQt4.QtCore import QCoreApplication +from PyQt4.QtGui import QApplication, QIcon, QPixmap + +import base.dg_rc + +if sys.platform == 'win32': + from app_win import DupeGuru +else: + from app import DupeGuru + +if __name__ == "__main__": + app = QApplication(sys.argv) + app.setWindowIcon(QIcon(QPixmap(":/logo_me"))) + QCoreApplication.setOrganizationName('Hardcoded Software') + QCoreApplication.setApplicationName(DupeGuru.NAME) + QCoreApplication.setApplicationVersion(DupeGuru.VERSION) + dgapp = DupeGuru() + sys.exit(app.exec_()) \ No newline at end of file diff --git a/me/qt/verinfo b/me/qt/verinfo new file mode 100644 index 00000000..6384c49e --- /dev/null +++ b/me/qt/verinfo @@ -0,0 +1,28 @@ +VSVersionInfo( + ffi=FixedFileInfo( + filevers=($versioncomma), + prodvers=($versioncomma), + mask=0x17, + flags=0x0, + OS=0x4, + fileType=0x1, + subtype=0x0, + date=(0, 0) + ), + kids=[ + StringFileInfo( + [ + StringTable( + '040904b0', + [StringStruct('CompanyName', 'Hardcoded Software'), + StringStruct('FileDescription', 'dupeGuru Music Edition'), + StringStruct('FileVersion', '$version'), + StringStruct('InternalName', 'dupeGuru ME.exe'), + StringStruct('LegalCopyright', '(c) Hardcoded Software. All rights reserved.'), + StringStruct('OriginalFilename', 'dupeGuru ME.exe'), + StringStruct('ProductName', 'dupeGuru Music Edition'), + StringStruct('ProductVersion', '$versioncomma')]) + ]), + VarFileInfo([VarStruct('Translation', [1033])]) + ] +) diff --git a/pe/cocoa/AppDelegate.h b/pe/cocoa/AppDelegate.h new file mode 100644 index 00000000..70203dfb --- /dev/null +++ b/pe/cocoa/AppDelegate.h @@ -0,0 +1,21 @@ +#import +#import "dgbase/AppDelegate.h" +#import "ResultWindow.h" +#import "DirectoryPanel.h" +#import "DetailsPanel.h" +#import "PyDupeGuru.h" + +@interface AppDelegate : AppDelegateBase +{ + IBOutlet ResultWindow *result; + + DetailsPanel *_detailsPanel; + DirectoryPanel *_directoryPanel; +} +- (IBAction)openWebsite:(id)sender; +- (IBAction)toggleDetailsPanel:(id)sender; +- (IBAction)toggleDirectories:(id)sender; + +- (DirectoryPanel *)directoryPanel; +- (PyDupeGuru *)py; +@end diff --git a/pe/cocoa/AppDelegate.m b/pe/cocoa/AppDelegate.m new file mode 100644 index 00000000..0a515656 --- /dev/null +++ b/pe/cocoa/AppDelegate.m @@ -0,0 +1,116 @@ +#import "AppDelegate.h" +#import "ProgressController.h" +#import "RegistrationInterface.h" +#import "Utils.h" +#import "ValueTransformers.h" +#import "Consts.h" + +@implementation AppDelegate ++ (void)initialize +{ + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + NSMutableDictionary *d = [NSMutableDictionary dictionaryWithCapacity:10]; + [d setObject:[NSNumber numberWithInt:95] forKey:@"minMatchPercentage"]; + [d setObject:[NSNumber numberWithInt:1] forKey:@"recreatePathType"]; + [d setObject:[NSNumber numberWithBool:NO] forKey:@"matchScaled"]; + [d setObject:[NSNumber numberWithBool:YES] forKey:@"mixFileKind"]; + [d setObject:[NSNumber numberWithBool:NO] forKey:@"useRegexpFilter"]; + [d setObject:[NSNumber numberWithBool:NO] forKey:@"removeEmptyFolders"]; + [d setObject:[NSNumber numberWithBool:NO] forKey:@"debug"]; + [d setObject:[NSArray array] forKey:@"recentDirectories"]; + [d setObject:[NSArray array] forKey:@"columnsOrder"]; + [d setObject:[NSDictionary dictionary] forKey:@"columnsWidth"]; + [[NSUserDefaultsController sharedUserDefaultsController] setInitialValues:d]; + [ud registerDefaults:d]; +} + +- (id)init +{ + self = [super init]; + _directoryPanel = nil; + _detailsPanel = nil; + _appName = APPNAME; + return self; +} + +- (IBAction)openWebsite:(id)sender +{ + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.hardcoded.net/dupeguru_pe"]]; +} + +- (IBAction)toggleDetailsPanel:(id)sender +{ + if (!_detailsPanel) + _detailsPanel = [[DetailsPanel alloc] initWithPy:py]; + if ([[_detailsPanel window] isVisible]) + [[_detailsPanel window] close]; + else + { + [[_detailsPanel window] orderFront:nil]; + [_detailsPanel refresh]; + } +} + +- (IBAction)toggleDirectories:(id)sender +{ + [[self directoryPanel] toggleVisible:sender]; +} + +- (DirectoryPanel *)directoryPanel +{ + if (!_directoryPanel) + _directoryPanel = [[DirectoryPanel alloc] initWithParentApp:self]; + return _directoryPanel; +} +- (PyDupeGuru *)py { return (PyDupeGuru *)py; } + +//Delegate +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification +{ + [[ProgressController mainProgressController] setWorker:py]; + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + //Restore Columns + NSArray *columnsOrder = [ud arrayForKey:@"columnsOrder"]; + NSDictionary *columnsWidth = [ud dictionaryForKey:@"columnsWidth"]; + if ([columnsOrder count]) + [result restoreColumnsPosition:columnsOrder widths:columnsWidth]; + //Reg stuff + if ([RegistrationInterface showNagWithApp:[self py] name:APPNAME limitDescription:LIMIT_DESC]) + [unlockMenuItem setTitle:@"Thanks for buying dupeGuru Picture Edition!"]; + //Restore results + [py loadIgnoreList]; + [py loadResults]; +} + +- (void)applicationWillBecomeActive:(NSNotification *)aNotification +{ + if (![[result window] isVisible]) + [result showWindow:NSApp]; +} + +- (void)applicationWillTerminate:(NSNotification *)aNotification +{ + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + [ud setObject: [result getColumnsOrder] forKey:@"columnsOrder"]; + [ud setObject: [result getColumnsWidth] forKey:@"columnsWidth"]; + [py saveIgnoreList]; + [py saveResults]; + int sc = [ud integerForKey:@"sessionCountSinceLastIgnorePurge"]; + if (sc >= 10) + { + sc = -1; + [py purgeIgnoreList]; + } + sc++; + [ud setInteger:sc forKey:@"sessionCountSinceLastIgnorePurge"]; + // NSApplication does not release nib instances objects, we must do it manually + // Well, it isn't needed because the memory is freed anyway (we are quitting the application + // But I need to release RecentDirectories so it saves the user defaults + [recentDirectories release]; +} + +- (void)recentDirecoryClicked:(NSString *)directory +{ + [[self directoryPanel] addDirectory:directory]; +} +@end diff --git a/pe/cocoa/Consts.h b/pe/cocoa/Consts.h new file mode 100644 index 00000000..c8aea9fa --- /dev/null +++ b/pe/cocoa/Consts.h @@ -0,0 +1,4 @@ +#import "dgbase/Consts.h" + +extern NSString *ImageLoadedNotification; +extern NSString *APPNAME; \ No newline at end of file diff --git a/pe/cocoa/Consts.m b/pe/cocoa/Consts.m new file mode 100644 index 00000000..b7c57178 --- /dev/null +++ b/pe/cocoa/Consts.m @@ -0,0 +1,5 @@ +#import "Consts.h" + +NSString *ImageLoadedNotification = @"ImageLoadedNotification"; +NSString *APPNAME = @"dupeGuru PE"; + diff --git a/pe/cocoa/DetailsPanel.h b/pe/cocoa/DetailsPanel.h new file mode 100644 index 00000000..119e6cf6 --- /dev/null +++ b/pe/cocoa/DetailsPanel.h @@ -0,0 +1,21 @@ +#import +#import "PyApp.h" +#import "Table.h" + + +@interface DetailsPanel : NSWindowController +{ + IBOutlet TableView *detailsTable; + IBOutlet NSImageView *dupeImage; + IBOutlet NSProgressIndicator *dupeProgressIndicator; + IBOutlet NSImageView *refImage; + IBOutlet NSProgressIndicator *refProgressIndicator; + + PyApp *py; + BOOL _needsRefresh; + NSString *_dupePath; + NSString *_refPath; +} +- (id)initWithPy:(PyApp *)aPy; +- (void)refresh; +@end \ No newline at end of file diff --git a/pe/cocoa/DetailsPanel.m b/pe/cocoa/DetailsPanel.m new file mode 100644 index 00000000..00845b33 --- /dev/null +++ b/pe/cocoa/DetailsPanel.m @@ -0,0 +1,79 @@ +#import "Utils.h" +#import "NSNotificationAdditions.h" +#import "NSImageAdditions.h" +#import "PyDupeGuru.h" +#import "DetailsPanel.h" +#import "Consts.h" + +@implementation DetailsPanel +- (id)initWithPy:(PyApp *)aPy +{ + self = [super initWithWindowNibName:@"Details"]; + [self window]; //So the detailsTable is initialized. + [detailsTable setPy:aPy]; + py = aPy; + _needsRefresh = YES; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(duplicateSelectionChanged:) name:DuplicateSelectionChangedNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(imageLoaded:) name:ImageLoadedNotification object:self]; + return self; +} + +- (void)loadImageAsync:(NSString *)imagePath +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSImage *image = [[NSImage alloc] initByReferencingFile:imagePath]; + NSImage *thumbnail = [image imageByScalingProportionallyToSize:NSMakeSize(512,512)]; + [image release]; + NSMutableDictionary *params = [NSMutableDictionary dictionary]; + [params setValue:imagePath forKey:@"imagePath"]; + [params setValue:thumbnail forKey:@"image"]; + [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:ImageLoadedNotification object:self userInfo:params waitUntilDone:YES]; + [pool release]; +} + +- (void)refresh +{ + if (!_needsRefresh) + return; + [detailsTable reloadData]; + + NSString *refPath = [(PyDupeGuru *)py getSelectedDupeRefPath]; + if (_refPath != nil) + [_refPath autorelease]; + _refPath = [refPath retain]; + [NSThread detachNewThreadSelector:@selector(loadImageAsync:) toTarget:self withObject:refPath]; + NSString *dupePath = [(PyDupeGuru *)py getSelectedDupePath]; + if (_dupePath != nil) + [_dupePath autorelease]; + _dupePath = [dupePath retain]; + if (![dupePath isEqual: refPath]) + [NSThread detachNewThreadSelector:@selector(loadImageAsync:) toTarget:self withObject:dupePath]; + [refProgressIndicator startAnimation:nil]; + [dupeProgressIndicator startAnimation:nil]; + _needsRefresh = NO; +} + +/* Notifications */ +- (void)duplicateSelectionChanged:(NSNotification *)aNotification +{ + _needsRefresh = YES; + if ([[self window] isVisible]) + [self refresh]; +} + +- (void)imageLoaded:(NSNotification *)aNotification +{ + NSString *imagePath = [[aNotification userInfo] valueForKey:@"imagePath"]; + NSImage *image = [[aNotification userInfo] valueForKey:@"image"]; + if ([imagePath isEqual: _refPath]) + { + [refImage setImage:image]; + [refProgressIndicator stopAnimation:nil]; + } + if ([imagePath isEqual: _dupePath]) + { + [dupeImage setImage:image]; + [dupeProgressIndicator stopAnimation:nil]; + } +} +@end diff --git a/pe/cocoa/DirectoryPanel.h b/pe/cocoa/DirectoryPanel.h new file mode 100644 index 00000000..6033367f --- /dev/null +++ b/pe/cocoa/DirectoryPanel.h @@ -0,0 +1,8 @@ +#import +#import "dgbase/DirectoryPanel.h" + +@interface DirectoryPanel : DirectoryPanelBase +{ +} +- (IBAction)addiPhoto:(id)sender; +@end diff --git a/pe/cocoa/DirectoryPanel.m b/pe/cocoa/DirectoryPanel.m new file mode 100644 index 00000000..9347ddd5 --- /dev/null +++ b/pe/cocoa/DirectoryPanel.m @@ -0,0 +1,44 @@ +#import "DirectoryPanel.h" +#import "ProgressController.h" + +static NSString* jobAddIPhoto = @"jobAddIPhoto"; + +@implementation DirectoryPanel +- (id)initWithParentApp:(id)aParentApp +{ + self = [super initWithParentApp:aParentApp]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jobCompleted:) name:JobCompletedNotification object:nil]; + return self; +} + +- (IBAction)addiPhoto:(id)sender +{ + [[ProgressController mainProgressController] setJobDesc:@"Adding iPhoto Library..."]; + [[ProgressController mainProgressController] setJobId:jobAddIPhoto]; + [[ProgressController mainProgressController] showSheetForParent:[self window]]; + [self addDirectory:@"iPhoto Library"]; +} + +- (IBAction)popupAddDirectoryMenu:(id)sender +{ + NSMenu *m = [addButtonPopUp menu]; + while ([m numberOfItems] > 0) + [m removeItemAtIndex:0]; + NSMenuItem *mi = [m addItemWithTitle:@"Add New Directory..." action:@selector(askForDirectory:) keyEquivalent:@""]; + [mi setTarget:self]; + mi = [m addItemWithTitle:@"Add iPhoto Directory" action:@selector(addiPhoto:) keyEquivalent:@""]; + [mi setTarget:self]; + [m addItem:[NSMenuItem separatorItem]]; + [_recentDirectories fillMenu:m]; + [addButtonPopUp selectItem:nil]; + [[addButtonPopUp cell] performClickWithFrame:[sender frame] inView:[sender superview]]; +} + +- (void)jobCompleted:(NSNotification *)aNotification +{ + if ([[ProgressController mainProgressController] jobId] == jobAddIPhoto) + { + [directories reloadData]; + } +} +@end diff --git a/pe/cocoa/English.lproj/Details.nib/classes.nib b/pe/cocoa/English.lproj/Details.nib/classes.nib new file mode 100644 index 00000000..f39cb617 --- /dev/null +++ b/pe/cocoa/English.lproj/Details.nib/classes.nib @@ -0,0 +1,24 @@ +{ + IBClasses = ( + { + CLASS = DetailsPanel; + LANGUAGE = ObjC; + OUTLETS = { + detailsTable = NSTableView; + dupeImage = NSImageView; + dupeProgressIndicator = NSProgressIndicator; + refImage = NSImageView; + refProgressIndicator = NSProgressIndicator; + }; + SUPERCLASS = NSWindowController; + }, + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + CLASS = TableView; + LANGUAGE = ObjC; + OUTLETS = {py = PyApp; }; + SUPERCLASS = NSTableView; + } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/pe/cocoa/English.lproj/Details.nib/info.nib b/pe/cocoa/English.lproj/Details.nib/info.nib new file mode 100644 index 00000000..3ad9dc9e --- /dev/null +++ b/pe/cocoa/English.lproj/Details.nib/info.nib @@ -0,0 +1,16 @@ + + + + + IBDocumentLocation + 701 68 356 240 0 0 1440 878 + IBFramework Version + 446.1 + IBOpenObjects + + 5 + + IBSystem Version + 8R2232 + + diff --git a/pe/cocoa/English.lproj/Details.nib/keyedobjects.nib b/pe/cocoa/English.lproj/Details.nib/keyedobjects.nib new file mode 100644 index 00000000..dfc61c70 Binary files /dev/null and b/pe/cocoa/English.lproj/Details.nib/keyedobjects.nib differ diff --git a/pe/cocoa/English.lproj/Directories.nib/classes.nib b/pe/cocoa/English.lproj/Directories.nib/classes.nib new file mode 100644 index 00000000..3ebaa96a --- /dev/null +++ b/pe/cocoa/English.lproj/Directories.nib/classes.nib @@ -0,0 +1,62 @@ + + + + + IBClasses + + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + ACTIONS + + askForDirectory + id + changeDirectoryState + id + popupAddDirectoryMenu + id + removeSelectedDirectory + id + toggleVisible + id + + CLASS + DirectoryPanel + LANGUAGE + ObjC + OUTLETS + + addButtonPopUp + NSPopUpButton + directories + NSOutlineView + removeButton + NSButton + + SUPERCLASS + DirectoryPanelBase + + + CLASS + OutlineView + LANGUAGE + ObjC + OUTLETS + + py + PyApp + + SUPERCLASS + NSOutlineView + + + IBVersion + 1 + + diff --git a/pe/cocoa/English.lproj/Directories.nib/info.nib b/pe/cocoa/English.lproj/Directories.nib/info.nib new file mode 100644 index 00000000..77f19ce7 --- /dev/null +++ b/pe/cocoa/English.lproj/Directories.nib/info.nib @@ -0,0 +1,20 @@ + + + + + IBFramework Version + 629 + IBLastKnownRelativeProjectPath + ../../dupeguru.xcodeproj + IBOldestOS + 5 + IBOpenObjects + + 5 + + IBSystem Version + 9B18 + targetFramework + IBCocoaFramework + + diff --git a/pe/cocoa/English.lproj/Directories.nib/keyedobjects.nib b/pe/cocoa/English.lproj/Directories.nib/keyedobjects.nib new file mode 100644 index 00000000..906ea9c3 Binary files /dev/null and b/pe/cocoa/English.lproj/Directories.nib/keyedobjects.nib differ diff --git a/pe/cocoa/English.lproj/InfoPlist.strings b/pe/cocoa/English.lproj/InfoPlist.strings new file mode 100644 index 00000000..d224a14b Binary files /dev/null and b/pe/cocoa/English.lproj/InfoPlist.strings differ diff --git a/pe/cocoa/English.lproj/MainMenu.nib/classes.nib b/pe/cocoa/English.lproj/MainMenu.nib/classes.nib new file mode 100644 index 00000000..fbce5b56 --- /dev/null +++ b/pe/cocoa/English.lproj/MainMenu.nib/classes.nib @@ -0,0 +1,235 @@ + + + + + IBClasses + + + CLASS + NSSegmentedControl + LANGUAGE + ObjC + SUPERCLASS + NSControl + + + ACTIONS + + openWebsite + id + toggleDetailsPanel + id + toggleDirectories + id + unlockApp + id + + CLASS + AppDelegate + LANGUAGE + ObjC + OUTLETS + + py + PyDupeGuru + recentDirectories + RecentDirectories + result + ResultWindow + unlockMenuItem + NSMenuItem + + SUPERCLASS + NSObject + + + CLASS + PyApp + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + CLASS + MatchesView + LANGUAGE + ObjC + SUPERCLASS + OutlineView + + + CLASS + PyDupeGuru + LANGUAGE + ObjC + SUPERCLASS + PyApp + + + ACTIONS + + changeDelta + id + changePowerMarker + id + clearIgnoreList + id + clearPictureCache + id + collapseAll + id + copyMarked + id + deleteMarked + id + expandAll + id + exportToXHTML + id + filter + id + ignoreSelected + id + markAll + id + markInvert + id + markNone + id + markSelected + id + markToggle + id + moveMarked + id + openSelected + id + refresh + id + removeMarked + id + removeSelected + id + renameSelected + id + resetColumnsToDefault + id + revealSelected + id + showPreferencesPanel + id + startDuplicateScan + id + switchSelected + id + toggleColumn + id + toggleDelta + id + toggleDetailsPanel + id + toggleDirectories + id + togglePowerMarker + id + + CLASS + ResultWindow + LANGUAGE + ObjC + OUTLETS + + actionMenu + NSPopUpButton + actionMenuView + NSView + app + id + columnsMenu + NSMenu + deltaSwitch + NSSegmentedControl + deltaSwitchView + NSView + filterField + NSSearchField + filterFieldView + NSView + matches + MatchesView + pmSwitch + NSSegmentedControl + pmSwitchView + NSView + preferencesPanel + NSWindow + py + PyDupeGuru + stats + NSTextField + + SUPERCLASS + NSWindowController + + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + ACTIONS + + checkForUpdates + id + + CLASS + SUUpdater + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + ACTIONS + + clearMenu + id + menuClick + id + + CLASS + RecentDirectories + LANGUAGE + ObjC + OUTLETS + + delegate + id + menu + NSMenu + + SUPERCLASS + NSObject + + + CLASS + OutlineView + LANGUAGE + ObjC + OUTLETS + + py + PyApp + + SUPERCLASS + NSOutlineView + + + IBVersion + 1 + + diff --git a/pe/cocoa/English.lproj/MainMenu.nib/info.nib b/pe/cocoa/English.lproj/MainMenu.nib/info.nib new file mode 100644 index 00000000..a75b8270 --- /dev/null +++ b/pe/cocoa/English.lproj/MainMenu.nib/info.nib @@ -0,0 +1,20 @@ + + + + + IBFramework Version + 629 + IBLastKnownRelativeProjectPath + ../../dupeguru.xcodeproj + IBOldestOS + 4 + IBOpenObjects + + 524 + + IBSystem Version + 9B18 + targetFramework + IBCocoaFramework + + diff --git a/pe/cocoa/English.lproj/MainMenu.nib/keyedobjects.nib b/pe/cocoa/English.lproj/MainMenu.nib/keyedobjects.nib new file mode 100644 index 00000000..1c9f4e3c Binary files /dev/null and b/pe/cocoa/English.lproj/MainMenu.nib/keyedobjects.nib differ diff --git a/pe/cocoa/Info.plist b/pe/cocoa/Info.plist new file mode 100644 index 00000000..6be0548d --- /dev/null +++ b/pe/cocoa/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleHelpBookFolder + dupeguru_pe_help + CFBundleHelpBookName + dupeGuru PE Help + CFBundleIconFile + dupeguru + CFBundleIdentifier + com.hardcoded_software.dupeguru_pe + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + hsft + CFBundleVersion + 1.7.2 + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + SUFeedURL + http://www.hardcoded.net/updates/dupeguru_pe.appcast + + diff --git a/pe/cocoa/PictureBlocks.h b/pe/cocoa/PictureBlocks.h new file mode 100644 index 00000000..6b1a5160 --- /dev/null +++ b/pe/cocoa/PictureBlocks.h @@ -0,0 +1,11 @@ +#import + + +@interface PictureBlocks : NSObject { +} ++ (NSString *)getBlocksFromImagePath:(NSString *)imagePath blockCount:(NSNumber *)blockCount scanArea:(NSNumber *)scanArea; ++ (NSSize)getImageSize:(NSString *)imagePath; +@end + + +NSString* GetBlocks(NSString *filePath, int blockCount, int scanSize); \ No newline at end of file diff --git a/pe/cocoa/PictureBlocks.m b/pe/cocoa/PictureBlocks.m new file mode 100644 index 00000000..bc743694 --- /dev/null +++ b/pe/cocoa/PictureBlocks.m @@ -0,0 +1,139 @@ +#import "PictureBlocks.h" +#import "Utils.h" + + +@implementation PictureBlocks ++ (NSString *)getBlocksFromImagePath:(NSString *)imagePath blockCount:(NSNumber *)blockCount scanArea:(NSNumber *)scanArea +{ + return GetBlocks(imagePath, n2i(blockCount), n2i(scanArea)); +} + ++ (NSSize)getImageSize:(NSString *)imagePath +{ + CFURLRef fileURL = CFURLCreateWithFileSystemPath(NULL, (CFStringRef)imagePath, kCFURLPOSIXPathStyle, FALSE); + CGImageSourceRef source = CGImageSourceCreateWithURL(fileURL, NULL); + if (source == NULL) + return NSMakeSize(0, 0); + CGImageRef image = CGImageSourceCreateImageAtIndex(source, 0, NULL); + if (image == NULL) + return NSMakeSize(0, 0); + size_t width = CGImageGetWidth(image); + size_t height = CGImageGetHeight(image); + CGImageRelease(image); + CFRelease(source); + CFRelease(fileURL); + return NSMakeSize(width, height); +} +@end + + CGContextRef MyCreateBitmapContext (int width, int height) + { + CGContextRef context = NULL; + CGColorSpaceRef colorSpace; + void * bitmapData; + int bitmapByteCount; + int bitmapBytesPerRow; + + bitmapBytesPerRow = (width * 4); + bitmapByteCount = (bitmapBytesPerRow * height); + + colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); + + bitmapData = malloc( bitmapByteCount ); + if (bitmapData == NULL) + { + fprintf (stderr, "Memory not allocated!"); + return NULL; + } + + context = CGBitmapContextCreate (bitmapData,width,height,8,bitmapBytesPerRow,colorSpace,kCGImageAlphaNoneSkipLast); + if (context== NULL) + { + free (bitmapData); + fprintf (stderr, "Context not created!"); + return NULL; + } + CGColorSpaceRelease( colorSpace ); + return context; + } + + // returns 0x00RRGGBB + int GetBlock(unsigned char *imageData, int imageWidth, int imageHeight, int boxX, int boxY, int boxW, int boxH) + { + int i,j; + int totalR = 0; + int totalG = 0; + int totalB = 0; + for(i = boxY; i < boxY + boxH; i++) + { + for(j = boxX; j < boxX + boxW; j++) + { + int offset = (i * imageWidth * 4) + (j * 4); + totalR += *(imageData + offset); + totalG += *(imageData + offset + 1); + totalB += *(imageData + offset + 2); + } + } + int pixelCount = boxH * boxW; + int result = 0; + result += (totalR / pixelCount) << 16; + result += (totalG / pixelCount) << 8; + result += (totalB / pixelCount); + return result; + } + + NSString* GetBlocks (NSString* filePath, int blockCount, int scanSize) + { + CFURLRef fileURL = CFURLCreateWithFileSystemPath(NULL, (CFStringRef)filePath, kCFURLPOSIXPathStyle, FALSE); + CGImageSourceRef source = CGImageSourceCreateWithURL(fileURL, NULL); + if (source == NULL) + return NULL; + CGImageRef image = CGImageSourceCreateImageAtIndex(source, 0, NULL); + if (image == NULL) + return NULL; + size_t width = CGImageGetWidth(image); + size_t height = CGImageGetHeight(image); + if ((scanSize > 0) && (width > scanSize)) + width = scanSize; + if ((scanSize > 0) && (height > scanSize)) + height = scanSize; + CGContextRef myContext = MyCreateBitmapContext(width, height); + CGRect myBoundingBox = CGRectMake (0, 0, width, height); + CGContextDrawImage(myContext, myBoundingBox, image); + unsigned char *bitmapData = CGBitmapContextGetData(myContext); + if (bitmapData == NULL) + return NULL; + + int blockHeight = height / blockCount; + if (blockHeight < 1) + blockHeight = 1; + int blockWidth = width / blockCount; + if (blockWidth < 1) + blockWidth = 1; + //blockCount might have changed + int blockXCount = (width / blockWidth); + int blockYCount = (height / blockHeight); + + CFMutableArrayRef blocks = CFArrayCreateMutable(NULL, blockXCount * blockYCount, &kCFTypeArrayCallBacks); + int i,j; + for(i = 0; i < blockYCount; i++) + { + for(j = 0; j < blockXCount; j++) + { + int block = GetBlock(bitmapData, width, height, j * blockWidth, i * blockHeight, blockWidth, blockHeight); + CFStringRef strBlock = CFStringCreateWithFormat(NULL, NULL, CFSTR("%06x"), block); + CFArrayAppendValue(blocks, strBlock); + CFRelease(strBlock); + } + } + + CGContextRelease (myContext); + if (bitmapData) free(bitmapData); + CGImageRelease(image); + CFRelease(source); + CFRelease(fileURL); + + CFStringRef result = CFStringCreateByCombiningStrings(NULL, blocks, CFSTR("")); + CFRelease(blocks); + return (NSString *)result; + } \ No newline at end of file diff --git a/pe/cocoa/PyDupeGuru.h b/pe/cocoa/PyDupeGuru.h new file mode 100644 index 00000000..8ced12b6 --- /dev/null +++ b/pe/cocoa/PyDupeGuru.h @@ -0,0 +1,9 @@ +#import +#import "dgbase/PyDupeGuru.h" + +@interface PyDupeGuru : PyDupeGuruBase +- (void)clearPictureCache; +- (NSString *)getSelectedDupePath; +- (NSString *)getSelectedDupeRefPath; +- (void)setMatchScaled:(NSNumber *)match_scaled; +@end diff --git a/pe/cocoa/ResultWindow.h b/pe/cocoa/ResultWindow.h new file mode 100644 index 00000000..dcc96079 --- /dev/null +++ b/pe/cocoa/ResultWindow.h @@ -0,0 +1,59 @@ +#import +#import "Outline.h" +#import "dgbase/ResultWindow.h" +#import "DirectoryPanel.h" + +@interface ResultWindow : ResultWindowBase +{ + IBOutlet NSPopUpButton *actionMenu; + IBOutlet NSView *actionMenuView; + IBOutlet id app; + IBOutlet NSMenu *columnsMenu; + IBOutlet NSView *deltaSwitchView; + IBOutlet NSSearchField *filterField; + IBOutlet NSView *filterFieldView; + IBOutlet NSSegmentedControl *pmSwitch; + IBOutlet NSView *pmSwitchView; + IBOutlet NSWindow *preferencesPanel; + IBOutlet NSTextField *stats; + + NSMutableArray *_resultColumns; + NSMutableIndexSet *_deltaColumns; +} +- (IBAction)changePowerMarker:(id)sender; +- (IBAction)clearIgnoreList:(id)sender; +- (IBAction)clearPictureCache:(id)sender; +- (IBAction)exportToXHTML:(id)sender; +- (IBAction)filter:(id)sender; +- (IBAction)ignoreSelected:(id)sender; +- (IBAction)markAll:(id)sender; +- (IBAction)markInvert:(id)sender; +- (IBAction)markNone:(id)sender; +- (IBAction)markSelected:(id)sender; +- (IBAction)markToggle:(id)sender; +- (IBAction)openSelected:(id)sender; +- (IBAction)refresh:(id)sender; +- (IBAction)removeMarked:(id)sender; +- (IBAction)removeSelected:(id)sender; +- (IBAction)renameSelected:(id)sender; +- (IBAction)resetColumnsToDefault:(id)sender; +- (IBAction)revealSelected:(id)sender; +- (IBAction)showPreferencesPanel:(id)sender; +- (IBAction)startDuplicateScan:(id)sender; +- (IBAction)switchSelected:(id)sender; +- (IBAction)toggleColumn:(id)sender; +- (IBAction)toggleDelta:(id)sender; +- (IBAction)toggleDetailsPanel:(id)sender; +- (IBAction)togglePowerMarker:(id)sender; +- (IBAction)toggleDirectories:(id)sender; + +- (NSTableColumn *)getColumnForIdentifier:(int)aIdentifier title:(NSString *)aTitle width:(int)aWidth refCol:(NSTableColumn *)aColumn; +- (NSArray *)getColumnsOrder; +- (NSDictionary *)getColumnsWidth; +- (NSArray *)getSelected:(BOOL)aDupesOnly; +- (NSArray *)getSelectedPaths:(BOOL)aDupesOnly; +- (void)performPySelection:(NSArray *)aIndexPaths; +- (void)initResultColumns; +- (void)refreshStats; +- (void)restoreColumnsPosition:(NSArray *)aColumnsOrder widths:(NSDictionary *)aColumnsWidth; +@end diff --git a/pe/cocoa/ResultWindow.m b/pe/cocoa/ResultWindow.m new file mode 100644 index 00000000..e0679e4f --- /dev/null +++ b/pe/cocoa/ResultWindow.m @@ -0,0 +1,569 @@ +#import "ResultWindow.h" +#import "Dialogs.h" +#import "ProgressController.h" +#import "RegistrationInterface.h" +#import "Utils.h" +#import "AppDelegate.h" +#import "Consts.h" + +static NSString* tbbDirectories = @"tbbDirectories"; +static NSString* tbbDetails = @"tbbDetail"; +static NSString* tbbPreferences = @"tbbPreferences"; +static NSString* tbbPowerMarker = @"tbbPowerMarker"; +static NSString* tbbScan = @"tbbScan"; +static NSString* tbbAction = @"tbbAction"; +static NSString* tbbDelta = @"tbbDelta"; +static NSString* tbbFilter = @"tbbFilter"; + +@implementation ResultWindow +/* Override */ +- (void)awakeFromNib +{ + [super awakeFromNib]; + _displayDelta = NO; + _powerMode = NO; + _deltaColumns = [[NSMutableIndexSet indexSetWithIndexesInRange:NSMakeRange(2,5)] retain]; + [_deltaColumns removeIndex:3]; + [_deltaColumns removeIndex:4]; + [deltaSwitch setSelectedSegment:0]; + [pmSwitch setSelectedSegment:0]; + [py setDisplayDeltaValues:b2n(_displayDelta)]; + [matches setTarget:self]; + [matches setDoubleAction:@selector(openSelected:)]; + [[actionMenu itemAtIndex:0] setImage:[NSImage imageNamed: @"gear"]]; + [self initResultColumns]; + [self refreshStats]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resultsMarkingChanged:) name:ResultsMarkingChangedNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resultsChanged:) name:ResultsChangedNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jobCompleted:) name:JobCompletedNotification object:nil]; + + NSToolbar *t = [[[NSToolbar alloc] initWithIdentifier:@"ResultWindowToolbar"] autorelease]; + [t setAllowsUserCustomization:YES]; + [t setAutosavesConfiguration:NO]; + [t setDisplayMode:NSToolbarDisplayModeIconAndLabel]; + [t setDelegate:self]; + [[self window] setToolbar:t]; +} + +/* Actions */ + +- (IBAction)changePowerMarker:(id)sender +{ + _powerMode = [pmSwitch selectedSegment] == 1; + if (_powerMode) + [matches setTag:2]; + else + [matches setTag:0]; + [self expandAll:nil]; + [self outlineView:matches didClickTableColumn:nil]; +} + +- (IBAction)clearIgnoreList:(id)sender +{ + int i = n2i([py getIgnoreListCount]); + if (!i) + return; + if ([Dialogs askYesNo:[NSString stringWithFormat:@"Do you really want to remove all %d items from the ignore list?",i]] == NSAlertSecondButtonReturn) // NO + return; + [py clearIgnoreList]; +} + +- (IBAction)clearPictureCache:(id)sender +{ + if ([Dialogs askYesNo:@"Do you really want to remove all your cached picture analysis?"] == NSAlertSecondButtonReturn) // NO + return; + [(PyDupeGuru *)py clearPictureCache]; +} + +- (IBAction)exportToXHTML:(id)sender +{ + NSString *xsltPath = [[NSBundle mainBundle] pathForResource:@"dg" ofType:@"xsl"]; + NSString *cssPath = [[NSBundle mainBundle] pathForResource:@"hardcoded" ofType:@"css"]; + NSString *exported = [py exportToXHTMLwithColumns:[self getColumnsOrder] xslt:xsltPath css:cssPath]; + [[NSWorkspace sharedWorkspace] openFile:exported]; +} + +- (IBAction)filter:(id)sender +{ + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + [py setEscapeFilterRegexp:b2n(!n2b([ud objectForKey:@"useRegexpFilter"]))]; + [py applyFilter:[filterField stringValue]]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)ignoreSelected:(id)sender +{ + NSArray *nodeList = [self getSelected:YES]; + if (![nodeList count]) + return; + if ([Dialogs askYesNo:[NSString stringWithFormat:@"All selected %d matches are going to be ignored in all subsequent scans. Continue?",[nodeList count]]] == NSAlertSecondButtonReturn) // NO + return; + [self performPySelection:[self getSelectedPaths:YES]]; + [py addSelectedToIgnoreList]; + [py removeSelected]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)markAll:(id)sender +{ + [py markAll]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsMarkingChangedNotification object:self]; +} + +- (IBAction)markInvert:(id)sender +{ + [py markInvert]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsMarkingChangedNotification object:self]; +} + +- (IBAction)markNone:(id)sender +{ + [py markNone]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsMarkingChangedNotification object:self]; +} + +- (IBAction)markSelected:(id)sender +{ + [self performPySelection:[self getSelectedPaths:YES]]; + [py toggleSelectedMark]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsMarkingChangedNotification object:self]; +} + +- (IBAction)markToggle:(id)sender +{ + OVNode *node = [matches itemAtRow:[matches clickedRow]]; + [self performPySelection:[NSArray arrayWithObject:p2a([node indexPath])]]; + [py toggleSelectedMark]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsMarkingChangedNotification object:self]; +} + +- (IBAction)openSelected:(id)sender +{ + [self performPySelection:[self getSelectedPaths:NO]]; + [py openSelected]; +} + +- (IBAction)refresh:(id)sender +{ + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)removeMarked:(id)sender +{ + int mark_count = [[py getMarkCount] intValue]; + if (!mark_count) + return; + if ([Dialogs askYesNo:[NSString stringWithFormat:@"You are about to remove %d files from results. Continue?",mark_count]] == NSAlertSecondButtonReturn) // NO + return; + [py removeMarked]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)removeSelected:(id)sender +{ + NSArray *nodeList = [self getSelected:YES]; + if (![nodeList count]) + return; + if ([Dialogs askYesNo:[NSString stringWithFormat:@"You are about to remove %d files from results. Continue?",[nodeList count]]] == NSAlertSecondButtonReturn) // NO + return; + [self performPySelection:[self getSelectedPaths:YES]]; + [py removeSelected]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)renameSelected:(id)sender +{ + int col = [matches columnWithIdentifier:@"0"]; + int row = [matches selectedRow]; + [matches editColumn:col row:row withEvent:[NSApp currentEvent] select:YES]; +} + +- (IBAction)resetColumnsToDefault:(id)sender +{ + NSMutableArray *columnsOrder = [NSMutableArray array]; + [columnsOrder addObject:@"0"]; + [columnsOrder addObject:@"1"]; + [columnsOrder addObject:@"2"]; + [columnsOrder addObject:@"4"]; + [columnsOrder addObject:@"7"]; + NSMutableDictionary *columnsWidth = [NSMutableDictionary dictionary]; + [columnsWidth setObject:i2n(125) forKey:@"0"]; + [columnsWidth setObject:i2n(120) forKey:@"1"]; + [columnsWidth setObject:i2n(63) forKey:@"2"]; + [columnsWidth setObject:i2n(73) forKey:@"4"]; + [columnsWidth setObject:i2n(58) forKey:@"7"]; + [self restoreColumnsPosition:columnsOrder widths:columnsWidth]; +} + +- (IBAction)revealSelected:(id)sender +{ + [self performPySelection:[self getSelectedPaths:NO]]; + [py revealSelected]; +} + +- (IBAction)showPreferencesPanel:(id)sender +{ + [preferencesPanel makeKeyAndOrderFront:sender]; +} + +- (IBAction)startDuplicateScan:(id)sender +{ + if ([matches numberOfRows] > 0) + { + if ([Dialogs askYesNo:@"Are you sure you want to start a new duplicate scan?"] == NSAlertSecondButtonReturn) // NO + return; + } + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + PyDupeGuru *_py = (PyDupeGuru *)py; + [_py setMinMatchPercentage:[ud objectForKey:@"minMatchPercentage"]]; + [_py setMixFileKind:[ud objectForKey:@"mixFileKind"]]; + [_py setMatchScaled:[ud objectForKey:@"matchScaled"]]; + int r = n2i([py doScan]); + [matches reloadData]; + [self refreshStats]; + if (r != 0) + [[ProgressController mainProgressController] hide]; + if (r == 1) + [Dialogs showMessage:@"You cannot make a duplicate scan with only reference directories."]; + if (r == 3) + { + [Dialogs showMessage:@"The selected directories contain no scannable file."]; + [app toggleDirectories:nil]; + } +} + +- (IBAction)switchSelected:(id)sender +{ + [self performPySelection:[self getSelectedPaths:YES]]; + [py makeSelectedReference]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)toggleColumn:(id)sender +{ + NSMenuItem *mi = sender; + NSString *colId = [NSString stringWithFormat:@"%d",[mi tag]]; + NSTableColumn *col = [matches tableColumnWithIdentifier:colId]; + if (col == nil) + { + //Add Column + col = [_resultColumns objectAtIndex:[mi tag]]; + [matches addTableColumn:col]; + [mi setState:NSOnState]; + } + else + { + //Remove column + [matches removeTableColumn:col]; + [mi setState:NSOffState]; + } +} + +- (IBAction)toggleDelta:(id)sender +{ + if ([deltaSwitch selectedSegment] == 1) + [deltaSwitch setSelectedSegment:0]; + else + [deltaSwitch setSelectedSegment:1]; + [self changeDelta:sender]; +} + + +- (IBAction)toggleDetailsPanel:(id)sender +{ + [(AppDelegate *)app toggleDetailsPanel:sender]; +} + +- (IBAction)togglePowerMarker:(id)sender +{ + if ([pmSwitch selectedSegment] == 1) + [pmSwitch setSelectedSegment:0]; + else + [pmSwitch setSelectedSegment:1]; + [self changePowerMarker:sender]; +} + +- (IBAction)toggleDirectories:(id)sender +{ + [(AppDelegate *)app toggleDirectories:sender]; +} + +/* Public */ +- (NSTableColumn *)getColumnForIdentifier:(int)aIdentifier title:(NSString *)aTitle width:(int)aWidth refCol:(NSTableColumn *)aColumn +{ + NSNumber *n = [NSNumber numberWithInt:aIdentifier]; + NSTableColumn *col = [[NSTableColumn alloc] initWithIdentifier:[n stringValue]]; + [col setWidth:aWidth]; + [col setEditable:NO]; + [[col dataCell] setFont:[[aColumn dataCell] font]]; + [[col headerCell] setStringValue:aTitle]; + [col setResizingMask:NSTableColumnUserResizingMask]; + [col setSortDescriptorPrototype:[[NSSortDescriptor alloc] initWithKey:[n stringValue] ascending:YES]]; + return col; +} + +//Returns an array of identifiers, in order. +- (NSArray *)getColumnsOrder +{ + NSTableColumn *col; + NSString *colId; + NSMutableArray *result = [NSMutableArray array]; + NSEnumerator *e = [[matches tableColumns] objectEnumerator]; + while (col = [e nextObject]) + { + colId = [col identifier]; + [result addObject:colId]; + } + return result; +} + +- (NSDictionary *)getColumnsWidth +{ + NSMutableDictionary *result = [NSMutableDictionary dictionary]; + NSTableColumn *col; + NSString *colId; + NSNumber *width; + NSEnumerator *e = [[matches tableColumns] objectEnumerator]; + while (col = [e nextObject]) + { + colId = [col identifier]; + width = [NSNumber numberWithFloat:[col width]]; + [result setObject:width forKey:colId]; + } + return result; +} + +- (NSArray *)getSelected:(BOOL)aDupesOnly +{ + if (_powerMode) + aDupesOnly = NO; + NSIndexSet *indexes = [matches selectedRowIndexes]; + NSMutableArray *nodeList = [NSMutableArray array]; + OVNode *node; + int i = [indexes firstIndex]; + while (i != NSNotFound) + { + node = [matches itemAtRow:i]; + if (!aDupesOnly || ([node level] > 1)) + [nodeList addObject:node]; + i = [indexes indexGreaterThanIndex:i]; + } + return nodeList; +} + +- (NSArray *)getSelectedPaths:(BOOL)aDupesOnly +{ + NSMutableArray *r = [NSMutableArray array]; + NSArray *selected = [self getSelected:aDupesOnly]; + NSEnumerator *e = [selected objectEnumerator]; + OVNode *node; + while (node = [e nextObject]) + [r addObject:p2a([node indexPath])]; + return r; +} + +- (void)performPySelection:(NSArray *)aIndexPaths +{ + if (_powerMode) + [py selectPowerMarkerNodePaths:aIndexPaths]; + else + [py selectResultNodePaths:aIndexPaths]; +} + +- (void)initResultColumns +{ + NSTableColumn *refCol = [matches tableColumnWithIdentifier:@"0"]; + _resultColumns = [[NSMutableArray alloc] init]; + [_resultColumns addObject:[matches tableColumnWithIdentifier:@"0"]]; // File Name + [_resultColumns addObject:[matches tableColumnWithIdentifier:@"1"]]; // Directory + [_resultColumns addObject:[matches tableColumnWithIdentifier:@"2"]]; // Size + [_resultColumns addObject:[self getColumnForIdentifier:3 title:@"Kind" width:40 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:4 title:@"Dimensions" width:80 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:5 title:@"Creation" width:120 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:6 title:@"Modification" width:120 refCol:refCol]]; + [_resultColumns addObject:[matches tableColumnWithIdentifier:@"7"]]; // Match % + [_resultColumns addObject:[self getColumnForIdentifier:8 title:@"Dupe Count" width:80 refCol:refCol]]; +} + +-(void)refreshStats +{ + [stats setStringValue:[py getStatLine]]; +} + +- (void)restoreColumnsPosition:(NSArray *)aColumnsOrder widths:(NSDictionary *)aColumnsWidth +{ + NSTableColumn *col; + NSString *colId; + NSNumber *width; + NSMenuItem *mi; + //Remove all columns + NSEnumerator *e = [[columnsMenu itemArray] objectEnumerator]; + while (mi = [e nextObject]) + { + if ([mi state] == NSOnState) + [self toggleColumn:mi]; + } + //Add columns and set widths + e = [aColumnsOrder objectEnumerator]; + while (colId = [e nextObject]) + { + if (![colId isEqual:@"mark"]) + { + col = [_resultColumns objectAtIndex:[colId intValue]]; + width = [aColumnsWidth objectForKey:[col identifier]]; + mi = [columnsMenu itemWithTag:[colId intValue]]; + if (width) + [col setWidth:[width floatValue]]; + [self toggleColumn:mi]; + } + } +} + +/* Delegate */ +- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item +{ + OVNode *node = item; + if ([[tableColumn identifier] isEqual:@"mark"]) + { + [cell setEnabled: [node isMarkable]]; + } + if ([cell isKindOfClass:[NSTextFieldCell class]]) + { + // Determine if the text color will be blue due to directory being reference. + NSTextFieldCell *textCell = cell; + if ([node isMarkable]) + [textCell setTextColor:[NSColor blackColor]]; + else + [textCell setTextColor:[NSColor blueColor]]; + if ((_displayDelta) && (_powerMode || ([node level] > 1))) + { + int i = [[tableColumn identifier] intValue]; + if ([_deltaColumns containsIndex:i]) + [textCell setTextColor:[NSColor orangeColor]]; + } + } +} + +- (void)outlineViewSelectionDidChange:(NSNotification *)notification +{ + [self performPySelection:[self getSelectedPaths:NO]]; + [py refreshDetailsWithSelected]; + [[NSNotificationCenter defaultCenter] postNotificationName:DuplicateSelectionChangedNotification object:self]; +} + +- (void)resultsChanged:(NSNotification *)aNotification +{ + [matches reloadData]; + [self expandAll:nil]; + [self outlineViewSelectionDidChange:nil]; + [self refreshStats]; +} + +- (void)resultsMarkingChanged:(NSNotification *)aNotification +{ + [matches invalidateMarkings]; + [self refreshStats]; +} + +/* Toolbar */ + +- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag +{ + NSToolbarItem *tbi = [[[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier] autorelease]; + if (itemIdentifier == tbbDirectories) + { + [tbi setLabel: @"Directories"]; + [tbi setToolTip: @"Show/Hide the directories panel."]; + [tbi setImage: [NSImage imageNamed: @"folder32"]]; + [tbi setTarget: self]; + [tbi setAction: @selector(toggleDirectories:)]; + } + else if (itemIdentifier == tbbDetails) + { + [tbi setLabel: @"Details"]; + [tbi setToolTip: @"Show/Hide the details panel."]; + [tbi setImage: [NSImage imageNamed: @"details32"]]; + [tbi setTarget: self]; + [tbi setAction: @selector(toggleDetailsPanel:)]; + } + else if (itemIdentifier == tbbPreferences) + { + [tbi setLabel: @"Preferences"]; + [tbi setToolTip: @"Show the preferences panel."]; + [tbi setImage: [NSImage imageNamed: @"preferences32"]]; + [tbi setTarget: self]; + [tbi setAction: @selector(showPreferencesPanel:)]; + } + else if (itemIdentifier == tbbPowerMarker) + { + [tbi setLabel: @"Power Marker"]; + [tbi setToolTip: @"When enabled, only the duplicates are shown, not the references."]; + [tbi setView:pmSwitchView]; + [tbi setMinSize:[pmSwitchView frame].size]; + [tbi setMaxSize:[pmSwitchView frame].size]; + } + else if (itemIdentifier == tbbScan) + { + [tbi setLabel: @"Start Scanning"]; + [tbi setToolTip: @"Start scanning for duplicates in the selected diectories."]; + [tbi setImage: [NSImage imageNamed: @"dgpe_logo_32"]]; + [tbi setTarget: self]; + [tbi setAction: @selector(startDuplicateScan:)]; + } + else if (itemIdentifier == tbbAction) + { + [tbi setLabel: @"Action"]; + [tbi setView:actionMenuView]; + [tbi setMinSize:[actionMenuView frame].size]; + [tbi setMaxSize:[actionMenuView frame].size]; + } + else if (itemIdentifier == tbbDelta) + { + [tbi setLabel: @"Delta Values"]; + [tbi setToolTip: @"When enabled, this option makes dupeGuru display, where applicable, delta values instead of absolute values."]; + [tbi setView:deltaSwitchView]; + [tbi setMinSize:[deltaSwitchView frame].size]; + [tbi setMaxSize:[deltaSwitchView frame].size]; + } + else if (itemIdentifier == tbbFilter) + { + [tbi setLabel: @"Filter"]; + [tbi setToolTip: @"Filters the results using regular expression."]; + [tbi setView:filterFieldView]; + [tbi setMinSize:[filterFieldView frame].size]; + [tbi setMaxSize:NSMakeSize(1000, [filterFieldView frame].size.height)]; + } + [tbi setPaletteLabel: [tbi label]]; + return tbi; +} + +- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar +{ + return [NSArray arrayWithObjects: + tbbDirectories, + tbbDetails, + tbbPreferences, + tbbPowerMarker, + tbbScan, + tbbAction, + tbbDelta, + tbbFilter, + NSToolbarSeparatorItemIdentifier, + NSToolbarSpaceItemIdentifier, + NSToolbarFlexibleSpaceItemIdentifier, + nil]; +} + +- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar +{ + return [NSArray arrayWithObjects: + tbbScan, + tbbAction, + tbbDirectories, + tbbDetails, + tbbPowerMarker, + tbbDelta, + tbbFilter, + nil]; +} +@end \ No newline at end of file diff --git a/pe/cocoa/dupeguru.icns b/pe/cocoa/dupeguru.icns new file mode 100755 index 00000000..c143ed86 Binary files /dev/null and b/pe/cocoa/dupeguru.icns differ diff --git a/pe/cocoa/dupeguru.xcodeproj/hsoft.mode1 b/pe/cocoa/dupeguru.xcodeproj/hsoft.mode1 new file mode 100644 index 00000000..699331ae --- /dev/null +++ b/pe/cocoa/dupeguru.xcodeproj/hsoft.mode1 @@ -0,0 +1,1380 @@ + + + + + ActivePerspectiveName + Project + AllowedModules + + + BundleLoadPath + + MaxInstances + n + Module + PBXSmartGroupTreeModule + Name + Groups and Files Outline View + + + BundleLoadPath + + MaxInstances + n + Module + PBXNavigatorGroup + Name + Editor + + + BundleLoadPath + + MaxInstances + n + Module + XCTaskListModule + Name + Task List + + + BundleLoadPath + + MaxInstances + n + Module + XCDetailModule + Name + File and Smart Group Detail Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXBuildResultsModule + Name + Detailed Build Results Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXProjectFindModule + Name + Project Batch Find Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXRunSessionModule + Name + Run Log + + + BundleLoadPath + + MaxInstances + n + Module + PBXBookmarksModule + Name + Bookmarks Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXClassBrowserModule + Name + Class Browser + + + BundleLoadPath + + MaxInstances + n + Module + PBXCVSModule + Name + Source Code Control Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXDebugBreakpointsModule + Name + Debug Breakpoints Tool + + + BundleLoadPath + + MaxInstances + n + Module + XCDockableInspector + Name + Inspector + + + BundleLoadPath + + MaxInstances + n + Module + PBXOpenQuicklyModule + Name + Open Quickly Tool + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugSessionModule + Name + Debugger + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugCLIModule + Name + Debug Console + + + Description + DefaultDescriptionKey + DockingSystemVisible + + Extension + mode1 + FavBarConfig + + PBXProjectModuleGUID + CE381CB409914B41003581CE + XCBarModuleItemNames + + XCBarModuleItems + + + FirstTimeWindowDisplayed + + Identifier + com.apple.perspectives.project.mode1 + MajorVersion + 31 + MinorVersion + 1 + Name + Default + Notifications + + OpenEditors + + PerspectiveWidths + + -1 + -1 + + Perspectives + + + ChosenToolbarItems + + active-executable-popup + action + active-buildstyle-popup + active-target-popup + buildOrClean + build-and-runOrDebug + com.apple.ide.PBXToolbarStopButton + get-info + toggle-editor + + ControllerClassBaseName + + IconName + WindowOfProjectWithEditor + Identifier + perspective.project + IsVertical + + Layout + + + BecomeActive + + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C08E77C0454961000C914BD + 1C37FABC05509CD000000102 + 1C37FABC05539CD112110102 + E2644B35053B69B200211256 + 1C37FABC04509CD000100104 + 1CC0EA4004350EF90044410B + 1CC0EA4004350EF90041110B + + PBXProjectModuleGUID + 1CE0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 194 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 29B97314FDCFA39411CA2CEA + 080E96DDFE201D6D7F000001 + 29B97315FDCFA39411CA2CEA + 29B97317FDCFA39411CA2CEA + 29B97323FDCFA39411CA2CEA + 1058C7A0FEA54F0111CA2CBB + 19C28FACFE9D520D11CA2CBB + 1C37FBAC04509CD000000102 + CE2ACA9A0CA214440012E1E8 + CE2ACA9B0CA214440012E1E8 + CE2ACA9C0CA214440012E1E8 + CE2ACA9D0CA214440012E1E8 + 1C37FAAC04509CD000000102 + 1C37FABC05509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 17 + 15 + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {194, 764}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + + XCSharingToken + com.apple.Xcode.GFSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {211, 782}} + GroupTreeTableConfiguration + + MainColumn + 194 + + RubberWindowFrame + 4 54 1366 823 0 0 1440 878 + + Module + PBXSmartGroupTreeModule + Proportion + 211pt + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CE0B20306471E060097A5F4 + PBXProjectModuleLabel + PyDupeGuru.h + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1CE0B20406471E060097A5F4 + PBXProjectModuleLabel + PyDupeGuru.h + _historyCapacity + 10 + bookmark + CE2ACAA20CA214B50012E1E8 + history + + CEE22C420B9A163B000D3096 + CEE584280BACAE4E004F9755 + CEE586070BACBCA6004F9755 + CEE301880BF7350900D6840C + CEE301890BF7350900D6840C + CEE3018A0BF7350900D6840C + CEE301DC0BF73A0300D6840C + CEE301DD0BF73A0300D6840C + CEE301F30BF73A9A00D6840C + CEB6A23E0C9EA80D00767CC9 + + prevStack + + CE2CB4DA09AE70AA0015538F + CEF411510A11093E00E7F110 + CE6E6AE70AA528B2002F29BE + CEFA86C20AAEE6DE00E0FAA1 + CEFA86C30AAEE6DE00E0FAA1 + CED527320AB0C9EB00D70726 + CEE2E1F30AB0E4A900D458B6 + CEE2E1F40AB0E4A900D458B6 + CEF650770ABABB44009F3C83 + CEE3018C0BF7350900D6840C + CEE3018F0BF7350900D6840C + + + SplitCount + 1 + + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {1150, 544}} + RubberWindowFrame + 4 54 1366 823 0 0 1440 878 + + Module + PBXNavigatorGroup + Proportion + 544pt + + + ContentConfiguration + + PBXProjectModuleGUID + 1CE0B20506471E060097A5F4 + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{0, 549}, {1150, 233}} + RubberWindowFrame + 4 54 1366 823 0 0 1440 878 + + Module + XCDetailModule + Proportion + 233pt + + + Proportion + 1150pt + + + Name + Project + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + XCModuleDock + PBXNavigatorGroup + XCDetailModule + + TableOfContents + + CE2ACA9F0CA214440012E1E8 + 1CE0B1FE06471DED0097A5F4 + CE2ACAA00CA214440012E1E8 + 1CE0B20306471E060097A5F4 + 1CE0B20506471E060097A5F4 + + ToolbarConfiguration + xcode.toolbar.config.default + + + ControllerClassBaseName + + IconName + WindowOfProject + Identifier + perspective.morph + IsVertical + 0 + Layout + + + BecomeActive + 1 + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C08E77C0454961000C914BD + 1C37FABC05509CD000000102 + 1C37FABC05539CD112110102 + E2644B35053B69B200211256 + 1C37FABC04509CD000100104 + 1CC0EA4004350EF90044410B + 1CC0EA4004350EF90041110B + + PBXProjectModuleGUID + 11E0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 186 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 29B97314FDCFA39411CA2CEA + 1C37FABC05509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {186, 337}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + 1 + XCSharingToken + com.apple.Xcode.GFSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {203, 355}} + GroupTreeTableConfiguration + + MainColumn + 186 + + RubberWindowFrame + 373 269 690 397 0 0 1440 878 + + Module + PBXSmartGroupTreeModule + Proportion + 100% + + + Name + Morph + PreferredWidth + 300 + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + + TableOfContents + + 11E0B1FE06471DED0097A5F4 + + ToolbarConfiguration + xcode.toolbar.config.default.short + + + PerspectivesBarVisible + + ShelfIsVisible + + SourceDescription + file at '/System/Library/PrivateFrameworks/DevToolsInterface.framework/Versions/A/Resources/XCPerspectivesSpecificationMode1.xcperspec' + StatusbarIsVisible + + TimeStamp + 0.0 + ToolbarDisplayMode + 1 + ToolbarIsVisible + + ToolbarSizeMode + 1 + Type + Perspectives + UpdateMessage + The Default Workspace in this version of Xcode now includes support to hide and show the detail view (what has been referred to as the "Metro-Morph" feature). You must discard your current Default Workspace settings and update to the latest Default Workspace in order to gain this feature. Do you wish to update to the latest Workspace defaults for project '%@'? + WindowJustification + 5 + WindowOrderList + + /Users/hsoft/src/dupeguru_pe_cocoa/dupeguru.xcodeproj + + WindowString + 4 54 1366 823 0 0 1440 878 + WindowTools + + + FirstTimeWindowDisplayed + + Identifier + windowTool.build + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CD0528F0623707200166675 + PBXProjectModuleLabel + + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {1366, 540}} + RubberWindowFrame + 0 56 1366 822 0 0 1440 878 + + Module + PBXNavigatorGroup + Proportion + 540pt + + + BecomeActive + + ContentConfiguration + + PBXProjectModuleGUID + XCMainBuildResultsModuleGUID + PBXProjectModuleLabel + Build + XCBuildResultsTrigger_Collapse + 1021 + XCBuildResultsTrigger_Open + 1011 + + GeometryConfiguration + + Frame + {{0, 545}, {1366, 236}} + RubberWindowFrame + 0 56 1366 822 0 0 1440 878 + + Module + PBXBuildResultsModule + Proportion + 236pt + + + Proportion + 781pt + + + Name + Build Results + ServiceClasses + + PBXBuildResultsModule + + StatusbarIsVisible + + TableOfContents + + CE381CCE09914BC8003581CE + CEB6A2360C9EA7D700767CC9 + 1CD0528F0623707200166675 + XCMainBuildResultsModuleGUID + + ToolbarConfiguration + xcode.toolbar.config.build + WindowString + 0 56 1366 822 0 0 1440 878 + WindowToolGUID + CE381CCE09914BC8003581CE + WindowToolIsVisible + + + + FirstTimeWindowDisplayed + + Identifier + windowTool.debugger + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + Debugger + + HorizontalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {150, 339}} + {{150, 0}, {874, 339}} + + + VerticalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {1024, 339}} + {{0, 339}, {1024, 306}} + + + + LauncherConfigVersion + 8 + PBXProjectModuleGUID + 1C162984064C10D400B95A72 + PBXProjectModuleLabel + Debug - GLUTExamples (Underwater) + + GeometryConfiguration + + DebugConsoleDrawerSize + {100, 120} + DebugConsoleVisible + None + DebugConsoleWindowFrame + {{200, 200}, {500, 300}} + DebugSTDIOWindowFrame + {{200, 200}, {500, 300}} + Frame + {{0, 0}, {1024, 645}} + RubberWindowFrame + 328 62 1024 686 0 0 1440 878 + + Module + PBXDebugSessionModule + Proportion + 645pt + + + Proportion + 645pt + + + Name + Debugger + ServiceClasses + + PBXDebugSessionModule + + StatusbarIsVisible + + TableOfContents + + 1CD10A99069EF8BA00B06720 + CEC94B9A0BA3652F009F7CBD + 1C162984064C10D400B95A72 + CEC94B9B0BA3652F009F7CBD + CEC94B9C0BA3652F009F7CBD + CEC94B9D0BA3652F009F7CBD + CEC94B9E0BA3652F009F7CBD + CEC94B9F0BA3652F009F7CBD + CEC94BA00BA3652F009F7CBD + + ToolbarConfiguration + xcode.toolbar.config.debug + WindowString + 328 62 1024 686 0 0 1440 878 + WindowToolGUID + 1CD10A99069EF8BA00B06720 + WindowToolIsVisible + + + + FirstTimeWindowDisplayed + + Identifier + windowTool.find + IsVertical + + Layout + + + Dock + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CDD528C0622207200134675 + PBXProjectModuleLabel + + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {781, 212}} + RubberWindowFrame + 31 253 781 470 0 0 1024 746 + + Module + PBXNavigatorGroup + Proportion + 781pt + + + Proportion + 212pt + + + ContentConfiguration + + PBXProjectModuleGUID + 1CD0528E0623707200166675 + PBXProjectModuleLabel + Project Find + + GeometryConfiguration + + Frame + {{0, 217}, {781, 212}} + RubberWindowFrame + 31 253 781 470 0 0 1024 746 + + Module + PBXProjectFindModule + Proportion + 212pt + + + Proportion + 429pt + + + Name + Project Find + ServiceClasses + + PBXProjectFindModule + + StatusbarIsVisible + + TableOfContents + + 1C530D57069F1CE1000CFCEE + CE3755460A37628100022F3B + CE3755470A37628100022F3B + 1CDD528C0622207200134675 + 1CD0528E0623707200166675 + + WindowString + 31 253 781 470 0 0 1024 746 + WindowToolGUID + 1C530D57069F1CE1000CFCEE + WindowToolIsVisible + + + + Identifier + MENUSEPARATOR + + + FirstTimeWindowDisplayed + + Identifier + windowTool.debuggerConsole + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1C78EAAC065D492600B07095 + PBXProjectModuleLabel + Debugger Console + + GeometryConfiguration + + Frame + {{0, 0}, {440, 358}} + RubberWindowFrame + 72 414 440 400 0 0 1440 878 + + Module + PBXDebugCLIModule + Proportion + 358pt + + + Proportion + 359pt + + + Name + Debugger Console + ServiceClasses + + PBXDebugCLIModule + + StatusbarIsVisible + + TableOfContents + + CECD0ADE099294C1003DC359 + CEC94BA10BA3652F009F7CBD + 1C78EAAC065D492600B07095 + + WindowString + 72 414 440 400 0 0 1440 878 + WindowToolGUID + CECD0ADE099294C1003DC359 + WindowToolIsVisible + + + + FirstTimeWindowDisplayed + + Identifier + windowTool.run + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + LauncherConfigVersion + 3 + PBXProjectModuleGUID + 1CD0528B0623707200166675 + PBXProjectModuleLabel + Run + Runner + + HorizontalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {366, 168}} + {{0, 173}, {366, 270}} + + + VerticalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {406, 443}} + {{411, 0}, {517, 443}} + + + + + GeometryConfiguration + + Frame + {{0, 0}, {1377, 781}} + RubberWindowFrame + 0 56 1377 822 0 0 1440 878 + + Module + PBXRunSessionModule + Proportion + 781pt + + + Proportion + 781pt + + + Name + Run Log + ServiceClasses + + PBXRunSessionModule + + StatusbarIsVisible + + TableOfContents + + 1C0AD2B3069F1EA900FABCE6 + CE89234E0BFF46580079C065 + 1CD0528B0623707200166675 + CE89234F0BFF46580079C065 + + ToolbarConfiguration + xcode.toolbar.config.run + WindowString + 0 56 1377 822 0 0 1440 878 + WindowToolGUID + 1C0AD2B3069F1EA900FABCE6 + WindowToolIsVisible + + + + Identifier + windowTool.scm + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1C78EAB2065D492600B07095 + PBXProjectModuleLabel + <No Editor> + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1C78EAB3065D492600B07095 + + SplitCount + 1 + + StatusBarVisibility + 1 + + GeometryConfiguration + + Frame + {{0, 0}, {452, 0}} + RubberWindowFrame + 743 379 452 308 0 0 1280 1002 + + Module + PBXNavigatorGroup + Proportion + 0pt + + + BecomeActive + 1 + ContentConfiguration + + PBXProjectModuleGUID + 1CD052920623707200166675 + PBXProjectModuleLabel + SCM + + GeometryConfiguration + + ConsoleFrame + {{0, 259}, {452, 0}} + Frame + {{0, 7}, {452, 259}} + RubberWindowFrame + 743 379 452 308 0 0 1280 1002 + TableConfiguration + + Status + 30 + FileName + 199 + Path + 197.09500122070312 + + TableFrame + {{0, 0}, {452, 250}} + + Module + PBXCVSModule + Proportion + 262pt + + + Proportion + 266pt + + + Name + SCM + ServiceClasses + + PBXCVSModule + + StatusbarIsVisible + 1 + TableOfContents + + 1C78EAB4065D492600B07095 + 1C78EAB5065D492600B07095 + 1C78EAB2065D492600B07095 + 1CD052920623707200166675 + + ToolbarConfiguration + xcode.toolbar.config.scm + WindowString + 743 379 452 308 0 0 1280 1002 + + + FirstTimeWindowDisplayed + + Identifier + windowTool.breakpoints + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C77FABC04509CD000000102 + + PBXProjectModuleGUID + 1CE0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + no + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 168 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 1C77FABC04509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {168, 350}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + + + GeometryConfiguration + + Frame + {{0, 0}, {185, 368}} + GroupTreeTableConfiguration + + MainColumn + 168 + + RubberWindowFrame + 21 314 744 409 0 0 1024 746 + + Module + PBXSmartGroupTreeModule + Proportion + 185pt + + + BecomeActive + + ContentConfiguration + + PBXProjectModuleGUID + 1CA1AED706398EBD00589147 + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{190, 0}, {554, 368}} + RubberWindowFrame + 21 314 744 409 0 0 1024 746 + + Module + XCDetailModule + Proportion + 554pt + + + Proportion + 368pt + + + MajorVersion + 2 + MinorVersion + 0 + Name + Breakpoints + ServiceClasses + + PBXSmartGroupTreeModule + XCDetailModule + + StatusbarIsVisible + + TableOfContents + + CEDA9EAC09D2BBCE00741F3F + CEDA9EAD09D2BBCE00741F3F + 1CE0B1FE06471DED0097A5F4 + 1CA1AED706398EBD00589147 + + ToolbarConfiguration + xcode.toolbar.config.breakpoints + WindowString + 21 314 744 409 0 0 1024 746 + WindowToolGUID + CEDA9EAC09D2BBCE00741F3F + WindowToolIsVisible + + + + Identifier + windowTool.debugAnimator + Layout + + + Dock + + + Module + PBXNavigatorGroup + Proportion + 100% + + + Proportion + 100% + + + Name + Debug Visualizer + ServiceClasses + + PBXNavigatorGroup + + StatusbarIsVisible + 1 + ToolbarConfiguration + xcode.toolbar.config.debugAnimator + WindowString + 100 100 700 500 0 0 1280 1002 + + + Identifier + windowTool.bookmarks + Layout + + + Dock + + + Module + PBXBookmarksModule + Proportion + 100% + + + Proportion + 100% + + + Name + Bookmarks + ServiceClasses + + PBXBookmarksModule + + StatusbarIsVisible + 0 + WindowString + 538 42 401 187 0 0 1280 1002 + + + Identifier + windowTool.classBrowser + Layout + + + Dock + + + BecomeActive + 1 + ContentConfiguration + + OptionsSetName + Hierarchy, all classes + PBXProjectModuleGUID + 1CA6456E063B45B4001379D8 + PBXProjectModuleLabel + Class Browser - NSObject + + GeometryConfiguration + + ClassesFrame + {{0, 0}, {374, 96}} + ClassesTreeTableConfiguration + + PBXClassNameColumnIdentifier + 208 + PBXClassBookColumnIdentifier + 22 + + Frame + {{0, 0}, {630, 331}} + MembersFrame + {{0, 105}, {374, 395}} + MembersTreeTableConfiguration + + PBXMemberTypeIconColumnIdentifier + 22 + PBXMemberNameColumnIdentifier + 216 + PBXMemberTypeColumnIdentifier + 97 + PBXMemberBookColumnIdentifier + 22 + + PBXModuleWindowStatusBarHidden2 + 1 + RubberWindowFrame + 385 179 630 352 0 0 1440 878 + + Module + PBXClassBrowserModule + Proportion + 332pt + + + Proportion + 332pt + + + Name + Class Browser + ServiceClasses + + PBXClassBrowserModule + + StatusbarIsVisible + 0 + TableOfContents + + 1C0AD2AF069F1E9B00FABCE6 + 1C0AD2B0069F1E9B00FABCE6 + 1CA6456E063B45B4001379D8 + + ToolbarConfiguration + xcode.toolbar.config.classbrowser + WindowString + 385 179 630 352 0 0 1440 878 + WindowToolGUID + 1C0AD2AF069F1E9B00FABCE6 + WindowToolIsVisible + 0 + + + + diff --git a/pe/cocoa/dupeguru.xcodeproj/project.pbxproj b/pe/cocoa/dupeguru.xcodeproj/project.pbxproj new file mode 100644 index 00000000..02043065 --- /dev/null +++ b/pe/cocoa/dupeguru.xcodeproj/project.pbxproj @@ -0,0 +1,588 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 42; + objects = { + +/* Begin PBXBuildFile section */ + 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; }; + 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; + 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; + 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; + CE073F6309CAE1A3005C1D2F /* dupeguru_pe_help in Resources */ = {isa = PBXBuildFile; fileRef = CE073F5409CAE1A3005C1D2F /* dupeguru_pe_help */; }; + CE0C46AA0FA0647E000BE99B /* PictureBlocks.m in Sources */ = {isa = PBXBuildFile; fileRef = CE0C46A90FA0647E000BE99B /* PictureBlocks.m */; }; + CE15C8A80ADEB8B50061D4A5 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE15C8A70ADEB8B50061D4A5 /* Sparkle.framework */; }; + CE15C8C00ADEB8D40061D4A5 /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CE15C8A70ADEB8B50061D4A5 /* Sparkle.framework */; }; + CE381C9609914ACE003581CE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CE381C9409914ACE003581CE /* AppDelegate.m */; }; + CE381C9C09914ADF003581CE /* ResultWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CE381C9A09914ADF003581CE /* ResultWindow.m */; }; + CE381D0509915304003581CE /* dg_cocoa.plugin in Resources */ = {isa = PBXBuildFile; fileRef = CE381CF509915304003581CE /* dg_cocoa.plugin */; }; + CE3AA46709DB207900DB3A21 /* Directories.nib in Resources */ = {isa = PBXBuildFile; fileRef = CE3AA46509DB207900DB3A21 /* Directories.nib */; }; + CE68EE6809ABC48000971085 /* DirectoryPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = CE68EE6609ABC48000971085 /* DirectoryPanel.m */; }; + CE80DB2E0FC192D60086DCA6 /* Dialogs.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DB1C0FC192D60086DCA6 /* Dialogs.m */; }; + CE80DB2F0FC192D60086DCA6 /* HSErrorReportWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DB1E0FC192D60086DCA6 /* HSErrorReportWindow.m */; }; + CE80DB300FC192D60086DCA6 /* Outline.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DB200FC192D60086DCA6 /* Outline.m */; }; + CE80DB310FC192D60086DCA6 /* ProgressController.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DB220FC192D60086DCA6 /* ProgressController.m */; }; + CE80DB320FC192D60086DCA6 /* RecentDirectories.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DB250FC192D60086DCA6 /* RecentDirectories.m */; }; + CE80DB330FC192D60086DCA6 /* RegistrationInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DB270FC192D60086DCA6 /* RegistrationInterface.m */; }; + CE80DB340FC192D60086DCA6 /* Table.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DB290FC192D60086DCA6 /* Table.m */; }; + CE80DB350FC192D60086DCA6 /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DB2B0FC192D60086DCA6 /* Utils.m */; }; + CE80DB360FC192D60086DCA6 /* ValueTransformers.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DB2D0FC192D60086DCA6 /* ValueTransformers.m */; }; + CE80DB470FC193650086DCA6 /* NSNotificationAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DB460FC193650086DCA6 /* NSNotificationAdditions.m */; }; + CE80DB4A0FC193770086DCA6 /* NSImageAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DB490FC193770086DCA6 /* NSImageAdditions.m */; }; + CE80DB760FC194760086DCA6 /* ErrorReportWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE80DB700FC194760086DCA6 /* ErrorReportWindow.xib */; }; + CE80DB770FC194760086DCA6 /* progress.nib in Resources */ = {isa = PBXBuildFile; fileRef = CE80DB720FC194760086DCA6 /* progress.nib */; }; + CE80DB780FC194760086DCA6 /* registration.nib in Resources */ = {isa = PBXBuildFile; fileRef = CE80DB740FC194760086DCA6 /* registration.nib */; }; + CE80DB8A0FC1951C0086DCA6 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DB830FC1951C0086DCA6 /* AppDelegate.m */; }; + CE80DB8B0FC1951C0086DCA6 /* DirectoryPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DB860FC1951C0086DCA6 /* DirectoryPanel.m */; }; + CE80DB8C0FC1951C0086DCA6 /* ResultWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CE80DB890FC1951C0086DCA6 /* ResultWindow.m */; }; + CE848A1909DD85810004CB44 /* Consts.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = CE848A1809DD85810004CB44 /* Consts.h */; }; + CECA899909DB12CA00A3D774 /* Details.nib in Resources */ = {isa = PBXBuildFile; fileRef = CECA899709DB12CA00A3D774 /* Details.nib */; }; + CECA899C09DB132E00A3D774 /* DetailsPanel.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = CECA899A09DB132E00A3D774 /* DetailsPanel.h */; }; + CECA899D09DB132E00A3D774 /* DetailsPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = CECA899B09DB132E00A3D774 /* DetailsPanel.m */; }; + CEDA432E0B07C6E600B3091A /* dg.xsl in Resources */ = {isa = PBXBuildFile; fileRef = CEDA432C0B07C6E600B3091A /* dg.xsl */; }; + CEDA432F0B07C6E600B3091A /* hardcoded.css in Resources */ = {isa = PBXBuildFile; fileRef = CEDA432D0B07C6E600B3091A /* hardcoded.css */; }; + CEEB135209C837A2004D2330 /* dupeguru.icns in Resources */ = {isa = PBXBuildFile; fileRef = CEEB135109C837A2004D2330 /* dupeguru.icns */; }; + CEF4112B0A11069600E7F110 /* Consts.m in Sources */ = {isa = PBXBuildFile; fileRef = CEF4112A0A11069600E7F110 /* Consts.m */; }; + CEF7823809C8AA0200EF38FF /* gear.png in Resources */ = {isa = PBXBuildFile; fileRef = CEF7823709C8AA0200EF38FF /* gear.png */; }; + CEFC294609C89E3D00D9F998 /* folder32.png in Resources */ = {isa = PBXBuildFile; fileRef = CEFC294509C89E3D00D9F998 /* folder32.png */; }; + CEFC295509C89FF200D9F998 /* details32.png in Resources */ = {isa = PBXBuildFile; fileRef = CEFC295309C89FF200D9F998 /* details32.png */; }; + CEFC295609C89FF200D9F998 /* preferences32.png in Resources */ = {isa = PBXBuildFile; fileRef = CEFC295409C89FF200D9F998 /* preferences32.png */; }; + CEFCDE2D0AB0418600C33A93 /* dgpe_logo_32.png in Resources */ = {isa = PBXBuildFile; fileRef = CEFCDE2C0AB0418600C33A93 /* dgpe_logo_32.png */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + CECC02B709A36E8200CC0A94 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + CE15C8C00ADEB8D40061D4A5 /* Sparkle.framework in CopyFiles */, + CECA899C09DB132E00A3D774 /* DetailsPanel.h in CopyFiles */, + CE848A1909DD85810004CB44 /* Consts.h in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; + 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; + 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; + 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; }; + 29B97319FDCFA39411CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/MainMenu.nib; sourceTree = ""; }; + 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; + 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; + 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; }; + 8D1107320486CEB800E47090 /* dupeGuru PE.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "dupeGuru PE.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + CE073F5409CAE1A3005C1D2F /* dupeguru_pe_help */ = {isa = PBXFileReference; lastKnownFileType = folder; name = dupeguru_pe_help; path = help/dupeguru_pe_help; sourceTree = SOURCE_ROOT; }; + CE0C46A80FA0647E000BE99B /* PictureBlocks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PictureBlocks.h; sourceTree = ""; }; + CE0C46A90FA0647E000BE99B /* PictureBlocks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PictureBlocks.m; sourceTree = ""; }; + CE15C8A70ADEB8B50061D4A5 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = /Library/Frameworks/Sparkle.framework; sourceTree = ""; }; + CE381C9409914ACE003581CE /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = SOURCE_ROOT; }; + CE381C9509914ACE003581CE /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = SOURCE_ROOT; }; + CE381C9A09914ADF003581CE /* ResultWindow.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = ResultWindow.m; sourceTree = SOURCE_ROOT; }; + CE381C9B09914ADF003581CE /* ResultWindow.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = ResultWindow.h; sourceTree = SOURCE_ROOT; }; + CE381CF509915304003581CE /* dg_cocoa.plugin */ = {isa = PBXFileReference; lastKnownFileType = folder; name = dg_cocoa.plugin; path = py/dist/dg_cocoa.plugin; sourceTree = SOURCE_ROOT; }; + CE3AA46609DB207900DB3A21 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/Directories.nib; sourceTree = ""; }; + CE68EE6509ABC48000971085 /* DirectoryPanel.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = DirectoryPanel.h; sourceTree = SOURCE_ROOT; }; + CE68EE6609ABC48000971085 /* DirectoryPanel.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = DirectoryPanel.m; sourceTree = SOURCE_ROOT; }; + CE80DB1B0FC192D60086DCA6 /* Dialogs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Dialogs.h; path = cocoalib/Dialogs.h; sourceTree = SOURCE_ROOT; }; + CE80DB1C0FC192D60086DCA6 /* Dialogs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Dialogs.m; path = cocoalib/Dialogs.m; sourceTree = SOURCE_ROOT; }; + CE80DB1D0FC192D60086DCA6 /* HSErrorReportWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HSErrorReportWindow.h; path = cocoalib/HSErrorReportWindow.h; sourceTree = SOURCE_ROOT; }; + CE80DB1E0FC192D60086DCA6 /* HSErrorReportWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HSErrorReportWindow.m; path = cocoalib/HSErrorReportWindow.m; sourceTree = SOURCE_ROOT; }; + CE80DB1F0FC192D60086DCA6 /* Outline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Outline.h; path = cocoalib/Outline.h; sourceTree = SOURCE_ROOT; }; + CE80DB200FC192D60086DCA6 /* Outline.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Outline.m; path = cocoalib/Outline.m; sourceTree = SOURCE_ROOT; }; + CE80DB210FC192D60086DCA6 /* ProgressController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ProgressController.h; path = cocoalib/ProgressController.h; sourceTree = SOURCE_ROOT; }; + CE80DB220FC192D60086DCA6 /* ProgressController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ProgressController.m; path = cocoalib/ProgressController.m; sourceTree = SOURCE_ROOT; }; + CE80DB230FC192D60086DCA6 /* PyApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PyApp.h; path = cocoalib/PyApp.h; sourceTree = SOURCE_ROOT; }; + CE80DB240FC192D60086DCA6 /* RecentDirectories.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RecentDirectories.h; path = cocoalib/RecentDirectories.h; sourceTree = SOURCE_ROOT; }; + CE80DB250FC192D60086DCA6 /* RecentDirectories.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RecentDirectories.m; path = cocoalib/RecentDirectories.m; sourceTree = SOURCE_ROOT; }; + CE80DB260FC192D60086DCA6 /* RegistrationInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegistrationInterface.h; path = cocoalib/RegistrationInterface.h; sourceTree = SOURCE_ROOT; }; + CE80DB270FC192D60086DCA6 /* RegistrationInterface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RegistrationInterface.m; path = cocoalib/RegistrationInterface.m; sourceTree = SOURCE_ROOT; }; + CE80DB280FC192D60086DCA6 /* Table.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Table.h; path = cocoalib/Table.h; sourceTree = SOURCE_ROOT; }; + CE80DB290FC192D60086DCA6 /* Table.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Table.m; path = cocoalib/Table.m; sourceTree = SOURCE_ROOT; }; + CE80DB2A0FC192D60086DCA6 /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Utils.h; path = cocoalib/Utils.h; sourceTree = SOURCE_ROOT; }; + CE80DB2B0FC192D60086DCA6 /* Utils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Utils.m; path = cocoalib/Utils.m; sourceTree = SOURCE_ROOT; }; + CE80DB2C0FC192D60086DCA6 /* ValueTransformers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueTransformers.h; path = cocoalib/ValueTransformers.h; sourceTree = SOURCE_ROOT; }; + CE80DB2D0FC192D60086DCA6 /* ValueTransformers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ValueTransformers.m; path = cocoalib/ValueTransformers.m; sourceTree = SOURCE_ROOT; }; + CE80DB450FC193650086DCA6 /* NSNotificationAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NSNotificationAdditions.h; path = cocoalib/NSNotificationAdditions.h; sourceTree = SOURCE_ROOT; }; + CE80DB460FC193650086DCA6 /* NSNotificationAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NSNotificationAdditions.m; path = cocoalib/NSNotificationAdditions.m; sourceTree = SOURCE_ROOT; }; + CE80DB480FC193770086DCA6 /* NSImageAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NSImageAdditions.h; path = cocoalib/NSImageAdditions.h; sourceTree = SOURCE_ROOT; }; + CE80DB490FC193770086DCA6 /* NSImageAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NSImageAdditions.m; path = cocoalib/NSImageAdditions.m; sourceTree = SOURCE_ROOT; }; + CE80DB710FC194760086DCA6 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = cocoalib/English.lproj/ErrorReportWindow.xib; sourceTree = SOURCE_ROOT; }; + CE80DB730FC194760086DCA6 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = cocoalib/English.lproj/progress.nib; sourceTree = SOURCE_ROOT; }; + CE80DB750FC194760086DCA6 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = cocoalib/English.lproj/registration.nib; sourceTree = SOURCE_ROOT; }; + CE80DB820FC1951C0086DCA6 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = dgbase/AppDelegate.h; sourceTree = SOURCE_ROOT; }; + CE80DB830FC1951C0086DCA6 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = dgbase/AppDelegate.m; sourceTree = SOURCE_ROOT; }; + CE80DB840FC1951C0086DCA6 /* Consts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Consts.h; path = dgbase/Consts.h; sourceTree = SOURCE_ROOT; }; + CE80DB850FC1951C0086DCA6 /* DirectoryPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DirectoryPanel.h; path = dgbase/DirectoryPanel.h; sourceTree = SOURCE_ROOT; }; + CE80DB860FC1951C0086DCA6 /* DirectoryPanel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DirectoryPanel.m; path = dgbase/DirectoryPanel.m; sourceTree = SOURCE_ROOT; }; + CE80DB870FC1951C0086DCA6 /* PyDupeGuru.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PyDupeGuru.h; path = dgbase/PyDupeGuru.h; sourceTree = SOURCE_ROOT; }; + CE80DB880FC1951C0086DCA6 /* ResultWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ResultWindow.h; path = dgbase/ResultWindow.h; sourceTree = SOURCE_ROOT; }; + CE80DB890FC1951C0086DCA6 /* ResultWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ResultWindow.m; path = dgbase/ResultWindow.m; sourceTree = SOURCE_ROOT; }; + CE848A1809DD85810004CB44 /* Consts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Consts.h; sourceTree = ""; }; + CECA899809DB12CA00A3D774 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/Details.nib; sourceTree = ""; }; + CECA899A09DB132E00A3D774 /* DetailsPanel.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = DetailsPanel.h; sourceTree = ""; }; + CECA899B09DB132E00A3D774 /* DetailsPanel.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = DetailsPanel.m; sourceTree = ""; }; + CEDA432C0B07C6E600B3091A /* dg.xsl */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text.xml; name = dg.xsl; path = w3/dg.xsl; sourceTree = SOURCE_ROOT; }; + CEDA432D0B07C6E600B3091A /* hardcoded.css */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text; name = hardcoded.css; path = w3/hardcoded.css; sourceTree = SOURCE_ROOT; }; + CEEB135109C837A2004D2330 /* dupeguru.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = dupeguru.icns; sourceTree = ""; }; + CEF4112A0A11069600E7F110 /* Consts.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = Consts.m; sourceTree = SOURCE_ROOT; }; + CEF7823709C8AA0200EF38FF /* gear.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = gear.png; path = images/gear.png; sourceTree = ""; }; + CEFC294509C89E3D00D9F998 /* folder32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = folder32.png; path = images/folder32.png; sourceTree = SOURCE_ROOT; }; + CEFC295309C89FF200D9F998 /* details32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = details32.png; path = images/details32.png; sourceTree = SOURCE_ROOT; }; + CEFC295409C89FF200D9F998 /* preferences32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = preferences32.png; path = images/preferences32.png; sourceTree = SOURCE_ROOT; }; + CEFCDE2C0AB0418600C33A93 /* dgpe_logo_32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = dgpe_logo_32.png; path = images/dgpe_logo_32.png; sourceTree = SOURCE_ROOT; }; + CEFF18A009A4D387005E6321 /* PyDupeGuru.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = PyDupeGuru.h; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8D11072E0486CEB800E47090 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, + CE15C8A80ADEB8B50061D4A5 /* Sparkle.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 080E96DDFE201D6D7F000001 /* Classes */ = { + isa = PBXGroup; + children = ( + CE0C46A80FA0647E000BE99B /* PictureBlocks.h */, + CE0C46A90FA0647E000BE99B /* PictureBlocks.m */, + CE381C9509914ACE003581CE /* AppDelegate.h */, + CE381C9409914ACE003581CE /* AppDelegate.m */, + CE848A1809DD85810004CB44 /* Consts.h */, + CEF4112A0A11069600E7F110 /* Consts.m */, + CECA899A09DB132E00A3D774 /* DetailsPanel.h */, + CECA899B09DB132E00A3D774 /* DetailsPanel.m */, + CE68EE6509ABC48000971085 /* DirectoryPanel.h */, + CE68EE6609ABC48000971085 /* DirectoryPanel.m */, + CEFF18A009A4D387005E6321 /* PyDupeGuru.h */, + CE381C9B09914ADF003581CE /* ResultWindow.h */, + CE381C9A09914ADF003581CE /* ResultWindow.m */, + ); + name = Classes; + sourceTree = ""; + }; + 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = { + isa = PBXGroup; + children = ( + CE15C8A70ADEB8B50061D4A5 /* Sparkle.framework */, + 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */, + ); + name = "Linked Frameworks"; + sourceTree = ""; + }; + 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 29B97324FDCFA39411CA2CEA /* AppKit.framework */, + 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */, + 29B97325FDCFA39411CA2CEA /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; + 19C28FACFE9D520D11CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 8D1107320486CEB800E47090 /* dupeGuru PE.app */, + ); + name = Products; + sourceTree = ""; + }; + 29B97314FDCFA39411CA2CEA /* dupeguru */ = { + isa = PBXGroup; + children = ( + 080E96DDFE201D6D7F000001 /* Classes */, + CE80DB1A0FC192AB0086DCA6 /* cocoalib */, + CE80DB810FC194BD0086DCA6 /* dgbase */, + 29B97315FDCFA39411CA2CEA /* Other Sources */, + 29B97317FDCFA39411CA2CEA /* Resources */, + 29B97323FDCFA39411CA2CEA /* Frameworks */, + 19C28FACFE9D520D11CA2CBB /* Products */, + ); + name = dupeguru; + sourceTree = ""; + }; + 29B97315FDCFA39411CA2CEA /* Other Sources */ = { + isa = PBXGroup; + children = ( + 29B97316FDCFA39411CA2CEA /* main.m */, + ); + name = "Other Sources"; + sourceTree = ""; + }; + 29B97317FDCFA39411CA2CEA /* Resources */ = { + isa = PBXGroup; + children = ( + CE073F5409CAE1A3005C1D2F /* dupeguru_pe_help */, + CE381CF509915304003581CE /* dg_cocoa.plugin */, + CEFC294309C89E0000D9F998 /* images */, + CEDA432B0B07C6E600B3091A /* w3 */, + CEEB135109C837A2004D2330 /* dupeguru.icns */, + 8D1107310486CEB800E47090 /* Info.plist */, + 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */, + CECA899709DB12CA00A3D774 /* Details.nib */, + CE3AA46509DB207900DB3A21 /* Directories.nib */, + 29B97318FDCFA39411CA2CEA /* MainMenu.nib */, + ); + name = Resources; + sourceTree = ""; + }; + 29B97323FDCFA39411CA2CEA /* Frameworks */ = { + isa = PBXGroup; + children = ( + 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */, + 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */, + ); + name = Frameworks; + sourceTree = ""; + }; + CE80DB1A0FC192AB0086DCA6 /* cocoalib */ = { + isa = PBXGroup; + children = ( + CE80DB700FC194760086DCA6 /* ErrorReportWindow.xib */, + CE80DB720FC194760086DCA6 /* progress.nib */, + CE80DB740FC194760086DCA6 /* registration.nib */, + CE80DB480FC193770086DCA6 /* NSImageAdditions.h */, + CE80DB490FC193770086DCA6 /* NSImageAdditions.m */, + CE80DB450FC193650086DCA6 /* NSNotificationAdditions.h */, + CE80DB460FC193650086DCA6 /* NSNotificationAdditions.m */, + CE80DB1B0FC192D60086DCA6 /* Dialogs.h */, + CE80DB1C0FC192D60086DCA6 /* Dialogs.m */, + CE80DB1D0FC192D60086DCA6 /* HSErrorReportWindow.h */, + CE80DB1E0FC192D60086DCA6 /* HSErrorReportWindow.m */, + CE80DB1F0FC192D60086DCA6 /* Outline.h */, + CE80DB200FC192D60086DCA6 /* Outline.m */, + CE80DB210FC192D60086DCA6 /* ProgressController.h */, + CE80DB220FC192D60086DCA6 /* ProgressController.m */, + CE80DB230FC192D60086DCA6 /* PyApp.h */, + CE80DB240FC192D60086DCA6 /* RecentDirectories.h */, + CE80DB250FC192D60086DCA6 /* RecentDirectories.m */, + CE80DB260FC192D60086DCA6 /* RegistrationInterface.h */, + CE80DB270FC192D60086DCA6 /* RegistrationInterface.m */, + CE80DB280FC192D60086DCA6 /* Table.h */, + CE80DB290FC192D60086DCA6 /* Table.m */, + CE80DB2A0FC192D60086DCA6 /* Utils.h */, + CE80DB2B0FC192D60086DCA6 /* Utils.m */, + CE80DB2C0FC192D60086DCA6 /* ValueTransformers.h */, + CE80DB2D0FC192D60086DCA6 /* ValueTransformers.m */, + ); + name = cocoalib; + sourceTree = ""; + }; + CE80DB810FC194BD0086DCA6 /* dgbase */ = { + isa = PBXGroup; + children = ( + CE80DB820FC1951C0086DCA6 /* AppDelegate.h */, + CE80DB830FC1951C0086DCA6 /* AppDelegate.m */, + CE80DB840FC1951C0086DCA6 /* Consts.h */, + CE80DB850FC1951C0086DCA6 /* DirectoryPanel.h */, + CE80DB860FC1951C0086DCA6 /* DirectoryPanel.m */, + CE80DB870FC1951C0086DCA6 /* PyDupeGuru.h */, + CE80DB880FC1951C0086DCA6 /* ResultWindow.h */, + CE80DB890FC1951C0086DCA6 /* ResultWindow.m */, + ); + name = dgbase; + sourceTree = ""; + }; + CEDA432B0B07C6E600B3091A /* w3 */ = { + isa = PBXGroup; + children = ( + CEDA432C0B07C6E600B3091A /* dg.xsl */, + CEDA432D0B07C6E600B3091A /* hardcoded.css */, + ); + path = w3; + sourceTree = SOURCE_ROOT; + }; + CEFC294309C89E0000D9F998 /* images */ = { + isa = PBXGroup; + children = ( + CEFCDE2C0AB0418600C33A93 /* dgpe_logo_32.png */, + CEF7823709C8AA0200EF38FF /* gear.png */, + CEFC295309C89FF200D9F998 /* details32.png */, + CEFC295409C89FF200D9F998 /* preferences32.png */, + CEFC294509C89E3D00D9F998 /* folder32.png */, + ); + name = images; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8D1107260486CEB800E47090 /* dupeguru */ = { + isa = PBXNativeTarget; + buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "dupeguru" */; + buildPhases = ( + CEABE1A60FCC00E3005F8031 /* ShellScript */, + 8D1107290486CEB800E47090 /* Resources */, + 8D11072C0486CEB800E47090 /* Sources */, + 8D11072E0486CEB800E47090 /* Frameworks */, + CECC02B709A36E8200CC0A94 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = dupeguru; + productInstallPath = "$(HOME)/Applications"; + productName = dupeguru; + productReference = 8D1107320486CEB800E47090 /* dupeGuru PE.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 29B97313FDCFA39411CA2CEA /* Project object */ = { + isa = PBXProject; + buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "dupeguru" */; + compatibilityVersion = "Xcode 2.4"; + hasScannedForEncodings = 1; + mainGroup = 29B97314FDCFA39411CA2CEA /* dupeguru */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8D1107260486CEB800E47090 /* dupeguru */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8D1107290486CEB800E47090 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */, + 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */, + CE381D0509915304003581CE /* dg_cocoa.plugin in Resources */, + CE073F6309CAE1A3005C1D2F /* dupeguru_pe_help in Resources */, + CEEB135209C837A2004D2330 /* dupeguru.icns in Resources */, + CEFC294609C89E3D00D9F998 /* folder32.png in Resources */, + CEFC295509C89FF200D9F998 /* details32.png in Resources */, + CEFC295609C89FF200D9F998 /* preferences32.png in Resources */, + CEF7823809C8AA0200EF38FF /* gear.png in Resources */, + CECA899909DB12CA00A3D774 /* Details.nib in Resources */, + CE3AA46709DB207900DB3A21 /* Directories.nib in Resources */, + CEFCDE2D0AB0418600C33A93 /* dgpe_logo_32.png in Resources */, + CEDA432E0B07C6E600B3091A /* dg.xsl in Resources */, + CEDA432F0B07C6E600B3091A /* hardcoded.css in Resources */, + CE80DB760FC194760086DCA6 /* ErrorReportWindow.xib in Resources */, + CE80DB770FC194760086DCA6 /* progress.nib in Resources */, + CE80DB780FC194760086DCA6 /* registration.nib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + CEABE1A60FCC00E3005F8031 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "cd help\npython gen.py\n/Developer/Applications/Utilities/Help\\ Indexer.app/Contents/MacOS/Help\\ Indexer dupeguru_pe_help"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8D11072C0486CEB800E47090 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D11072D0486CEB800E47090 /* main.m in Sources */, + CE381C9609914ACE003581CE /* AppDelegate.m in Sources */, + CE381C9C09914ADF003581CE /* ResultWindow.m in Sources */, + CE68EE6809ABC48000971085 /* DirectoryPanel.m in Sources */, + CECA899D09DB132E00A3D774 /* DetailsPanel.m in Sources */, + CEF4112B0A11069600E7F110 /* Consts.m in Sources */, + CE0C46AA0FA0647E000BE99B /* PictureBlocks.m in Sources */, + CE80DB2E0FC192D60086DCA6 /* Dialogs.m in Sources */, + CE80DB2F0FC192D60086DCA6 /* HSErrorReportWindow.m in Sources */, + CE80DB300FC192D60086DCA6 /* Outline.m in Sources */, + CE80DB310FC192D60086DCA6 /* ProgressController.m in Sources */, + CE80DB320FC192D60086DCA6 /* RecentDirectories.m in Sources */, + CE80DB330FC192D60086DCA6 /* RegistrationInterface.m in Sources */, + CE80DB340FC192D60086DCA6 /* Table.m in Sources */, + CE80DB350FC192D60086DCA6 /* Utils.m in Sources */, + CE80DB360FC192D60086DCA6 /* ValueTransformers.m in Sources */, + CE80DB470FC193650086DCA6 /* NSNotificationAdditions.m in Sources */, + CE80DB4A0FC193770086DCA6 /* NSImageAdditions.m in Sources */, + CE80DB8A0FC1951C0086DCA6 /* AppDelegate.m in Sources */, + CE80DB8B0FC1951C0086DCA6 /* DirectoryPanel.m in Sources */, + CE80DB8C0FC1951C0086DCA6 /* ResultWindow.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 089C165DFE840E0CC02AAC07 /* English */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + 29B97318FDCFA39411CA2CEA /* MainMenu.nib */ = { + isa = PBXVariantGroup; + children = ( + 29B97319FDCFA39411CA2CEA /* English */, + ); + name = MainMenu.nib; + sourceTree = SOURCE_ROOT; + }; + CE3AA46509DB207900DB3A21 /* Directories.nib */ = { + isa = PBXVariantGroup; + children = ( + CE3AA46609DB207900DB3A21 /* English */, + ); + name = Directories.nib; + sourceTree = ""; + }; + CE80DB700FC194760086DCA6 /* ErrorReportWindow.xib */ = { + isa = PBXVariantGroup; + children = ( + CE80DB710FC194760086DCA6 /* English */, + ); + name = ErrorReportWindow.xib; + sourceTree = SOURCE_ROOT; + }; + CE80DB720FC194760086DCA6 /* progress.nib */ = { + isa = PBXVariantGroup; + children = ( + CE80DB730FC194760086DCA6 /* English */, + ); + name = progress.nib; + sourceTree = SOURCE_ROOT; + }; + CE80DB740FC194760086DCA6 /* registration.nib */ = { + isa = PBXVariantGroup; + children = ( + CE80DB750FC194760086DCA6 /* English */, + ); + name = registration.nib; + sourceTree = SOURCE_ROOT; + }; + CECA899709DB12CA00A3D774 /* Details.nib */ = { + isa = PBXVariantGroup; + children = ( + CECA899809DB12CA00A3D774 /* English */, + ); + name = Details.nib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + C01FCF4B08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(FRAMEWORK_SEARCH_PATHS)", + "$(SRCROOT)/cocoalib/build/Release", + "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", + ); + FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)/dgbase/build/Release\""; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Applications"; + PRODUCT_NAME = dupeGuru; + WRAPPER_EXTENSION = app; + ZERO_LINK = YES; + }; + name = Debug; + }; + C01FCF4C08A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + ppc, + i386, + ); + FRAMEWORK_SEARCH_PATHS = ( + "$(FRAMEWORK_SEARCH_PATHS)", + "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", + ); + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_MODEL_TUNING = G5; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Applications"; + PRODUCT_NAME = "dupeGuru PE"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; + C01FCF4F08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_C_LANGUAGE_STANDARD = c99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.4; + PREBINDING = NO; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + }; + name = Debug; + }; + C01FCF5008A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + ppc, + i386, + ); + FRAMEWORK_SEARCH_PATHS = ""; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.4; + PREBINDING = NO; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "dupeguru" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4B08A954540054247B /* Debug */, + C01FCF4C08A954540054247B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C01FCF4E08A954540054247B /* Build configuration list for PBXProject "dupeguru" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4F08A954540054247B /* Debug */, + C01FCF5008A954540054247B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; +} diff --git a/pe/cocoa/main.m b/pe/cocoa/main.m new file mode 100644 index 00000000..c5f30658 --- /dev/null +++ b/pe/cocoa/main.m @@ -0,0 +1,21 @@ +// +// main.m +// dupeguru +// +// Created by Virgil Dupras on 2006/02/01. +// Copyright __MyCompanyName__ 2006. All rights reserved. +// + +#import + +int main(int argc, char *argv[]) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSString *pluginPath = [[NSBundle mainBundle] + pathForResource:@"dg_cocoa" + ofType:@"plugin"]; + NSBundle *pluginBundle = [NSBundle bundleWithPath:pluginPath]; + [pluginBundle load]; + [pool release]; + return NSApplicationMain(argc, (const char **) argv); +} diff --git a/pe/cocoa/py/build_py.sh b/pe/cocoa/py/build_py.sh new file mode 100755 index 00000000..c9ac2993 --- /dev/null +++ b/pe/cocoa/py/build_py.sh @@ -0,0 +1,2 @@ +#!/bin/bash +python setup.py py2app \ No newline at end of file diff --git a/pe/cocoa/py/dg_cocoa.py b/pe/cocoa/py/dg_cocoa.py new file mode 100644 index 00000000..76126ec1 --- /dev/null +++ b/pe/cocoa/py/dg_cocoa.py @@ -0,0 +1,199 @@ +#!/usr/bin/env python +import objc +from AppKit import * +from PyObjCTools import NibClassBuilder + +NibClassBuilder.extractClasses("MainMenu", bundle=NSBundle.mainBundle()) + +from dupeguru import app_pe_cocoa, scanner + +class PyApp(NibClassBuilder.AutoBaseClass): + pass #fake class + +class PyDupeGuru(PyApp): + def init(self): + self = super(PyDupeGuru,self).init() + self.app = app_pe_cocoa.DupeGuruPE() + return self + + #---Directories + def addDirectory_(self,directory): + return self.app.AddDirectory(directory) + + def removeDirectory_(self,index): + self.app.RemoveDirectory(index) + + def setDirectory_state_(self,node_path,state): + self.app.SetDirectoryState(node_path,state) + + #---Results + def clearIgnoreList(self): + self.app.scanner.ignore_list.Clear() + + def clearPictureCache(self): + self.app.scanner.match_factory.cached_blocks.clear() + + def doScan(self): + return self.app.start_scanning() + + def exportToXHTMLwithColumns_xslt_css_(self,column_ids,xslt_path,css_path): + return self.app.ExportToXHTML(column_ids,xslt_path,css_path) + + def loadIgnoreList(self): + self.app.LoadIgnoreList() + + def loadResults(self): + self.app.load() + + def markAll(self): + self.app.results.mark_all() + + def markNone(self): + self.app.results.mark_none() + + def markInvert(self): + self.app.results.mark_invert() + + def purgeIgnoreList(self): + self.app.PurgeIgnoreList() + + def toggleSelectedMark(self): + self.app.ToggleSelectedMarkState() + + def saveIgnoreList(self): + self.app.SaveIgnoreList() + + def saveResults(self): + self.app.Save() + + def refreshDetailsWithSelected(self): + self.app.RefreshDetailsWithSelected() + + def selectResultNodePaths_(self,node_paths): + self.app.SelectResultNodePaths(node_paths) + + def selectPowerMarkerNodePaths_(self,node_paths): + self.app.SelectPowerMarkerNodePaths(node_paths) + + #---Actions + def addSelectedToIgnoreList(self): + self.app.AddSelectedToIgnoreList() + + def deleteMarked(self): + self.app.delete_marked() + + def applyFilter_(self, filter): + self.app.ApplyFilter(filter) + + def makeSelectedReference(self): + self.app.MakeSelectedReference() + + def copyOrMove_markedTo_recreatePath_(self,copy,destination,recreate_path): + self.app.copy_or_move_marked(copy, destination, recreate_path) + + def openSelected(self): + self.app.OpenSelected() + + def removeMarked(self): + self.app.results.perform_on_marked(lambda x:True,True) + + def removeSelected(self): + self.app.RemoveSelected() + + def renameSelected_(self,newname): + return self.app.RenameSelected(newname) + + def revealSelected(self): + self.app.RevealSelected() + + #---Misc + def sortDupesBy_ascending_(self,key,asc): + self.app.sort_dupes(key,asc) + + def sortGroupsBy_ascending_(self,key,asc): + self.app.sort_groups(key,asc) + + #---Information + def getIgnoreListCount(self): + return len(self.app.scanner.ignore_list) + + def getMarkCount(self): + return self.app.results.mark_count + + def getStatLine(self): + return self.app.stat_line + + def getOperationalErrorCount(self): + return self.app.last_op_error_count + + def getSelectedDupePath(self): + return unicode(self.app.selected_dupe_path()) + + def getSelectedDupeRefPath(self): + return unicode(self.app.selected_dupe_ref_path()) + + #---Data + @objc.signature('i@:i') + def getOutlineViewMaxLevel_(self, tag): + return self.app.GetOutlineViewMaxLevel(tag) + + @objc.signature('@@:i@') + def getOutlineView_childCountsForPath_(self, tag, node_path): + return self.app.GetOutlineViewChildCounts(tag, node_path) + + def getOutlineView_valuesForIndexes_(self,tag,node_path): + return self.app.GetOutlineViewValues(tag,node_path) + + def getOutlineView_markedAtIndexes_(self,tag,node_path): + return self.app.GetOutlineViewMarked(tag,node_path) + + def getTableViewCount_(self,tag): + return self.app.GetTableViewCount(tag) + + def getTableViewMarkedIndexes_(self,tag): + return self.app.GetTableViewMarkedIndexes(tag) + + def getTableView_valuesForRow_(self,tag,row): + return self.app.GetTableViewValues(tag,row) + + #---Properties + def setMatchScaled_(self,match_scaled): + self.app.scanner.match_factory.match_scaled = match_scaled + + def setMinMatchPercentage_(self,percentage): + self.app.scanner.match_factory.threshold = int(percentage) + + def setMixFileKind_(self,mix_file_kind): + self.app.scanner.mix_file_kind = mix_file_kind + + def setDisplayDeltaValues_(self,display_delta_values): + self.app.display_delta_values= display_delta_values + + def setEscapeFilterRegexp_(self, escape_filter_regexp): + self.app.options['escape_filter_regexp'] = escape_filter_regexp + + def setRemoveEmptyFolders_(self, remove_empty_folders): + self.app.options['clean_empty_dirs'] = remove_empty_folders + + #---Worker + def getJobProgress(self): + return self.app.progress.last_progress + + def getJobDesc(self): + return self.app.progress.last_desc + + def cancelJob(self): + self.app.progress.job_cancelled = True + + #---Registration + @objc.signature('i@:') + def isRegistered(self): + return self.app.registered + + @objc.signature('i@:@@') + def isCodeValid_withEmail_(self, code, email): + return self.app.is_code_valid(code, email) + + def setRegisteredCode_andEmail_(self, code, email): + self.app.set_registration(code, email) + diff --git a/pe/cocoa/py/setup.py b/pe/cocoa/py/setup.py new file mode 100644 index 00000000..8bf847db --- /dev/null +++ b/pe/cocoa/py/setup.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +from setuptools import setup + +from hs.build import set_buildenv + +set_buildenv() + +setup( + plugin=['dg_cocoa.py'], + setup_requires=['py2app'], +) diff --git a/pe/cocoa/w3/dg.xsl b/pe/cocoa/w3/dg.xsl new file mode 100644 index 00000000..4f982fce --- /dev/null +++ b/pe/cocoa/w3/dg.xsl @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + indented + + + + + + + + + + + + + + + + + + + + + + + + + + + + dupeGuru Results + + + +

dupeGuru Results

+ + + + + +
+ + +
+ +
\ No newline at end of file diff --git a/pe/cocoa/w3/hardcoded.css b/pe/cocoa/w3/hardcoded.css new file mode 100644 index 00000000..ed243bcc --- /dev/null +++ b/pe/cocoa/w3/hardcoded.css @@ -0,0 +1,71 @@ +BODY +{ + background-color:white; +} + +BODY,A,P,UL,TABLE,TR,TD +{ + font-family:Tahoma,Arial,sans-serif; + font-size:10pt; + color: #4477AA; +} + +TABLE +{ + background-color: #225588; + margin-left: auto; + margin-right: auto; + width: 90%; +} + +TR +{ + background-color: white; +} + +TH +{ + font-weight: bold; + color: black; + background-color: #C8D6E5; +} + +TH TD +{ + color:black; +} + +TD +{ + padding-left: 2pt; +} + +TD.rightelem +{ + text-align:right; + /*padding-left:0pt;*/ + padding-right: 2pt; + width: 17%; +} + +TD.indented +{ + padding-left: 12pt; +} + +H1 +{ + font-family:"Courier New",monospace; + color:#6699CC; + font-size:18pt; + color:#6da500; + border-color: #70A0CF; + border-width: 1pt; + border-style: solid; + margin-top: 16pt; + margin-left: 5%; + margin-right: 5%; + padding-top: 2pt; + padding-bottom:2pt; + text-align: center; +} \ No newline at end of file diff --git a/pe/help/changelog.yaml b/pe/help/changelog.yaml new file mode 100644 index 00000000..f387c334 --- /dev/null +++ b/pe/help/changelog.yaml @@ -0,0 +1,174 @@ +- date: 2009-05-27 + version: 1.7.2 + description: | + * Fixed a bug causing '.jpeg' files not to be scanned. + * Fixed a bug causing a GUI freeze at the beginning of a scan with a lot of files. + * Fixed a bug that sometimes caused a crash when an action was cancelled, and then started again. + * Improved scanning speed. +- date: 2009-05-26 + version: 1.7.1 + description: | + * Fixed a bug causing the "Match Scaled" preference to be inverted. +- date: 2009-05-20 + version: 1.7.0 + description: | + * Fixed the bug from 1.6.0 preventing PowerPC macs from running the application. + * Converted the Windows GUI to Qt, thus enabling multiprocessing and making the scanning process + faster. +- date: 2009-03-24 + description: "* **Improved** scanning speed, mainly on OS X where all cores of the\ + \ CPU are now used.\r\n* **Fixed** an occasional crash caused by permission issues.\r\ + \n* **Fixed** a bug where the \"X discarded\" notice would show a too large number\ + \ of discarded duplicates." + version: 1.6.0 +- date: 2008-09-10 + description: "
    \n\t\t\t\t\t\t
  • Added a notice in the status bar when\ + \ matches were discarded during the scan.
  • \n\t\t\t\t\t\t
  • Improved\ + \ duplicate prioritization (smartly chooses which file you will keep).
  • \n\t\ + \t\t\t\t\t
  • Improved scan progress feedback.
  • \n\t\t\t\t\t\t
  • Improved\ + \ responsiveness of the user interface for certain actions.
  • \n\t\t \ + \
" + version: 1.5.0 +- date: 2008-07-28 + description: "
    \n\t\t\t\t\t\t
  • Improved iPhoto compatibility on Mac\ + \ OS X.
  • \n\t\t\t\t\t\t
  • Improved the speed of results loading and\ + \ saving.
  • \n\t\t\t\t\t\t
  • Fixed a crash sometimes occurring during\ + \ duplicate deletion.
  • \n\t\t
" + version: 1.4.2 +- date: 2008-04-12 + description: "
    \n\t\t\t\t\t\t
  • Improved iPhoto Library loading feedback\ + \ on Mac OS X.
  • \n\t\t\t\t\t\t
  • Fixed the directory selection dialog.\ + \ Bundles can be selected again on Mac OS X.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ \"Clear Ignore List\" crash in Windows.
  • \n\t\t
" + version: 1.4.1 +- date: 2008-02-20 + description: "
    \n\t\t\t\t\t\t
  • Added iPhoto Library support on Mac OS\ + \ X.
  • \n\t\t\t\t\t\t
  • Fixed occasional crashes when scanning corrupted\ + \ pictures.
  • \n\t\t
" + version: 1.4.0 +- date: 2008-02-20 + description: "
    \n\t\t\t\t\t\t
  • Added iPhoto Library support on Mac OS\ + \ X.
  • \n\t\t\t\t\t\t
  • Fixed occasional crashes when scanning corrupted\ + \ pictures.
  • \n\t\t
" + version: 1.4.0 +- date: 2008-01-12 + description: "
    \n\t\t\t\t\t\t
  • Improved scan, delete and move speed\ + \ in situations where there were a lot of duplicates.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ occasional crashes when moving a lot of files at once.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ an issue sometimes preventing the application from starting at all.
  • \n\t\ + \t
" + version: 1.3.4 +- date: 2007-12-03 + description: "
    \n\t\t\t\t\t\t
  • Improved the handling of low memory situations.
  • \n\ + \t\t\t\t\t\t
  • Improved the directory panel. The \"Remove\" button changes\ + \ to \"Put Back\" when an excluded directory is selected.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ the directory selection dialog. iPhoto '08 library files can now be selected.
  • \n\ + \t\t
" + version: 1.3.3 +- date: 2007-11-24 + description: "
    \n\t\t\t\t\t\t
  • Added the \"Remove empty folders\" option.
  • \n\ + \t\t\t\t\t\t
  • Fixed results load/save issues.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ occasional status bar inaccuracies when the results are filtered.
  • \n\t\t\ + \
" + version: 1.3.2 +- date: 2007-10-21 + description: "
    \n\t\t\t\t\t\t
  • Improved results loading speed.
  • \n\ + \t\t\t\t\t\t
  • Improved details panel's picture loading (made it asynchronous).
  • \n\ + \t\t\t\t\t\t
  • Fixed a bug where the stats line at the bottom would sometimes\ + \ go confused while having a filter active.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ a bug under Windows where some duplicate markings would be lost.
  • \n\t\t\ + \
" + version: 1.3.1 +- date: 2007-09-22 + description: "
    \n\t\t\t\t\t\t
  • Added post scan filtering.
  • \n\t\t\ + \t\t\t\t
  • Fixed issues with the rename feature under Windows
  • \n\t\ + \t\t\t\t\t
  • Fixed some user interface annoyances under Windows
  • \n\ + \t\t
" + version: 1.3.0 +- date: 2007-05-19 + description: "
    \n\t\t\t\t\t\t
  • Improved UI responsiveness (using threads)\ + \ under Mac OS X.
  • \n\t\t\t\t\t\t
  • Improved result load/save speed\ + \ and memory usage.
  • \n\t\t
" + version: 1.2.1 +- date: 2007-03-17 + description: "
    \n\t\t\t\t\t\t
  • Changed the picture decoding libraries\ + \ for both Mac OS X and Windows. The Mac OS X version uses the Core Graphics library\ + \ and the Windows version uses the .NET framework imaging capabilities. This results\ + \ in much faster scans. As a bonus, the Mac OS X version of dupeGuru PE now supports\ + \ RAW images.
  • \n\t\t
" + version: 1.2.0 +- date: 2007-02-11 + description: "
    \n\t\t\t\t\t\t
  • Added Re-orderable columns. In fact,\ + \ I re-added the feature which was lost in the C# conversion in 2.4.0 (Windows).
  • \n\ + \t\t\t\t\t\t
  • Fixed a bug with all the Delete/Move/Copy actions with\ + \ certain kinds of files.
  • \n\t\t
" + version: 1.1.6 +- date: 2007-01-11 + description: "
    \n\t\t\t\t\t\t
  • Fixed a bug with the Move action.
  • \n\ + \t\t
" + version: 1.1.5 +- date: 2007-01-09 + description: "
    \n\t\t\t\t\t\t
  • Fixed a \"ghosting\" bug. Dupes deleted\ + \ by dupeGuru would sometimes come back in subsequent scans (Windows).
  • \n\t\ + \t\t\t\t\t
  • Fixed bugs sometimes making dupeGuru crash when marking a\ + \ dupe (Windows).
  • \n\t\t\t\t\t\t
  • Fixed some minor visual glitches\ + \ (Windows).
  • \n\t\t
" + version: 1.1.4 +- date: 2006-12-23 + description: "
    \n\t\t\t\t\t\t
  • Improved the caching system. This makes\ + \ duplicate scans significantly faster.
  • \n\t\t\t\t\t\t
  • Improved\ + \ the rename file dialog to exclude the extension from the original selection\ + \ (so when you start typing your new filename, it doesn't overwrite it) (Windows).
  • \n\ + \t\t\t\t\t\t
  • Changed some menu key shortcuts that created conflicts\ + \ (Windows).
  • \n\t\t\t\t\t\t
  • Fixed a bug preventing files from \"\ + reference\" directories to be displayed in blue in the results (Windows).
  • \n\ + \t\t\t\t\t\t
  • Fixed a bug preventing some files to be sent to the recycle\ + \ bin (Windows).
  • \n\t\t\t\t\t\t
  • Fixed a bug with the \"Remove\"\ + \ button of the directories panel (Windows).
  • \n\t\t\t\t\t\t
  • Fixed\ + \ a bug in the packaging preventing certain Windows configurations to start dupeGuru\ + \ at all.
  • \n\t\t
" + version: 1.1.3 +- date: 2006-11-18 + description: "
    \n\t\t\t\t\t\t
  • Fixed a bug with directory states.
  • \n\ + \t\t
" + version: 1.1.2 +- date: 2006-11-17 + description: "
    \n\t\t\t\t\t\t
  • Fixed a bug causing the ignore list not\ + \ to be saved.
  • \n\t\t\t\t\t\t
  • Fixed a bug with selection under Power\ + \ Marker mode.
  • \n\t\t
" + version: 1.1.1 +- date: 2006-11-15 + description: "
    \n\t\t\t\t\t\t
  • Changed the Windows interface. It is\ + \ now .NET based.
  • \n\t\t\t\t\t\t
  • Added an auto-update feature to\ + \ the windows version.
  • \n\t\t\t\t\t\t
  • Changed the way power marking\ + \ works. It is now a mode instead of a separate window.
  • \n\t\t\t\t\t\t
  • Changed\ + \ the \"Size (MB)\" column for a \"Size (KB)\" column. The values are now \"ceiled\"\ + \ instead of rounded. Therefore, a size \"0\" is now really 0 bytes, not just\ + \ a value too small to be rounded up. It is also the case for delta values.
  • \n\ + \t\t\t\t\t\t
  • Fixed a bug sometimes making delete and move operations\ + \ stall.
  • \n\t\t
" + version: 1.1.0 +- date: 2006-10-12 + description: "
    \n\t\t\t\t\t\t
  • Added an auto-update feature in the Mac\ + \ OS X version (with Sparkle).
  • \n\t\t \t
  • Fixed a bug\ + \ sometimes causing inaccuracies of the Match %.
  • \n\t\t
" + version: 1.0.5 +- date: 2006-09-21 + description: "
    \n\t\t \t
  • Fixed a bug with the cache system.
  • \n\ + \t\t
" + version: 1.0.4 +- date: 2006-09-15 + description: "
    \n\t\t\t\t\t\t
  • Added the ability to search for scaled\ + \ duplicates.
  • \n\t\t\t\t\t\t
  • Added a cache system for faster scans.
  • \n\ + \t\t \t
  • Improved speed of the scanning engine.
  • \n\t\t\ + \
" + version: 1.0.3 +- date: 2006-09-11 + description: "
    \n\t\t \t
  • Improved speed of the scanning\ + \ engine.
  • \n\t\t\t\t\t\t
  • Improved the display of pictures in the\ + \ details panel (Windows).
  • \n\t\t
" + version: 1.0.2 +- date: 2006-09-08 + description: "
    \n\t\t \t
  • Initial release.
  • \n\t\t \ + \
" + version: 1.0.0 diff --git a/pe/help/gen.py b/pe/help/gen.py new file mode 100644 index 00000000..8ed33e4e --- /dev/null +++ b/pe/help/gen.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python +# Unit Name: +# Created By: Virgil Dupras +# Created On: 2009-05-24 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import os + +from web import generate_help + +generate_help.main('.', 'dupeguru_pe_help', force_render=True) diff --git a/pe/help/skeleton/hardcoded.css b/pe/help/skeleton/hardcoded.css new file mode 100644 index 00000000..a3b17c5b --- /dev/null +++ b/pe/help/skeleton/hardcoded.css @@ -0,0 +1,409 @@ +/***************************************************** + General settings +*****************************************************/ + +BODY +{ + background-color:white; +} + +BODY,A,P,UL,TABLE,TR,TD +{ + font-family:Tahoma,Arial,sans-serif; + font-size:10pt; + color: #4477AA;/*darker than 5588bb for the sake of the eyes*/ +} + +/***************************************************** + "A" settings +*****************************************************/ + +A +{ + color: #ae322b; + text-decoration:underline; + font-weight:bold; +} + +A.glossaryword {color:#A0A0A0;} + +A.noline +{ + text-decoration: none; +} + + +/***************************************************** + Menu and mainframe settings +*****************************************************/ + +.maincontainer +{ + display:block; + margin-left:7%; + margin-right:7%; + padding-left:5px; + padding-right:0px; + border-color:#CCCCCC; + border-style:solid; + border-width:2px; + border-right-width:0px; + border-bottom-width:0px; + border-top-color:#ae322b; + vertical-align:top; +} + +TD.menuframe +{ + width:30%; +} + +.menu +{ + margin:4px 4px 4px 4px; + margin-top: 16pt; + border-color:gray; + border-width:1px; + border-style:dotted; + padding-top:10pt; + padding-bottom:10pt; + padding-right:6pt; +} + +.submenu +{ + list-style-type: none; + margin-left:26pt; + margin-top:0pt; + margin-bottom:0pt; + padding-left:0pt; +} + +A.menuitem,A.menuitem_selected +{ + font-size:14pt; + font-family:Tahoma,Arial,sans-serif; + font-weight:normal; + padding-left:10pt; + color:#5588bb; + margin-right:2pt; + margin-left:4pt; + text-decoration:none; +} + +A.menuitem_selected +{ + font-weight:bold; +} + +A.submenuitem +{ + font-family:Tahoma,Arial,sans-serif; + font-weight:normal; + color:#5588bb; + text-decoration:none; +} + +.titleline +{ + border-width:3px; + border-style:solid; + border-left-width:0px; + border-right-width:0px; + border-top-width:0px; + border-color:#CCCCCC; + margin-left:28pt; + margin-right:2pt; + line-height:1px; + padding-top:0px; + margin-top:0px; + display:block; +} + +.titledescrip +{ + text-align:left; + display:block; + margin-left:26pt; + color:#ae322b; +} + +.mainlogo +{ + display:block; + margin-left:8%; + margin-top:4pt; + margin-bottom:4pt; +} + +/***************************************************** + IMG settings +*****************************************************/ + +IMG +{ + border-style:none; +} + +IMG.smallbutton +{ + margin-right: 20px; + float:none; +} + +IMG.floating +{ + float:left; + margin-right: 4pt; + margin-bottom: 4pt; +} + +IMG.lefticon +{ + vertical-align: middle; + padding-right: 2pt; +} + +IMG.righticon +{ + vertical-align: middle; + padding-left: 2pt; +} + +/***************************************************** + TABLE settings +*****************************************************/ + +TABLE +{ + border-style:none; +} + +TABLE.box +{ + width: 90%; + margin-left:5%; +} + +TABLE.centered +{ + margin-left: auto; + margin-right: auto; +} + +TABLE.hardcoded +{ + background-color: #225588; + margin-left: auto; + margin-right: auto; + width: 90%; +} + +TR { background-color: transparent; } + +TABLE.hardcoded TR { background-color: white } + +TABLE.hardcoded TR.header +{ + font-weight: bold; + color: black; + background-color: #C8D6E5; +} + +TABLE.hardcoded TR.header TD {color:black;} + +TABLE.hardcoded TD { padding-left: 2pt; } + +TD.minimelem { + padding-right:0px; + padding-left:0px; + text-align:center; +} + +TD.rightelem +{ + text-align:right; + /*padding-left:0pt;*/ + padding-right: 2pt; + width: 17%; +} + +/***************************************************** + P settings +*****************************************************/ + +p,.sub{text-align:justify;} +.centered{text-align:center;} +.sub +{ + padding-left: 16pt; + padding-right:16pt; +} + +.Note, .ContactInfo +{ + border-color: #ae322b; + border-width: 1pt; + border-style: dashed; + text-align:justify; + padding: 2pt 2pt 2pt 2pt; + margin-bottom:4pt; + margin-top:8pt; + list-style-position:inside; +} + +.ContactInfo +{ + width:60%; + margin-left:5%; +} + +.NewsItem +{ + border-color:#ae322b; + border-style: solid; + border-right:none; + border-top:none; + border-left:none; + border-bottom-width:1px; + text-align:justify; + padding-left:4pt; + padding-right:4pt; + padding-bottom:8pt; +} + +/***************************************************** + Lists settings +*****************************************************/ +UL.plain +{ + list-style-type: none; + padding-left:0px; + margin-left:0px; +} + +LI.plain +{ + list-style-type: none; +} + +LI.section +{ + padding-top: 6pt; +} + +UL.longtext LI +{ + border-color: #ae322b; + border-width:0px; + border-top-width:1px; + border-style:solid; + margin-top:12px; +} + +/* + with UL.longtext LI, there can be anything between + the UL and the LI, and it will still make the + lontext thing, I must break it with this hack +*/ +UL.longtext UL LI +{ + border-style:none; + margin-top:2px; +} + + +/***************************************************** + Titles settings +*****************************************************/ + +H1,H2,H3 +{ + font-family:"Courier New",monospace; + color:#5588bb; +} + +H1 +{ + font-size:18pt; + color: #ae322b; + border-color: #70A0CF; + border-width: 1pt; + border-style: solid; + margin-top: 16pt; + margin-left: 5%; + margin-right: 5%; + padding-top: 2pt; + padding-bottom:2pt; + text-align: center; +} + +H2 +{ + border-color: #ae322b; + border-bottom-width: 2px; + border-top-width: 0pt; + border-left-width: 2px; + border-right-width: 0pt; + border-bottom-color: #cccccc; + border-style: solid; + margin-top: 16pt; + margin-left: 0pt; + margin-right: 0pt; + padding-bottom:3pt; + padding-left:5pt; + text-align: left; + font-size:16pt; +} + +H3 +{ + display:block; + color:#ae322b; + border-color: #70A0CF; + border-bottom-width: 2px; + border-top-width: 0pt; + border-left-width: 0pt; + border-right-width: 0pt; + border-style: dashed; + margin-top: 12pt; + margin-left: 0pt; + margin-bottom: 4pt; + width:auto; + padding-bottom:3pt; + padding-right:2pt; + padding-left:2pt; + text-align: left; + font-weight:bold; +} + + +/***************************************************** + Misc. classes +*****************************************************/ +.longtext:first-letter {font-size: 150%} + +.price, .loweredprice, .specialprice {font-weight:bold;} + +.loweredprice {text-decoration:line-through} + +.specialprice {color:red} + +form +{ + margin:0px; +} + +.program_summary +{ + float:right; + margin: 32pt; + margin-top:0pt; + margin-bottom:0pt; +} + +.screenshot +{ + float:left; + margin: 8pt; +} \ No newline at end of file diff --git a/pe/help/skeleton/images/hs_title.png b/pe/help/skeleton/images/hs_title.png new file mode 100644 index 00000000..07bd89c6 Binary files /dev/null and b/pe/help/skeleton/images/hs_title.png differ diff --git a/pe/help/templates/base_dg.mako b/pe/help/templates/base_dg.mako new file mode 100644 index 00000000..7767c49f --- /dev/null +++ b/pe/help/templates/base_dg.mako @@ -0,0 +1,14 @@ +<%inherit file="/base_help.mako"/> +${next.body()} + +<%def name="menu()"><% +self.menuitem('intro.htm', 'Introduction', 'Introduction to dupeGuru') +self.menuitem('quick_start.htm', 'Quick Start', 'Quickly get into the action') +self.menuitem('directories.htm', 'Directories', 'Managing dupeGuru directories') +self.menuitem('preferences.htm', 'Preferences', 'Setting dupeGuru preferences') +self.menuitem('results.htm', 'Results', 'Time to delete these duplicates!') +self.menuitem('power_marker.htm', 'Power Marker', 'Take control of your duplicates') +self.menuitem('faq.htm', 'F.A.Q.', 'Frequently Asked Questions') +self.menuitem('versions.htm', 'Version History', 'Changes dupeGuru went through') +self.menuitem('credits.htm', 'Credits', 'People who contributed to dupeGuru') +%> \ No newline at end of file diff --git a/pe/help/templates/credits.mako b/pe/help/templates/credits.mako new file mode 100644 index 00000000..9de91bd2 --- /dev/null +++ b/pe/help/templates/credits.mako @@ -0,0 +1,25 @@ +## -*- coding: utf-8 -*- +<%! + title = 'Credits' + selected_menu_item = 'Credits' +%> +<%inherit file="/base_dg.mako"/> +Below is the list of people who contributed, directly or indirectly to dupeGuru. + +${self.credit('Virgil Dupras', 'Developer', "That's me, Hardcoded Software founder", 'www.hardcoded.net', 'hsoft@hardcoded.net')} + +${self.credit(u'Jérôme Cantin', u'Icon designer', u"Icons in dupeGuru are from him")} + +${self.credit('Python', 'Programming language', "The bestest of the bests", 'www.python.org')} + +${self.credit('PyObjC', 'Python-to-Cocoa bridge', "Used for the Mac OS X version", 'pyobjc.sourceforge.net')} + +${self.credit('PyQt', 'Python-to-Qt bridge', "Used for the Windows version", 'www.riverbankcomputing.co.uk')} + +${self.credit('Qt', 'GUI Toolkit', "Used for the Windows version", 'www.qtsoftware.com')} + +${self.credit('Sparkle', 'Auto-update library', "Used for the Mac OS X version", 'andymatuschak.org/pages/sparkle')} + +${self.credit('Python Imaging Library', 'Picture analyzer', "Used for the Windows version", 'www.pythonware.com/products/pil/')} + +${self.credit('You', 'dupeGuru user', "What would I do without you?")} diff --git a/pe/help/templates/directories.mako b/pe/help/templates/directories.mako new file mode 100644 index 00000000..e75b47bd --- /dev/null +++ b/pe/help/templates/directories.mako @@ -0,0 +1,24 @@ +<%! + title = 'Directories' + selected_menu_item = 'Directories' +%> +<%inherit file="/base_dg.mako"/> + +There is a panel in dupeGuru called **Directories**. You can open it by clicking on the **Directories** button. This directory contains the list of the directories that will be scanned when you click on **Start Scanning**. + +This panel is quite straightforward to use. If you want to add a directory, click on **Add**. If you added directories before, a popup menu with a list of recent directories you added will pop. You can click on one of them to add it directly to your list. If you click on the first item of the popup menu, **Add New Directory...**, you will be prompted for a directory to add. If you never added a directory, no menu will pop and you will directly be prompted for a new directory to add. + +To remove a directory, select the directory to remove and click on **Remove**. If a subdirectory is selected when you click remove, the selected directory will be set to **excluded** state (see below) instead of being removed. + +Directory states +----- + +Every directory can be in one of these 3 states: + +* **Normal:** Duplicates found in these directories can be deleted. +* **Reference:** Duplicates found in this directory **cannot** be deleted. Files in reference directories will be in a blue color in the results. +* **Excluded:** Files in this directory will not be included in the scan. + +The default state of a directory is, of course, **Normal**. You can use **Reference** state for a directory if you want to be sure that you won't delete any file from it. + +When you set the state of a directory, all subdirectories of this directory automatically inherit this state unless you explicitly set a subdirectory's state. diff --git a/pe/help/templates/faq.mako b/pe/help/templates/faq.mako new file mode 100644 index 00000000..1c4e998f --- /dev/null +++ b/pe/help/templates/faq.mako @@ -0,0 +1,64 @@ +<%! + title = 'dupeGuru F.A.Q.' + selected_menu_item = 'F.A.Q.' +%> +<%inherit file="/base_dg.mako"/> + +<%text filter="md"> +### What is dupeGuru PE? + +dupeGuru Picture Edition (PE for short) is a tool to find duplicate pictures on your computer. Not only can it find exact matches, but it can also find duplicates among pictures of different kind (PNG, JPG, GIF etc..) and quality. + +### What makes it better than other duplicate scanners? + +The scanning engine is extremely flexible. You can tweak it to really get the kind of results you want. You can read more about dupeGuru tweaking option at the [Preferences page](preferences.htm). + +### How safe is it to use dupeGuru PE? + +Very safe. dupeGuru has been designed to make sure you don't delete files you didn't mean to delete. First, there is the reference directory system that lets you define directories where you absolutely **don't** want dupeGuru to let you delete files there, and then there is the group reference system that makes sure that you will **always** keep at least one member of the duplicate group. + +### What are the demo limitations of dupeGuru PE? + +In demo mode, you can only perform actions (delete/copy/move) on 10 duplicates per session. + +### The mark box of a file I want to delete is disabled. What must I do? + +You cannot mark the reference (The first file) of a duplicate group. However, what you can do is to promote a duplicate file to reference. Thus, if a file you want to mark is reference, select a duplicate file in the group that you want to promote to reference, and click on **Actions-->Make Selected Reference**. If the reference file is from a reference directory (filename written in blue letters), you cannot remove it from the reference position. + +### I have a directory from which I really don't want to delete files. + +If you want to be sure that dupeGuru will never delete file from a particular directory, just open the **Directories panel**, select that directory, and set its state to **Reference**. + +### What is this '(X discarded)' notice in the status bar? + +In some cases, some matches are not included in the final results for security reasons. Let me use an example. We have 3 file: A, B and C. We scan them using a low filter hardness. The scanner determines that A matches with B, A matches with C, but B does **not** match with C. Here, dupeGuru has kind of a problem. It cannot create a duplicate group with A, B and C in it because not all files in the group would match together. It could create 2 groups: one A-B group and then one A-C group, but it will not, for security reasons. Lets think about it: If B doesn't match with C, it probably means that either B, C or both are not actually duplicates. If there would be 2 groups (A-B and A-C), you would end up delete both B and C. And if one of them is not a duplicate, that is really not what you want to do, right? So what dupeGuru does in a case like this is to discard the A-C match (and adds a notice in the status bar). Thus, if you delete B and re-run a scan, you will have a A-C match in your next results. + +### I want to mark all files from a specific directory. What can I do? + +Enable the [Power Marker](power_marker.htm) mode and click on the Directory column to sort your duplicates by Directory. It will then be easy for you to select all duplicates from the same directory, and then press Space to mark all selected duplicates. + +### I want to remove all files that are more than 300 KB away from their reference file. What can I do? + +* Enable the [Power Marker](power_marker.htm) mode. +* Enable the **Delta Values** mode. +* Click on the "Size" column to sort the results by size. +* Select all duplicates below -300. +* Click on **Remove Selected from Results**. +* Select all duplicates over 300. +* Click on **Remove Selected from Results**. + +### I want to make my latest modified files reference files. What can I do? + +* Enable the [Power Marker](power_marker.htm) mode. +* Enable the **Delta Values** mode. +* Click on the "Modification" column to sort the results by modification date. +* Click on the "Modification" column again to reverse the sort order (see Power Marker page to know why). +* Select all duplicates over 0. +* Click on **Make Selected Reference**. + +### I want to mark all duplicates containing the word "copy". How do I do that? + +* **Windows**: Click on **Actions --> Apply Filter**, then type "copy", then click OK. +* **Mac OS X**: Type "copy" in the "Filter" field in the toolbar. +* Click on **Mark --> Mark All**. + \ No newline at end of file diff --git a/pe/help/templates/intro.mako b/pe/help/templates/intro.mako new file mode 100644 index 00000000..51d058c9 --- /dev/null +++ b/pe/help/templates/intro.mako @@ -0,0 +1,13 @@ +<%! + title = 'Introduction to dupeGuru PE' + selected_menu_item = 'introduction' +%> +<%inherit file="/base_dg.mako"/> + +dupeGuru Picture Edition (PE for short) is a tool to find duplicate pictures on your computer. Not only can it find exact matches, but it can also find duplicates among pictures of different kind (PNG, JPG, GIF etc..) and quality. + +Although dupeGuru can easily be used without documentation, reading this file will help you to master it. If you are looking for guidance for your first duplicate scan, you can take a look at the [Quick Start](quick_start.htm) section. + +It is a good idea to keep dupeGuru PE updated. You can download the latest version on the [dupeGuru PE homepage](http://www.hardcoded.net/dupeguru_pe/). + +<%def name="meta()"> diff --git a/pe/help/templates/power_marker.mako b/pe/help/templates/power_marker.mako new file mode 100644 index 00000000..26078f3d --- /dev/null +++ b/pe/help/templates/power_marker.mako @@ -0,0 +1,33 @@ +<%! + title = 'Power Marker' + selected_menu_item = 'Power Marker' +%> +<%inherit file="/base_dg.mako"/> + +You will probably not use the Power Marker feature very often, but if you get into a situation where you need it, you will be pretty happy that this feature exists. + +What is it? +----- + +When the Power Marker mode is enabled, the duplicates are shown without their respective reference file. You can select, mark and sort this list, just like in normal mode. + +So, what is it for? +----- + +The dupeGuru results, when in normal mode, are sorted according to duplicate groups' **reference file**. This means that if you want, for example, to mark all duplicates with the "exe" extension, you cannot just sort the results by "Kind" to have all exe duplicates together because a group can be composed of more than one kind of files. That is where Power Marker comes into play. To mark all your "exe" duplicates, you just have to: + +* Enable the Power marker mode. +* Add the "Kind" column with the "Columns" menu. +* Click on that "Kind" column to sort the list by kind. +* Locate the first duplicate with a "exe" kind. +* Select it. +* Scroll down the list to locate the last duplicate with a "exe" kind. +* Hold Shift and click on it. +* Press Space to mark all selected duplicates. + +Power Marker and delta values +----- + +The Power Marker unveil its true power when you use it with the **Delta Values** switch turned on. When you turn it on, relative values will be displayed instead of absolute ones. So if, for example, you want to remove from your results all duplicates that are more than 300 KB away from their reference, you could sort the Power Marker by Size, select all duplicates under -300 in the Size column, delete them, and then do the same for duplicates over 300 at the bottom of the list. + +You could also use it to change the reference priority of your duplicate list. When you make a fresh scan, if there are no reference directories, the reference file of every group is the biggest file. If you want to change that, for example, to the latest modification time, you can sort the Power Marker by modification time in **descending** order, select all duplicates with a modification time delta value higher than 0 and click on **Make Selected Reference**. The reason why you must make the sort order descending is because if 2 files among the same duplicate group are selected when you click on **Make Selected Reference**, only the first of the list will be made reference, the other will be ignored. And since you want the last modified file to be reference, having the sort order descending assures you that the first item of the list will be the last modified. diff --git a/pe/help/templates/preferences.mako b/pe/help/templates/preferences.mako new file mode 100644 index 00000000..0ef6a2ba --- /dev/null +++ b/pe/help/templates/preferences.mako @@ -0,0 +1,23 @@ +<%! + title = 'Preferences' + selected_menu_item = 'Preferences' +%> +<%inherit file="/base_dg.mako"/> + +**Filter Hardness:** The higher is this setting, the "harder" is the filter (In other words, the less results you get). Most pictures of the same quality match at 100% even if the format is different (PNG and JPG for example.). However, if you want to make a PNG match with a lower quality JPG, you will have to set the filer hardness to lower than 100. The default, 95, is a sweet spot. + +**Match scaled pictures together:** If you check this box, pictures of different dimensions will be allowed in the same duplicate group. + +**Can mix file kind:** If you check this box, duplicate groups are allowed to have files with different extensions. If you don't check it, well, they aren't! + +**Use regular expressions when filtering:** If you check this box, the filtering feature will treat your filter query as a **regular expression**. Explaining them is beyond the scope of this document. A good place to start learning it is . + +**Remove empty folders after delete or move:** When this option is enabled, folders are deleted after a file is deleted or moved and the folder is empty. + +**Copy and Move:** Determines how the Copy and Move operations (in the Action menu) will behave. + +* **Right in destination:** All files will be sent directly in the selected destination, without trying to recreate the source path at all. +* **Recreate relative path:** The source file's path will be re-created in the destination directory up to the root selection in the Directories panel. For example, if you added "/Users/foobar/Picture" to your Directories panel and you move "/Users/foobar/Picture/2006/06/photo.jpg" to the destination "/Users/foobar/MyDestination", the final destination for the file will be "/Users/foobar/MyDestination/2006/06" ("/Users/foobar/Picture" has been trimmed from source's path in the final destination.). +* **Recreate absolute path:** The source file's path will be re-created in the destination directory in it's entirety. For example, if you move "/Users/foobar/Picture/2006/06/photo.jpg" to the destination "/Users/foobar/MyDestination", the final destination for the file will be "/Users/foobar/MyDestination/Users/foobar/Picture/2006/06". + +In all cases, dupeGuru PE nicely handles naming conflicts by prepending a number to the destination filename if the filename already exists in the destination. diff --git a/pe/help/templates/quick_start.mako b/pe/help/templates/quick_start.mako new file mode 100644 index 00000000..dde33c65 --- /dev/null +++ b/pe/help/templates/quick_start.mako @@ -0,0 +1,18 @@ +<%! + title = 'Quick Start' + selected_menu_item = 'Quick Start' +%> +<%inherit file="/base_dg.mako"/> + +To get you quickly started with dupeGuru, let's just make a standard scan using default preferences. + +* Click on **Directories**. +* Click on **Add**. +* Choose a directory you want to scan for duplicates. +* Click on **Start Scanning**. +* Wait until the scan process is over. +* Look at every duplicate (The files that are indented) and verify that it is indeed a duplicate to the group's reference (The file above the duplicate that is not indented and have a disabled mark box). +* If a file is a false duplicate, select it and click on **Actions-->Remove Selected from Results**. +* Once you are sure that there is no false duplicate in your results, click on **Edit-->Mark All**, and then **Actions-->Send Marked to Recycle bin**. + +That is only a basic scan. There are a lot of tweaking you can do to get different results and several methods of examining and modifying your results. To know about them, just read the rest of this help file. diff --git a/pe/help/templates/results.mako b/pe/help/templates/results.mako new file mode 100644 index 00000000..53aa176f --- /dev/null +++ b/pe/help/templates/results.mako @@ -0,0 +1,73 @@ +<%! + title = 'Results' + selected_menu_item = 'Results' +%> +<%inherit file="/base_dg.mako"/> + +When dupeGuru is finished scanning for duplicates, it will show its results in the form of duplicate group list. + +About duplicate groups +----- + +A duplicate group is a group of files that all match together. Every group has a **reference file** and one or more **duplicate files**. The reference file is the first file of the group. Its mark box is disabled. Below it, and indented, are the duplicate files. + +You can mark duplicate files, but you can never mark the reference file of a group. This is a security measure to prevent dupeGuru from deleting not only duplicate files, but their reference. You sure don't want that, do you? + +What determines which files are reference and which files are duplicates is first their directory state. A files from a reference directory will always be reference in a duplicate group. If all files are from a normal directory, the size determine which file will be the reference of a duplicate group. dupeGuru assumes that you always want to keep the biggest file, so the biggest files will take the reference position. + +You can change the reference file of a group manually. To do so, select the duplicate file you want to promote to reference, and click on **Actions-->Make Selected Reference**. + +Reviewing results +----- + +Although you can just click on **Edit-->Mark All** and then **Actions-->Send Marked to Recycle bin** to quickly delete all duplicate files in your results, it is always recommended to review all duplicates before deleting them. + +To help you reviewing the results, you can bring up the **Details panel**. This panel shows all the details of the currently selected file as well as its reference's details. This is very handy to quickly determine if a duplicate really is a duplicate. You can also double-click on a file to open it with its associated application. + +If you have more false duplicates than true duplicates (If your filter hardness is very low), the best way to proceed would be to review duplicates, mark true duplicates and then click on **Actions-->Send Marked to Recycle bin**. If you have more true duplicates than false duplicates, you can instead mark all files that are false duplicates, and use **Actions-->Remove Marked from Results**. + +Marking and Selecting +----- + +A **marked** duplicate is a duplicate with the little box next to it having a check-mark. A **selected** duplicate is a duplicate being highlighted. The multiple selection actions can be performed in dupeGuru in the standard way (Shift/Command/Control click). You can toggle all selected duplicates' mark state by pressing **space**. + +Delta Values +----- + +If you turn this switch on, some columns will display the value relative to the duplicate's reference instead of the absolute values. These delta values will also be displayed in a different color so you can spot them easily. For example, if a duplicate is 1.2 MB and its reference is 1.4 MB, the Size column will display -0.2 MB. This option is a killer feature when combined with the [Power Marker](power_marker.htm). + +Filtering +----- + +dupeGuru supports post-scan filtering. With it, you can narrow down your results so you can perform actions on a subset of it. For example, you could easily mark all duplicates with their filename containing "copy" from your results using the filter. + +**Windows:** To use the filtering feature, click on Actions --> Apply Filter, write down the filter you want to apply and click OK. To go back to unfiltered results, click on Actions --> Cancel Filter. + +**Mac OS X:** To use the filtering feature, type your filter in the "Filter" search field in the toolbar. To go back to unfiltered result, blank out the field, or click on the "X". + +In simple mode (the default mode), whatever you type as the filter is the string used to perform the actual filtering, with the exception of one wildcard: **\***. Thus, if you type "[*]" as your filter, it will match anything with [] brackets in it, whatever is in between those brackets. + +For more advanced filtering, you can turn "Use regular expressions when filtering" on. The filtering feature will then use **regular expressions**. A regular expression is a language for matching text. Explaining them is beyond the scope of this document. A good place to start learning it is . + +Matches are case insensitive in both simple and regexp mode. + +For the filter to match, your regular expression don't have to match the whole filename, it just have to contain a string matching the expression. + +You might notice that not all duplicates in the filtered results will match your filter. That is because as soon as one single duplicate in a group matches the filter, the whole group stays in the results so you can have a better view of the duplicate's context. However, non-matching duplicates are in "reference mode". Therefore, you can perform actions like Mark All and be sure to only mark filtered duplicates. + +Action Menu +----- + +* **Start Duplicate Scan:** Starts a new duplicate scan. +* **Clear Ignore List:** Remove all ignored matches you added. You have to start a new scan for the newly cleared ignore list to be effective. +* **Export Results to XHTML:** Take the current results, and create an XHTML file out of it. The columns that are visible when you click on this button will be the columns present in the XHTML file. The file will automatically be opened in your default browser. +* **Send Marked to Trash:** Send all marked duplicates to trash, obviously. +* **Move Marked to...:** Prompt you for a destination, and then move all marked files to that destination. Source file's path might be re-created in destination, depending on the "Copy and Move" preference. +* **Copy Marked to...:** Prompt you for a destination, and then copy all marked files to that destination. Source file's path might be re-created in destination, depending on the "Copy and Move" preference. +* **Remove Marked from Results:** Remove all marked duplicates from results. The actual files will not be touched and will stay where they are. +* **Remove Selected from Results:** Remove all selected duplicates from results. Note that all selected reference files will be ignored, only duplicates can be removed with this action. +* **Make Selected Reference:** Promote all selected duplicates to reference. If a duplicate is a part of a group having a reference file coming from a reference directory (in blue color), no action will be taken for this duplicate. If more than one duplicate among the same group are selected, only the first of each group will be promoted. +* **Add Selected to Ignore List:** This first removes all selected duplicates from results, and then add the match of that duplicate and the current reference in the ignore list. This match will not come up again in further scan. The duplicate itself might come back, but it will be matched with another reference file. You can clear the ignore list with the Clear Ignore List command. +* **Open Selected with Default Application:** Open the file with the application associated with selected file's type. +* **Reveal Selected in Finder:** Open the folder containing selected file. +* **Rename Selected:** Prompts you for a new name, and then rename the selected file. diff --git a/pe/help/templates/versions.mako b/pe/help/templates/versions.mako new file mode 100644 index 00000000..157c26ba --- /dev/null +++ b/pe/help/templates/versions.mako @@ -0,0 +1,6 @@ +<%! + title = 'dupeGuru PE version history' + selected_menu_item = 'Version History' +%> +<%inherit file="/base_dg.mako"/> +${self.output_changelogs(changelog)} \ No newline at end of file diff --git a/pe/qt/app.py b/pe/qt/app.py new file mode 100644 index 00000000..f40580ad --- /dev/null +++ b/pe/qt/app.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python +# Unit Name: app +# Created By: Virgil Dupras +# Created On: 2009-04-25 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import os.path as op + +from PyQt4.QtGui import QImage +import PIL.Image + +from hs import fs +from hs.fs import phys +from hs.utils.str import get_file_ext + +from dupeguru import data_pe +from dupeguru.picture.cache import Cache +from dupeguru.picture.matchbase import AsyncMatchFactory + +from block import getblocks +from base.app import DupeGuru as DupeGuruBase +from details_dialog import DetailsDialog +from main_window import MainWindow +from preferences import Preferences +from preferences_dialog import PreferencesDialog + +class File(phys.File): + cls_info_map = { + 'size': fs.IT_ATTRS, + 'ctime': fs.IT_ATTRS, + 'mtime': fs.IT_ATTRS, + 'md5': fs.IT_MD5, + 'md5partial': fs.IT_MD5, + 'dimensions': fs.IT_EXTRA, + } + + def _initialize_info(self, section): + super(File, self)._initialize_info(section) + if section == fs.IT_EXTRA: + self._info.update({ + 'dimensions': (0,0), + }) + + def _read_info(self, section): + super(File, self)._read_info(section) + if section == fs.IT_EXTRA: + im = PIL.Image.open(unicode(self.path)) + self._info['dimensions'] = im.size + + def get_blocks(self, block_count_per_side): + image = QImage(unicode(self.path)) + image = image.convertToFormat(QImage.Format_RGB888) + return getblocks(image, block_count_per_side) + + +class Directory(phys.Directory): + cls_file_class = File + cls_supported_exts = ('png', 'jpg', 'jpeg', 'gif', 'bmp', 'tiff') + + def _fetch_subitems(self): + subdirs, subfiles = super(Directory, self)._fetch_subitems() + return subdirs, [name for name in subfiles if get_file_ext(name) in self.cls_supported_exts] + + +class DupeGuru(DupeGuruBase): + LOGO_NAME = 'logo_pe' + NAME = 'dupeGuru Picture Edition' + VERSION = '1.7.2' + DELTA_COLUMNS = frozenset([2, 5, 6]) + + def __init__(self): + DupeGuruBase.__init__(self, data_pe, appid=5) + + def _setup(self): + self.scanner.match_factory = AsyncMatchFactory() + self.directories.dirclass = Directory + self.scanner.match_factory.cached_blocks = Cache(op.join(self.appdata, 'cached_pictures.db')) + DupeGuruBase._setup(self) + + def _update_options(self): + DupeGuruBase._update_options(self) + self.scanner.match_factory.match_scaled = self.prefs.match_scaled + self.scanner.match_factory.threshold = self.prefs.filter_hardness + + def _create_details_dialog(self, parent): + return DetailsDialog(parent, self) + + def _create_main_window(self): + return MainWindow(app=self) + + def _create_preferences(self): + return Preferences() + + def _create_preferences_dialog(self, parent): + return PreferencesDialog(parent, self) + diff --git a/pe/qt/app_win.py b/pe/qt/app_win.py new file mode 100644 index 00000000..a18ce2e9 --- /dev/null +++ b/pe/qt/app_win.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# Unit Name: app_win +# Created By: Virgil Dupras +# Created On: 2009-05-02 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import winshell + +import app + +class DupeGuru(app.DupeGuru): + @staticmethod + def _recycle_dupe(dupe): + winshell.delete_file(unicode(dupe.path), no_confirm=True) + diff --git a/pe/qt/base/__init__.py b/pe/qt/base/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pe/qt/base/about_box.py b/pe/qt/base/about_box.py new file mode 100644 index 00000000..55a36eb1 --- /dev/null +++ b/pe/qt/base/about_box.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# Unit Name: about_box +# Created By: Virgil Dupras +# Created On: 2009-05-09 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import Qt, QCoreApplication, SIGNAL +from PyQt4.QtGui import QDialog, QDialogButtonBox, QPixmap + +from about_box_ui import Ui_AboutBox + +class AboutBox(QDialog, Ui_AboutBox): + def __init__(self, parent, app): + flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.MSWindowsFixedSizeDialogHint + QDialog.__init__(self, parent, flags) + self.app = app + self._setupUi() + + self.connect(self.buttonBox, SIGNAL('clicked(QAbstractButton*)'), self.buttonClicked) + + def _setupUi(self): + self.setupUi(self) + # Stuff that can't be done in the Designer + self.setWindowTitle(u"About %s" % QCoreApplication.instance().applicationName()) + self.nameLabel.setText(QCoreApplication.instance().applicationName()) + self.versionLabel.setText('Version ' + QCoreApplication.instance().applicationVersion()) + self.logoLabel.setPixmap(QPixmap(':/%s_big' % self.app.LOGO_NAME)) + self.registerButton = self.buttonBox.addButton("Register", QDialogButtonBox.ActionRole) + + #--- Events + def buttonClicked(self, button): + if button is self.registerButton: + self.app.ask_for_reg_code() + diff --git a/pe/qt/base/about_box.ui b/pe/qt/base/about_box.ui new file mode 100644 index 00000000..aa9c5ce5 --- /dev/null +++ b/pe/qt/base/about_box.ui @@ -0,0 +1,133 @@ + + + AboutBox + + + + 0 + 0 + 400 + 190 + + + + + 0 + 0 + + + + About dupeGuru + + + + + + + + + :/logo_me_big + + + + + + + + + + 75 + true + + + + dupeGuru + + + + + + + Version + + + + + + + Copyright Hardcoded Software 2009 + + + + + + + + 75 + true + + + + Registered To: + + + + + + + UNREGISTERED + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + + + + + buttonBox + accepted() + AboutBox + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AboutBox + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/pe/qt/base/app.py b/pe/qt/base/app.py new file mode 100644 index 00000000..3fa340bf --- /dev/null +++ b/pe/qt/base/app.py @@ -0,0 +1,269 @@ +#!/usr/bin/env python +# Unit Name: app +# Created By: Virgil Dupras +# Created On: 2009-04-25 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import logging +import os.path as op +import traceback + +from PyQt4.QtCore import Qt, QTimer, QObject, QCoreApplication, QUrl, SIGNAL +from PyQt4.QtGui import QProgressDialog, QDesktopServices, QFileDialog, QDialog, QMessageBox + +from hsutil import job +from hsutil.reg import RegistrationRequired + +from dupeguru import data_pe +from dupeguru.app import (DupeGuru as DupeGuruBase, JOB_SCAN, JOB_LOAD, JOB_MOVE, JOB_COPY, + JOB_DELETE) + +from main_window import MainWindow +from directories_dialog import DirectoriesDialog +from about_box import AboutBox +from reg import Registration +from error_report_dialog import ErrorReportDialog + +JOBID2TITLE = { + JOB_SCAN: "Scanning for duplicates", + JOB_LOAD: "Loading", + JOB_MOVE: "Moving", + JOB_COPY: "Copying", + JOB_DELETE: "Sending files to the recycle bin", +} + +class Progress(QProgressDialog, job.ThreadedJobPerformer): + def __init__(self, parent): + flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint + QProgressDialog.__init__(self, '', u"Cancel", 0, 100, parent, flags) + self.setModal(True) + self.setAutoReset(False) + self.setAutoClose(False) + self._timer = QTimer() + self._jobid = '' + self.connect(self._timer, SIGNAL('timeout()'), self.updateProgress) + + def updateProgress(self): + # the values might change before setValue happens + last_progress = self.last_progress + last_desc = self.last_desc + if not self._job_running or last_progress is None: + self._timer.stop() + self.close() + self.emit(SIGNAL('finished(QString)'), self._jobid) + if self._last_error is not None: + s = ''.join(traceback.format_exception(*self._last_error)) + dialog = ErrorReportDialog(self.parent(), s) + dialog.exec_() + return + if self.wasCanceled(): + self.job_cancelled = True + return + if last_desc: + self.setLabelText(last_desc) + self.setValue(last_progress) + + def run(self, jobid, title, target, args=()): + self._jobid = jobid + self.reset() + self.setLabelText('') + self.run_threaded(target, args) + self.setWindowTitle(title) + self.show() + self._timer.start(500) + + +def demo_method(method): + def wrapper(self, *args, **kwargs): + try: + return method(self, *args, **kwargs) + except RegistrationRequired: + msg = "The demo version of dupeGuru only allows 10 actions (delete/move/copy) per session." + QMessageBox.information(self.main_window, 'Demo', msg) + + return wrapper + +class DupeGuru(DupeGuruBase, QObject): + LOGO_NAME = '' + NAME = '' + DELTA_COLUMNS = frozenset() + + def __init__(self, data_module, appid): + appdata = unicode(QDesktopServices.storageLocation(QDesktopServices.DataLocation)) + DupeGuruBase.__init__(self, data_module, appdata, appid) + QObject.__init__(self) + self._setup() + + #--- Private + def _setup(self): + self.selected_dupe = None + self.prefs = self._create_preferences() + self.prefs.load() + self._update_options() + self.main_window = self._create_main_window() + self._progress = Progress(self.main_window) + self.directories_dialog = DirectoriesDialog(self.main_window, self) + self.details_dialog = self._create_details_dialog(self.main_window) + self.preferences_dialog = self._create_preferences_dialog(self.main_window) + self.about_box = AboutBox(self.main_window, self) + + self.reg = Registration(self) + self.set_registration(self.prefs.registration_code, self.prefs.registration_email) + if not self.registered: + self.reg.show_nag() + self.main_window.show() + self.load() + + self.connect(QCoreApplication.instance(), SIGNAL('aboutToQuit()'), self.application_will_terminate) + self.connect(self._progress, SIGNAL('finished(QString)'), self.job_finished) + + def _setup_as_registered(self): + self.prefs.registration_code = self.registration_code + self.prefs.registration_email = self.registration_email + self.main_window.actionRegister.setVisible(False) + self.about_box.registerButton.hide() + self.about_box.registeredEmailLabel.setText(self.prefs.registration_email) + + def _update_options(self): + self.scanner.mix_file_kind = self.prefs.mix_file_kind + self.options['escape_filter_regexp'] = self.prefs.use_regexp + self.options['clean_empty_dirs'] = self.prefs.remove_empty_folders + + #--- Virtual + def _create_details_dialog(self, parent): + raise NotImplementedError() + + def _create_main_window(self): + return MainWindow(app=self) + + def _create_preferences(self): + raise NotImplementedError() + + def _create_preferences_dialog(self, parent): + raise NotImplementedError() + + #--- Override + def _start_job(self, jobid, func): + title = JOBID2TITLE[jobid] + try: + j = self._progress.create_job() + self._progress.run(jobid, title, func, args=(j, )) + except job.JobInProgressError: + msg = "A previous action is still hanging in there. You can't start a new one yet. Wait a few seconds, then try again." + QMessageBox.information(self.main_window, 'Action in progress', msg) + + #--- Public + def add_dupes_to_ignore_list(self, duplicates): + for dupe in duplicates: + self.AddToIgnoreList(dupe) + self.remove_duplicates(duplicates) + + def ApplyFilter(self, filter): + DupeGuruBase.ApplyFilter(self, filter) + self.emit(SIGNAL('resultsChanged()')) + + def ask_for_reg_code(self): + if self.reg.ask_for_code(): + self._setup_ui_as_registered() + + @demo_method + def copy_or_move_marked(self, copy): + opname = 'copy' if copy else 'move' + title = "Select a directory to {0} marked files to".format(opname) + flags = QFileDialog.ShowDirsOnly + destination = unicode(QFileDialog.getExistingDirectory(self.main_window, title, '', flags)) + if not destination: + return + recreate_path = self.prefs.destination_type + DupeGuruBase.copy_or_move_marked(self, copy, destination, recreate_path) + + delete_marked = demo_method(DupeGuruBase.delete_marked) + + def make_reference(self, duplicates): + DupeGuruBase.make_reference(self, duplicates) + self.emit(SIGNAL('resultsChanged()')) + + def mark_all(self): + self.results.mark_all() + self.emit(SIGNAL('dupeMarkingChanged()')) + + def mark_invert(self): + self.results.mark_invert() + self.emit(SIGNAL('dupeMarkingChanged()')) + + def mark_none(self): + self.results.mark_none() + self.emit(SIGNAL('dupeMarkingChanged()')) + + def open_selected(self): + if self.selected_dupe is None: + return + url = QUrl.fromLocalFile(unicode(self.selected_dupe.path)) + QDesktopServices.openUrl(url) + + def remove_duplicates(self, duplicates): + self.results.remove_duplicates(duplicates) + self.emit(SIGNAL('resultsChanged()')) + + def remove_marked_duplicates(self): + marked = [d for d in self.results.dupes if self.results.is_marked(d)] + self.remove_duplicates(marked) + + def rename_dupe(self, dupe, newname): + try: + dupe.move(dupe.parent, newname) + return True + except (IndexError, fs.FSError) as e: + logging.warning("dupeGuru Warning: %s" % unicode(e)) + return False + + def reveal_selected(self): + if self.selected_dupe is None: + return + url = QUrl.fromLocalFile(unicode(self.selected_dupe.path[:-1])) + QDesktopServices.openUrl(url) + + def select_duplicate(self, dupe): + self.selected_dupe = dupe + self.emit(SIGNAL('duplicateSelected()')) + + def show_about_box(self): + self.about_box.show() + + def show_details(self): + self.details_dialog.show() + + def show_directories(self): + self.directories_dialog.show() + + def show_help(self): + url = QUrl.fromLocalFile(op.abspath('help/intro.htm')) + QDesktopServices.openUrl(url) + + def show_preferences(self): + self.preferences_dialog.load() + result = self.preferences_dialog.exec_() + if result == QDialog.Accepted: + self.preferences_dialog.save() + self.prefs.save() + self._update_options() + + def toggle_marking_for_dupes(self, dupes): + for dupe in dupes: + self.results.mark_toggle(dupe) + self.emit(SIGNAL('dupeMarkingChanged()')) + + #--- Events + def application_will_terminate(self): + self.Save() + self.SaveIgnoreList() + + def job_finished(self, jobid): + self.emit(SIGNAL('resultsChanged()')) + if jobid == JOB_LOAD: + self.emit(SIGNAL('directoriesChanged()')) + if jobid in (JOB_MOVE, JOB_COPY, JOB_DELETE) and self.last_op_error_count > 0: + msg = "{0} files could not be processed.".format(self.results.mark_count) + QMessageBox.warning(self.main_window, 'Warning', msg) + diff --git a/pe/qt/base/details_table.py b/pe/qt/base/details_table.py new file mode 100644 index 00000000..1c45de1e --- /dev/null +++ b/pe/qt/base/details_table.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +# Unit Name: details_table +# Created By: Virgil Dupras +# Created On: 2009-05-17 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import Qt, SIGNAL, QAbstractTableModel, QVariant +from PyQt4.QtGui import QHeaderView, QTableView + +HEADER = ['Attribute', 'Selected', 'Reference'] + +class DetailsModel(QAbstractTableModel): + def __init__(self, app): + QAbstractTableModel.__init__(self) + self._app = app + self._data = app.data + self._dupe_data = None + self._ref_data = None + self.connect(app, SIGNAL('duplicateSelected()'), self.duplicateSelected) + + def columnCount(self, parent): + return len(HEADER) + + def data(self, index, role): + if not index.isValid(): + return QVariant() + if role != Qt.DisplayRole: + return QVariant() + column = index.column() + row = index.row() + if column == 0: + return QVariant(self._data.COLUMNS[row]['display']) + elif column == 1 and self._dupe_data: + return QVariant(self._dupe_data[row]) + elif column == 2 and self._ref_data: + return QVariant(self._ref_data[row]) + return QVariant() + + def headerData(self, section, orientation, role): + if orientation == Qt.Horizontal and role == Qt.DisplayRole and section < len(HEADER): + return QVariant(HEADER[section]) + return QVariant() + + def rowCount(self, parent): + return len(self._data.COLUMNS) + + #--- Events + def duplicateSelected(self): + dupe = self._app.selected_dupe + group = self._app.results.get_group_of_duplicate(dupe) + ref = group.ref + self._dupe_data = self._data.GetDisplayInfo(dupe, group) + self._ref_data = self._data.GetDisplayInfo(ref, group) + self.reset() + + +class DetailsTable(QTableView): + def __init__(self, *args): + QTableView.__init__(self, *args) + self.setAlternatingRowColors(True) + self.setSelectionBehavior(QTableView.SelectRows) + self.setShowGrid(False) + + def setModel(self, model): + QTableView.setModel(self, model) + # The model needs to be set to set header stuff + hheader = self.horizontalHeader() + hheader.setHighlightSections(False) + hheader.setStretchLastSection(False) + hheader.resizeSection(0, 100) + hheader.setResizeMode(0, QHeaderView.Fixed) + hheader.setResizeMode(1, QHeaderView.Stretch) + hheader.setResizeMode(2, QHeaderView.Stretch) + vheader = self.verticalHeader() + vheader.setVisible(False) + vheader.setDefaultSectionSize(18) + diff --git a/pe/qt/base/dg.qrc b/pe/qt/base/dg.qrc new file mode 100644 index 00000000..f2f5e936 --- /dev/null +++ b/pe/qt/base/dg.qrc @@ -0,0 +1,17 @@ + + + images/details32.png + images/dgpe_logo_32.png + images/dgpe_logo_128.png + images/dgme_logo_32.png + images/dgme_logo_128.png + images/dgse_logo_32.png + images/dgse_logo_128.png + images/folderwin32.png + images/gear.png + images/preferences32.png + images/actions32.png + images/delta32.png + images/power_marker32.png + + \ No newline at end of file diff --git a/pe/qt/base/directories_dialog.py b/pe/qt/base/directories_dialog.py new file mode 100644 index 00000000..e2f3ddb3 --- /dev/null +++ b/pe/qt/base/directories_dialog.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python +# Unit Name: directories_dialog +# Created By: Virgil Dupras +# Created On: 2009-04-25 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import SIGNAL, Qt +from PyQt4.QtGui import QDialog, QFileDialog, QHeaderView + +from directories_dialog_ui import Ui_DirectoriesDialog +from directories_model import DirectoriesModel, DirectoriesDelegate + +class DirectoriesDialog(QDialog, Ui_DirectoriesDialog): + def __init__(self, parent, app): + flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint + QDialog.__init__(self, parent, flags) + self.app = app + self._setupUi() + self._updateRemoveButton() + + self.connect(self.doneButton, SIGNAL('clicked()'), self.doneButtonClicked) + self.connect(self.addButton, SIGNAL('clicked()'), self.addButtonClicked) + self.connect(self.removeButton, SIGNAL('clicked()'), self.removeButtonClicked) + self.connect(self.treeView.selectionModel(), SIGNAL('selectionChanged(QItemSelection,QItemSelection)'), self.selectionChanged) + self.connect(self.app, SIGNAL('directoriesChanged()'), self.directoriesChanged) + + def _setupUi(self): + self.setupUi(self) + # Stuff that can't be done in the Designer + self.directoriesModel = DirectoriesModel(self.app) + self.directoriesDelegate = DirectoriesDelegate() + self.treeView.setItemDelegate(self.directoriesDelegate) + self.treeView.setModel(self.directoriesModel) + + header = self.treeView.header() + header.setStretchLastSection(False) + header.setResizeMode(0, QHeaderView.Stretch) + header.setResizeMode(1, QHeaderView.Fixed) + header.resizeSection(1, 100) + + def _updateRemoveButton(self): + indexes = self.treeView.selectedIndexes() + if not indexes: + self.removeButton.setEnabled(False) + return + self.removeButton.setEnabled(True) + index = indexes[0] + node = index.internalPointer() + # label = 'Remove' if node.parent is None else 'Exclude' + + def addButtonClicked(self): + title = u"Select a directory to add to the scanning list" + flags = QFileDialog.ShowDirsOnly + dirpath = unicode(QFileDialog.getExistingDirectory(self, title, '', flags)) + if not dirpath: + return + self.app.AddDirectory(dirpath) + self.directoriesModel.reset() + + def directoriesChanged(self): + self.directoriesModel.reset() + + def doneButtonClicked(self): + self.hide() + + def removeButtonClicked(self): + indexes = self.treeView.selectedIndexes() + if not indexes: + return + index = indexes[0] + node = index.internalPointer() + if node.parent is None: + row = index.row() + del self.app.directories[row] + self.directoriesModel.reset() + + def selectionChanged(self, selected, deselected): + self._updateRemoveButton() + diff --git a/pe/qt/base/directories_dialog.ui b/pe/qt/base/directories_dialog.ui new file mode 100644 index 00000000..68bc8d84 --- /dev/null +++ b/pe/qt/base/directories_dialog.ui @@ -0,0 +1,133 @@ + + + DirectoriesDialog + + + + 0 + 0 + 420 + 338 + + + + Directories + + + + + + QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + + + true + + + false + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 91 + 0 + + + + + 16777215 + 32 + + + + Remove + + + + + + + + 91 + 0 + + + + + 16777215 + 32 + + + + Add + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 91 + 0 + + + + + 16777215 + 32 + + + + Done + + + true + + + + + + + + + + diff --git a/pe/qt/base/directories_model.py b/pe/qt/base/directories_model.py new file mode 100644 index 00000000..cae88f39 --- /dev/null +++ b/pe/qt/base/directories_model.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python +# Unit Name: directories_model +# Created By: Virgil Dupras +# Created On: 2009-04-25 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import QVariant, QModelIndex, Qt, QRect, QEvent, QPoint +from PyQt4.QtGui import QComboBox, QStyledItemDelegate, QMouseEvent, QApplication, QBrush + +from tree_model import TreeNode, TreeModel + +HEADERS = ['Name', 'State'] +STATES = ['Normal', 'Reference', 'Excluded'] + +class DirectoriesDelegate(QStyledItemDelegate): + def createEditor(self, parent, option, index): + editor = QComboBox(parent); + editor.addItems(STATES) + return editor + + def setEditorData(self, editor, index): + value, ok = index.model().data(index, Qt.EditRole).toInt() + assert ok + editor.setCurrentIndex(value); + press = QMouseEvent(QEvent.MouseButtonPress, QPoint(0, 0), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) + release = QMouseEvent(QEvent.MouseButtonRelease, QPoint(0, 0), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) + QApplication.sendEvent(editor, press) + QApplication.sendEvent(editor, release) + # editor.showPopup() # this causes a weird glitch. the ugly workaround is above. + + def setModelData(self, editor, model, index): + value = QVariant(editor.currentIndex()) + model.setData(index, value, Qt.EditRole) + + def updateEditorGeometry(self, editor, option, index): + editor.setGeometry(option.rect) + + +class DirectoryNode(TreeNode): + def __init__(self, parent, ref, row): + TreeNode.__init__(self, parent, row) + self.ref = ref + + def _get_children(self): + children = [] + for index, directory in enumerate(self.ref.dirs): + node = DirectoryNode(self, directory, index) + children.append(node) + return children + + +class DirectoriesModel(TreeModel): + def __init__(self, app): + self._dirs = app.directories + TreeModel.__init__(self) + + def _root_nodes(self): + nodes = [] + for index, directory in enumerate(self._dirs): + nodes.append(DirectoryNode(None, directory, index)) + return nodes + + def columnCount(self, parent): + return 2 + + def data(self, index, role): + if not index.isValid(): + return QVariant() + node = index.internalPointer() + if role == Qt.DisplayRole: + if index.column() == 0: + return QVariant(node.ref.name) + else: + return QVariant(STATES[self._dirs.GetState(node.ref.path)]) + elif role == Qt.EditRole and index.column() == 1: + return QVariant(self._dirs.GetState(node.ref.path)) + elif role == Qt.ForegroundRole: + state = self._dirs.GetState(node.ref.path) + if state == 1: + return QVariant(QBrush(Qt.blue)) + elif state == 2: + return QVariant(QBrush(Qt.red)) + return QVariant() + + def flags(self, index): + if not index.isValid(): + return 0 + result = Qt.ItemIsEnabled | Qt.ItemIsSelectable + if index.column() == 1: + result |= Qt.ItemIsEditable + return result + + def headerData(self, section, orientation, role): + if orientation == Qt.Horizontal: + if role == Qt.DisplayRole and section < len(HEADERS): + return QVariant(HEADERS[section]) + return QVariant() + + def setData(self, index, value, role): + if not index.isValid() or role != Qt.EditRole or index.column() != 1: + return False + node = index.internalPointer() + state, ok = value.toInt() + assert ok + self._dirs.SetState(node.ref.path, state) + return True + diff --git a/pe/qt/base/error_report_dialog.py b/pe/qt/base/error_report_dialog.py new file mode 100644 index 00000000..4aa8f977 --- /dev/null +++ b/pe/qt/base/error_report_dialog.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +# Unit Name: error_report_dialog +# Created By: Virgil Dupras +# Created On: 2009-05-23 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import Qt, QUrl +from PyQt4.QtGui import QDialog, QDesktopServices + +from error_report_dialog_ui import Ui_ErrorReportDialog + +class ErrorReportDialog(QDialog, Ui_ErrorReportDialog): + def __init__(self, parent, error): + flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint + QDialog.__init__(self, parent, flags) + self.setupUi(self) + self.errorTextEdit.setPlainText(error) + + def accept(self): + text = self.errorTextEdit.toPlainText() + url = QUrl("mailto:support@hardcoded.net?SUBJECT=Error Report&BODY=%s" % text) + QDesktopServices.openUrl(url) + QDialog.accept(self) + diff --git a/pe/qt/base/error_report_dialog.ui b/pe/qt/base/error_report_dialog.ui new file mode 100644 index 00000000..0974dd2f --- /dev/null +++ b/pe/qt/base/error_report_dialog.ui @@ -0,0 +1,117 @@ + + + ErrorReportDialog + + + + 0 + 0 + 553 + 349 + + + + Error Report + + + + + + Something went wrong. Would you like to send the error report to Hardcoded Software? + + + true + + + + + + + true + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 110 + 0 + + + + Don't Send + + + + + + + + 110 + 0 + + + + Send + + + true + + + + + + + + + + + sendButton + clicked() + ErrorReportDialog + accept() + + + 485 + 320 + + + 276 + 174 + + + + + dontSendButton + clicked() + ErrorReportDialog + reject() + + + 373 + 320 + + + 276 + 174 + + + + + diff --git a/pe/qt/base/gen.py b/pe/qt/base/gen.py new file mode 100644 index 00000000..3b0df2fa --- /dev/null +++ b/pe/qt/base/gen.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# Unit Name: gen +# Created By: Virgil Dupras +# Created On: 2009-05-22 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import os + +def print_and_do(cmd): + print cmd + os.system(cmd) + +print_and_do("pyuic4 main_window.ui > main_window_ui.py") +print_and_do("pyuic4 directories_dialog.ui > directories_dialog_ui.py") +print_and_do("pyuic4 about_box.ui > about_box_ui.py") +print_and_do("pyuic4 reg_submit_dialog.ui > reg_submit_dialog_ui.py") +print_and_do("pyuic4 reg_demo_dialog.ui > reg_demo_dialog_ui.py") +print_and_do("pyuic4 error_report_dialog.ui > error_report_dialog_ui.py") +print_and_do("pyrcc4 dg.qrc > dg_rc.py") \ No newline at end of file diff --git a/pe/qt/base/images/actions32.png b/pe/qt/base/images/actions32.png new file mode 100755 index 00000000..16d64fc1 Binary files /dev/null and b/pe/qt/base/images/actions32.png differ diff --git a/pe/qt/base/images/delta32.png b/pe/qt/base/images/delta32.png new file mode 100755 index 00000000..f7d95da0 Binary files /dev/null and b/pe/qt/base/images/delta32.png differ diff --git a/pe/qt/base/images/details32.png b/pe/qt/base/images/details32.png new file mode 100644 index 00000000..8ab245b4 Binary files /dev/null and b/pe/qt/base/images/details32.png differ diff --git a/pe/qt/base/images/dgme_logo.ico b/pe/qt/base/images/dgme_logo.ico new file mode 100644 index 00000000..e15f3ffd Binary files /dev/null and b/pe/qt/base/images/dgme_logo.ico differ diff --git a/pe/qt/base/images/dgme_logo_128.png b/pe/qt/base/images/dgme_logo_128.png new file mode 100644 index 00000000..187c21c8 Binary files /dev/null and b/pe/qt/base/images/dgme_logo_128.png differ diff --git a/pe/qt/base/images/dgme_logo_32.png b/pe/qt/base/images/dgme_logo_32.png new file mode 100644 index 00000000..88488462 Binary files /dev/null and b/pe/qt/base/images/dgme_logo_32.png differ diff --git a/pe/qt/base/images/dgpe_logo.ico b/pe/qt/base/images/dgpe_logo.ico new file mode 100644 index 00000000..01ea1b3f Binary files /dev/null and b/pe/qt/base/images/dgpe_logo.ico differ diff --git a/pe/qt/base/images/dgpe_logo_128.png b/pe/qt/base/images/dgpe_logo_128.png new file mode 100644 index 00000000..137b6396 Binary files /dev/null and b/pe/qt/base/images/dgpe_logo_128.png differ diff --git a/pe/qt/base/images/dgpe_logo_32.png b/pe/qt/base/images/dgpe_logo_32.png new file mode 100755 index 00000000..5384a81c Binary files /dev/null and b/pe/qt/base/images/dgpe_logo_32.png differ diff --git a/pe/qt/base/images/dgse_logo.ico b/pe/qt/base/images/dgse_logo.ico new file mode 100644 index 00000000..992c9280 Binary files /dev/null and b/pe/qt/base/images/dgse_logo.ico differ diff --git a/pe/qt/base/images/dgse_logo_128.png b/pe/qt/base/images/dgse_logo_128.png new file mode 100644 index 00000000..f50221b2 Binary files /dev/null and b/pe/qt/base/images/dgse_logo_128.png differ diff --git a/pe/qt/base/images/dgse_logo_32.png b/pe/qt/base/images/dgse_logo_32.png new file mode 100755 index 00000000..29d53d2d Binary files /dev/null and b/pe/qt/base/images/dgse_logo_32.png differ diff --git a/pe/qt/base/images/folder32.png b/pe/qt/base/images/folder32.png new file mode 100755 index 00000000..85070da7 Binary files /dev/null and b/pe/qt/base/images/folder32.png differ diff --git a/pe/qt/base/images/folderwin32.png b/pe/qt/base/images/folderwin32.png new file mode 100755 index 00000000..5e861a4b Binary files /dev/null and b/pe/qt/base/images/folderwin32.png differ diff --git a/pe/qt/base/images/gear.png b/pe/qt/base/images/gear.png new file mode 100755 index 00000000..41ff2dd6 Binary files /dev/null and b/pe/qt/base/images/gear.png differ diff --git a/pe/qt/base/images/power_marker32.png b/pe/qt/base/images/power_marker32.png new file mode 100755 index 00000000..48129026 Binary files /dev/null and b/pe/qt/base/images/power_marker32.png differ diff --git a/pe/qt/base/images/preferences32.png b/pe/qt/base/images/preferences32.png new file mode 100755 index 00000000..bdbc4051 Binary files /dev/null and b/pe/qt/base/images/preferences32.png differ diff --git a/pe/qt/base/main_window.py b/pe/qt/base/main_window.py new file mode 100644 index 00000000..3ca20de3 --- /dev/null +++ b/pe/qt/base/main_window.py @@ -0,0 +1,304 @@ +#!/usr/bin/env python +# Unit Name: main_window +# Created By: Virgil Dupras +# Created On: 2009-04-25 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import Qt, QCoreApplication, QProcess, SIGNAL +from PyQt4.QtGui import (QMainWindow, QMenu, QPixmap, QIcon, QToolButton, QLabel, QHeaderView, + QMessageBox, QInputDialog, QLineEdit) + +from hsutil.misc import nonone + +from dupeguru.app import NoScannableFileError, AllFilesAreRefError + +import dg_rc +from main_window_ui import Ui_MainWindow +from results_model import ResultsDelegate, ResultsModel + +class MainWindow(QMainWindow, Ui_MainWindow): + def __init__(self, app): + QMainWindow.__init__(self, None) + self.app = app + self._last_filter = None + self._setupUi() + self.resultsDelegate = ResultsDelegate() + self.resultsModel = ResultsModel(self.app) + self.resultsView.setModel(self.resultsModel) + self.resultsView.setItemDelegate(self.resultsDelegate) + self._load_columns() + self._update_column_actions_status() + self.resultsView.expandAll() + self._update_status_line() + + self.connect(self.app, SIGNAL('resultsChanged()'), self.resultsChanged) + self.connect(self.app, SIGNAL('dupeMarkingChanged()'), self.dupeMarkingChanged) + self.connect(self.actionQuit, SIGNAL('triggered()'), QCoreApplication.instance().quit) + self.connect(self.resultsView.selectionModel(), SIGNAL('selectionChanged(QItemSelection,QItemSelection)'), self.selectionChanged) + self.connect(self.menuColumns, SIGNAL('triggered(QAction*)'), self.columnToggled) + self.connect(QCoreApplication.instance(), SIGNAL('aboutToQuit()'), self.application_will_terminate) + self.connect(self.resultsModel, SIGNAL('modelReset()'), self.resultsReset) + + def _setupUi(self): + self.setupUi(self) + # Stuff that can't be setup in the Designer + h = self.resultsView.header() + h.setHighlightSections(False) + h.setMovable(True) + h.setStretchLastSection(False) + h.setDefaultAlignment(Qt.AlignLeft) + + self.setWindowTitle(QCoreApplication.instance().applicationName()) + self.actionScan.setIcon(QIcon(QPixmap(':/%s' % self.app.LOGO_NAME))) + + # Columns menu + menu = self.menuColumns + self._column_actions = [] + for index, column in enumerate(self.app.data.COLUMNS): + action = menu.addAction(column['display']) + action.setCheckable(True) + action.column_index = index + self._column_actions.append(action) + menu.addSeparator() + action = menu.addAction("Reset to Defaults") + action.column_index = -1 + + # Action menu + actionMenu = QMenu('Actions', self.toolBar) + actionMenu.setIcon(QIcon(QPixmap(":/actions"))) + actionMenu.addAction(self.actionDeleteMarked) + actionMenu.addAction(self.actionMoveMarked) + actionMenu.addAction(self.actionCopyMarked) + actionMenu.addAction(self.actionRemoveMarked) + actionMenu.addSeparator() + actionMenu.addAction(self.actionRemoveSelected) + actionMenu.addAction(self.actionIgnoreSelected) + actionMenu.addAction(self.actionMakeSelectedReference) + actionMenu.addSeparator() + actionMenu.addAction(self.actionOpenSelected) + actionMenu.addAction(self.actionRevealSelected) + actionMenu.addAction(self.actionRenameSelected) + self.actionActions.setMenu(actionMenu) + button = QToolButton(self.toolBar) + button.setDefaultAction(actionMenu.menuAction()) + button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) + self.actionsButton = button + self.toolBar.insertWidget(self.actionActions, button) # the action is a placeholder + self.toolBar.removeAction(self.actionActions) + + self.statusLabel = QLabel(self) + self.statusbar.addPermanentWidget(self.statusLabel, 1) + + #--- Private + def _confirm(self, title, msg, default_button=QMessageBox.Yes): + buttons = QMessageBox.Yes | QMessageBox.No + answer = QMessageBox.question(self, title, msg, buttons, default_button) + return answer == QMessageBox.Yes + + def _load_columns(self): + h = self.resultsView.header() + h.setResizeMode(QHeaderView.Interactive) + prefs = self.app.prefs + attrs = zip(prefs.columns_width, prefs.columns_visible) + for index, (width, visible) in enumerate(attrs): + h.resizeSection(index, width) + h.setSectionHidden(index, not visible) + h.setResizeMode(0, QHeaderView.Stretch) + + def _redraw_results(self): + # HACK. this is the only way I found to update the widget without reseting everything + self.resultsView.scroll(0, 1) + self.resultsView.scroll(0, -1) + + def _save_columns(self): + h = self.resultsView.header() + widths = [] + visible = [] + for i in range(len(self.app.data.COLUMNS)): + widths.append(h.sectionSize(i)) + visible.append(not h.isSectionHidden(i)) + prefs = self.app.prefs + prefs.columns_width = widths + prefs.columns_visible = visible + prefs.save() + + def _update_column_actions_status(self): + h = self.resultsView.header() + for action in self._column_actions: + colid = action.column_index + action.setChecked(not h.isSectionHidden(colid)) + + def _update_status_line(self): + self.statusLabel.setText(self.app.stat_line) + + #--- Actions + def aboutTriggered(self): + self.app.show_about_box() + + def actionsTriggered(self): + self.actionsButton.showMenu() + + def addToIgnoreListTriggered(self): + dupes = self.resultsView.selectedDupes() + if not dupes: + return + title = "Add to Ignore List" + msg = "All selected {0} matches are going to be ignored in all subsequent scans. Continue?".format(len(dupes)) + if self._confirm(title, msg): + self.app.add_dupes_to_ignore_list(dupes) + + def applyFilterTriggered(self): + title = "Apply Filter" + msg = "Type the filter you want to apply on your results. See help for details." + text = nonone(self._last_filter, '[*]') + answer, ok = QInputDialog.getText(self, title, msg, QLineEdit.Normal, text) + if not ok: + return + answer = unicode(answer) + self.app.ApplyFilter(answer) + self._last_filter = answer + + def cancelFilterTriggered(self): + self.app.ApplyFilter('') + + def checkForUpdateTriggered(self): + QProcess.execute('updater.exe', ['/checknow']) + + def clearIgnoreListTriggered(self): + title = "Clear Ignore List" + count = len(self.app.scanner.ignore_list) + if not count: + QMessageBox.information(self, title, "Nothing to clear.") + return + msg = "Do you really want to remove all {0} items from the ignore list?".format(count) + if self._confirm(title, msg, QMessageBox.No): + self.app.scanner.ignore_list.Clear() + QMessageBox.information(self, title, "Ignore list cleared.") + + def copyTriggered(self): + self.app.copy_or_move_marked(True) + + def deleteTriggered(self): + count = self.app.results.mark_count + if not count: + return + title = "Delete duplicates" + msg = "You are about to send {0} files to the recycle bin. Continue?".format(count) + if self._confirm(title, msg): + self.app.delete_marked() + + def deltaTriggered(self): + self.resultsModel.delta = self.actionDelta.isChecked() + self._redraw_results() + + def detailsTriggered(self): + self.app.show_details() + + def directoriesTriggered(self): + self.app.show_directories() + + def makeReferenceTriggered(self): + self.app.make_reference(self.resultsView.selectedDupes()) + + def markAllTriggered(self): + self.app.mark_all() + + def markInvertTriggered(self): + self.app.mark_invert() + + def markNoneTriggered(self): + self.app.mark_none() + + def markSelectedTriggered(self): + dupes = self.resultsView.selectedDupes() + self.app.toggle_marking_for_dupes(dupes) + + def moveTriggered(self): + self.app.copy_or_move_marked(False) + + def openTriggered(self): + self.app.open_selected() + + def powerMarkerTriggered(self): + self.resultsModel.power_marker = self.actionPowerMarker.isChecked() + + def preferencesTriggered(self): + self.app.show_preferences() + + def registerTrigerred(self): + self.app.ask_for_reg_code() + + def removeMarkedTriggered(self): + count = self.app.results.mark_count + if not count: + return + title = "Remove duplicates" + msg = "You are about to remove {0} files from results. Continue?".format(count) + if self._confirm(title, msg): + self.app.remove_marked_duplicates() + + def removeSelectedTriggered(self): + dupes = self.resultsView.selectedDupes() + if not dupes: + return + title = "Remove duplicates" + msg = "You are about to remove {0} files from results. Continue?".format(len(dupes)) + if self._confirm(title, msg): + self.app.remove_duplicates(dupes) + + def renameTriggered(self): + self.resultsView.edit(self.resultsView.selectionModel().currentIndex()) + + def revealTriggered(self): + self.app.reveal_selected() + + def scanTriggered(self): + title = "Start a new scan" + if len(self.app.results.groups) > 0: + msg = "Are you sure you want to start a new duplicate scan?" + if not self._confirm(title, msg): + return + try: + self.app.start_scanning() + except NoScannableFileError: + msg = "The selected directories contain no scannable file." + QMessageBox.warning(self, title, msg) + self.app.show_directories() + except AllFilesAreRefError: + msg = "You cannot make a duplicate scan with only reference directories." + QMessageBox.warning(self, title, msg) + + def showHelpTriggered(self): + self.app.show_help() + + #--- Events + def application_will_terminate(self): + self._save_columns() + + def columnToggled(self, action): + colid = action.column_index + if colid == -1: + self.app.prefs.reset_columns() + self._load_columns() + else: + h = self.resultsView.header() + h.setSectionHidden(colid, not h.isSectionHidden(colid)) + self._update_column_actions_status() + + def dupeMarkingChanged(self): + self._redraw_results() + self._update_status_line() + + def resultsChanged(self): + self.resultsView.model().reset() + + def resultsReset(self): + self.resultsView.expandAll() + self._update_status_line() + + def selectionChanged(self, selected, deselected): + index = self.resultsView.selectionModel().currentIndex() + dupe = index.internalPointer().dupe if index.isValid() else None + self.app.select_duplicate(dupe) + diff --git a/pe/qt/base/main_window.ui b/pe/qt/base/main_window.ui new file mode 100644 index 00000000..754f265c --- /dev/null +++ b/pe/qt/base/main_window.ui @@ -0,0 +1,911 @@ + + + MainWindow + + + + 0 + 0 + 630 + 514 + + + + dupeGuru + + + + + 0 + + + + + QAbstractItemView::ExtendedSelection + + + QAbstractItemView::SelectRows + + + false + + + true + + + false + + + true + + + false + + + false + + + + + + + + + 0 + 0 + 630 + 22 + + + + + Columns + + + + + Actions + + + + + + + + + + + + + + + + + + + + Mark + + + + + + + + + Modes + + + + + + + Windows + + + + + + + + Help + + + + + + + + + File + + + + + + + + + + + + + + + + + + toolBar + + + false + + + Qt::ToolButtonTextUnderIcon + + + false + + + TopToolBarArea + + + false + + + + + + + + + + + + true + + + + + + :/logo_pe:/logo_pe + + + Start Scan + + + Start scanning for duplicates + + + Ctrl+S + + + + + + :/folder:/folder + + + Directories + + + Ctrl+4 + + + + + + :/details:/details + + + Details + + + Ctrl+3 + + + + + + :/actions:/actions + + + Actions + + + + + + :/preferences:/preferences + + + Preferences + + + Ctrl+5 + + + + + true + + + + :/delta:/delta + + + Delta Values + + + Ctrl+2 + + + + + true + + + + :/power_marker:/power_marker + + + Power Marker + + + Ctrl+1 + + + + + Send Marked to Recycle Bin + + + Ctrl+D + + + + + Move Marked to... + + + Ctrl+M + + + + + Copy Marked to... + + + Ctrl+Shift+M + + + + + Remove Marked from Results + + + Ctrl+R + + + + + Remove Selected from Results + + + Ctrl+Del + + + + + Add Selected to Ignore List + + + Ctrl+Shift+Del + + + + + Make Selected Reference + + + Ctrl+Space + + + + + Open Selected with Default Application + + + Ctrl+O + + + + + Open Containing Folder of Selected + + + Ctrl+Shift+O + + + + + Rename Selected + + + F2 + + + + + Mark All + + + Ctrl+A + + + + + Mark None + + + Ctrl+Shift+A + + + + + Invert Marking + + + Ctrl+Alt+A + + + + + Mark Selected + + + + + Clear Ignore List + + + + + Quit + + + Ctrl+Q + + + + + Apply Filter + + + Ctrl+F + + + + + Cancel Filter + + + Ctrl+Shift+F + + + + + dupeGuru Help + + + F1 + + + + + About dupeGuru + + + + + Register dupeGuru + + + + + Check for Update + + + + + + ResultsView + QTreeView +
results_model
+
+
+ + + + + + actionDirectories + triggered() + MainWindow + directoriesTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionActions + triggered() + MainWindow + actionsTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionCopyMarked + triggered() + MainWindow + copyTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionDeleteMarked + triggered() + MainWindow + deleteTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionDelta + triggered() + MainWindow + deltaTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionDetails + triggered() + MainWindow + detailsTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionIgnoreSelected + triggered() + MainWindow + addToIgnoreListTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionMakeSelectedReference + triggered() + MainWindow + makeReferenceTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionMoveMarked + triggered() + MainWindow + moveTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionOpenSelected + triggered() + MainWindow + openTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionPowerMarker + triggered() + MainWindow + powerMarkerTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionPreferences + triggered() + MainWindow + preferencesTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionRemoveMarked + triggered() + MainWindow + removeMarkedTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionRemoveSelected + triggered() + MainWindow + removeSelectedTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionRevealSelected + triggered() + MainWindow + revealTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionRenameSelected + triggered() + MainWindow + renameTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionScan + triggered() + MainWindow + scanTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionClearIgnoreList + triggered() + MainWindow + clearIgnoreListTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionMarkAll + triggered() + MainWindow + markAllTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionMarkNone + triggered() + MainWindow + markNoneTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionMarkSelected + triggered() + MainWindow + markSelectedTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionInvertMarking + triggered() + MainWindow + markInvertTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionApplyFilter + triggered() + MainWindow + applyFilterTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionCancelFilter + triggered() + MainWindow + cancelFilterTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionShowHelp + triggered() + MainWindow + showHelpTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionAbout + triggered() + MainWindow + aboutTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + actionRegister + triggered() + MainWindow + registerTrigerred() + + + -1 + -1 + + + 314 + 256 + + + + + actionCheckForUpdate + triggered() + MainWindow + checkForUpdateTriggered() + + + -1 + -1 + + + 314 + 256 + + + + + + directoriesTriggered() + scanTriggered() + actionsTriggered() + detailsTriggered() + preferencesTriggered() + deltaTriggered() + powerMarkerTriggered() + deleteTriggered() + moveTriggered() + copyTriggered() + removeMarkedTriggered() + removeSelectedTriggered() + addToIgnoreListTriggered() + makeReferenceTriggered() + openTriggered() + revealTriggered() + renameTriggered() + clearIgnoreListTriggered() + clearPictureCacheTriggered() + markAllTriggered() + markNoneTriggered() + markInvertTriggered() + markSelectedTriggered() + applyFilterTriggered() + cancelFilterTriggered() + showHelpTriggered() + aboutTriggered() + registerTrigerred() + checkForUpdateTriggered() + +
diff --git a/pe/qt/base/preferences.py b/pe/qt/base/preferences.py new file mode 100644 index 00000000..64ad64d5 --- /dev/null +++ b/pe/qt/base/preferences.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python +# Unit Name: preferences +# Created By: Virgil Dupras +# Created On: 2009-05-03 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import QSettings, QVariant + +from hsutil.misc import tryint + +def variant_to_py(v): + value = None + ok = False + t = v.type() + if t == QVariant.String: + value = unicode(v.toString()) + ok = True # anyway + # might be bool or int, try them + if v == 'true': + value = True + elif value == 'false': + value = False + else: + value = tryint(value, value) + elif t == QVariant.Int: + value, ok = v.toInt() + elif t == QVariant.Bool: + value, ok = v.toBool(), True + elif t in (QVariant.List, QVariant.StringList): + value, ok = map(variant_to_py, v.toList()), True + if not ok: + raise TypeError() + return value + +class Preferences(object): + # (width, is_visible) + COLUMNS_DEFAULT_ATTRS = [] + + def __init__(self): + self.reset() + self.reset_columns() + + def _load_specific(self, settings, get): + # load prefs specific to the dg edition + pass + + def load(self): + self.reset() + settings = QSettings() + def get(name, default): + if settings.contains(name): + return variant_to_py(settings.value(name)) + else: + return default + + self.filter_hardness = get('FilterHardness', self.filter_hardness) + self.mix_file_kind = get('MixFileKind', self.mix_file_kind) + self.use_regexp = get('UseRegexp', self.use_regexp) + self.remove_empty_folders = get('RemoveEmptyFolders', self.remove_empty_folders) + self.destination_type = get('DestinationType', self.destination_type) + widths = get('ColumnsWidth', self.columns_width) + # only set nonzero values + for index, width in enumerate(widths[:len(self.columns_width)]): + if width > 0: + self.columns_width[index] = width + self.columns_visible = get('ColumnsVisible', self.columns_visible) + self.registration_code = get('RegistrationCode', self.registration_code) + self.registration_email = get('RegistrationEmail', self.registration_email) + self._load_specific(settings, get) + + def _reset_specific(self): + # reset prefs specific to the dg edition + pass + + def reset(self): + self.filter_hardness = 95 + self.mix_file_kind = True + self.use_regexp = False + self.remove_empty_folders = False + self.destination_type = 1 + self.registration_code = '' + self.registration_email = '' + self._reset_specific() + + def reset_columns(self): + self.columns_width = [width for width, _ in self.COLUMNS_DEFAULT_ATTRS] + self.columns_visible = [visible for _, visible in self.COLUMNS_DEFAULT_ATTRS] + + def _save_specific(self, settings, set_): + # save prefs specific to the dg edition + pass + + def save(self): + settings = QSettings() + def set_(name, value): + settings.setValue(name, QVariant(value)) + + set_('FilterHardness', self.filter_hardness) + set_('MixFileKind', self.mix_file_kind) + set_('UseRegexp', self.use_regexp) + set_('RemoveEmptyFolders', self.remove_empty_folders) + set_('DestinationType', self.destination_type) + set_('ColumnsWidth', self.columns_width) + set_('ColumnsVisible', self.columns_visible) + set_('RegistrationCode', self.registration_code) + set_('RegistrationEmail', self.registration_email) + self._save_specific(settings, set_) + diff --git a/pe/qt/base/reg.py b/pe/qt/base/reg.py new file mode 100644 index 00000000..59fd0bc3 --- /dev/null +++ b/pe/qt/base/reg.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# Unit Name: reg +# Created By: Virgil Dupras +# Created On: 2009-05-09 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from hashlib import md5 + +from PyQt4.QtGui import QDialog + +from reg_submit_dialog import RegSubmitDialog +from reg_demo_dialog import RegDemoDialog + +class Registration(object): + def __init__(self, app): + self.app = app + + def ask_for_code(self): + dialog = RegSubmitDialog(self.app.main_window, self.app.is_code_valid) + result = dialog.exec_() + code = unicode(dialog.codeEdit.text()) + email = unicode(dialog.emailEdit.text()) + dialog.setParent(None) # free it + if result == QDialog.Accepted and self.app.is_code_valid(code, email): + self.app.set_registration(code, email) + return True + return False + + def show_nag(self): + dialog = RegDemoDialog(self.app.main_window, self) + dialog.exec_() + dialog.setParent(None) # free it + diff --git a/pe/qt/base/reg_demo_dialog.py b/pe/qt/base/reg_demo_dialog.py new file mode 100644 index 00000000..95280314 --- /dev/null +++ b/pe/qt/base/reg_demo_dialog.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +# Unit Name: reg_demo_dialog +# Created By: Virgil Dupras +# Created On: 2009-05-10 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import SIGNAL, Qt, QUrl, QCoreApplication +from PyQt4.QtGui import QDialog, QMessageBox, QDesktopServices + +from reg_demo_dialog_ui import Ui_RegDemoDialog + +class RegDemoDialog(QDialog, Ui_RegDemoDialog): + def __init__(self, parent, reg): + flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint + QDialog.__init__(self, parent, flags) + self.reg = reg + self._setupUi() + + self.connect(self.enterCodeButton, SIGNAL('clicked()'), self.enterCodeClicked) + self.connect(self.purchaseButton, SIGNAL('clicked()'), self.purchaseClicked) + + def _setupUi(self): + self.setupUi(self) + # Stuff that can't be setup in the Designer + appname = QCoreApplication.instance().applicationName() + title = self.windowTitle() + title = title.replace('$appname', appname) + self.setWindowTitle(title) + title = self.titleLabel.text() + title = title.replace('$appname', appname) + self.titleLabel.setText(title) + desc = self.demoDescLabel.text() + desc = desc.replace('$appname', appname) + self.demoDescLabel.setText(desc) + + #--- Events + def enterCodeClicked(self): + if self.reg.ask_for_code(): + self.accept() + + def purchaseClicked(self): + url = QUrl('http://www.hardcoded.net/purchase.htm') + QDesktopServices.openUrl(url) + diff --git a/pe/qt/base/reg_demo_dialog.ui b/pe/qt/base/reg_demo_dialog.ui new file mode 100644 index 00000000..ef918225 --- /dev/null +++ b/pe/qt/base/reg_demo_dialog.ui @@ -0,0 +1,140 @@ + + + RegDemoDialog + + + + 0 + 0 + 387 + 161 + + + + $appname Demo Version + + + + + + + 75 + true + + + + $appname Demo Version + + + + + + + You are currently running a demo version of $appname. This version has limited functionalities, and you need to buy it to have access to these functionalities. + + + true + + + + + + + In the demo version, only 10 duplicates per session can be sent to the recycle bin, moved or copied. + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 110 + 0 + + + + Try Demo + + + + + + + + 110 + 0 + + + + Enter Code + + + + + + + + 110 + 0 + + + + Purchase + + + + + + + + + + + tryButton + clicked() + RegDemoDialog + accept() + + + 112 + 161 + + + 201 + 94 + + + + + diff --git a/pe/qt/base/reg_submit_dialog.py b/pe/qt/base/reg_submit_dialog.py new file mode 100644 index 00000000..4ba680b6 --- /dev/null +++ b/pe/qt/base/reg_submit_dialog.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# Unit Name: reg_submit_dialog +# Created By: Virgil Dupras +# Created On: 2009-05-09 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import SIGNAL, Qt, QUrl, QCoreApplication +from PyQt4.QtGui import QDialog, QMessageBox, QDesktopServices + +from reg_submit_dialog_ui import Ui_RegSubmitDialog + +class RegSubmitDialog(QDialog, Ui_RegSubmitDialog): + def __init__(self, parent, is_valid_func): + flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint + QDialog.__init__(self, parent, flags) + self._setupUi() + self.is_valid_func = is_valid_func + + self.connect(self.submitButton, SIGNAL('clicked()'), self.submitClicked) + self.connect(self.purchaseButton, SIGNAL('clicked()'), self.purchaseClicked) + + def _setupUi(self): + self.setupUi(self) + # Stuff that can't be setup in the Designer + appname = QCoreApplication.instance().applicationName() + prompt = self.promptLabel.text() + prompt = prompt.replace('$appname', appname) + self.promptLabel.setText(prompt) + + #--- Events + def purchaseClicked(self): + url = QUrl('http://www.hardcoded.net/purchase.htm') + QDesktopServices.openUrl(url) + + def submitClicked(self): + code = unicode(self.codeEdit.text()) + email = unicode(self.emailEdit.text()) + title = "Registration" + if self.is_valid_func(code, email): + msg = "This code is valid. Thanks!" + QMessageBox.information(self, title, msg) + self.accept() + else: + msg = "This code is invalid" + QMessageBox.warning(self, title, msg) + diff --git a/pe/qt/base/reg_submit_dialog.ui b/pe/qt/base/reg_submit_dialog.ui new file mode 100644 index 00000000..06de4191 --- /dev/null +++ b/pe/qt/base/reg_submit_dialog.ui @@ -0,0 +1,149 @@ + + + RegSubmitDialog + + + + 0 + 0 + 365 + 134 + + + + Enter your registration code + + + + + + Please enter your $appname registration code and registered e-mail (the e-mail you used for the purchase), then press "Submit". + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + QLayout::SetNoConstraint + + + QFormLayout::ExpandingFieldsGrow + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + Registration code: + + + + + + + Registered e-mail: + + + + + + + + + + + + + + + + + Purchase + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Cancel + + + false + + + + + + + + 0 + 0 + + + + Submit + + + false + + + true + + + + + + + + + + + cancelButton + clicked() + RegSubmitDialog + reject() + + + 260 + 159 + + + 198 + 97 + + + + + diff --git a/pe/qt/base/results_model.py b/pe/qt/base/results_model.py new file mode 100644 index 00000000..d28d6da3 --- /dev/null +++ b/pe/qt/base/results_model.py @@ -0,0 +1,175 @@ +#!/usr/bin/env python +# Unit Name: +# Created By: Virgil Dupras +# Created On: 2009-04-23 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import SIGNAL, Qt, QAbstractItemModel, QVariant, QModelIndex, QRect +from PyQt4.QtGui import QBrush, QStyledItemDelegate, QFont, QTreeView, QColor + +from tree_model import TreeNode, TreeModel + +class ResultNode(TreeNode): + def __init__(self, model, parent, row, dupe, group): + TreeNode.__init__(self, parent, row) + self.model = model + self.dupe = dupe + self.group = group + self._normalData = None + self._deltaData = None + + def _get_children(self): + children = [] + if self.dupe is self.group.ref: + for index, dupe in enumerate(self.group.dupes): + children.append(ResultNode(self.model, self, index, dupe, self.group)) + return children + + def reset(self): + self._normalData = None + self._deltaData = None + + @property + def normalData(self): + if self._normalData is None: + self._normalData = self.model._data.GetDisplayInfo(self.dupe, self.group, delta=False) + return self._normalData + + @property + def deltaData(self): + if self._deltaData is None: + self._deltaData = self.model._data.GetDisplayInfo(self.dupe, self.group, delta=True) + return self._deltaData + + +class ResultsDelegate(QStyledItemDelegate): + def initStyleOption(self, option, index): + QStyledItemDelegate.initStyleOption(self, option, index) + node = index.internalPointer() + if node.group.ref is node.dupe: + newfont = QFont(option.font) + newfont.setBold(True) + option.font = newfont + + +class ResultsModel(TreeModel): + def __init__(self, app): + self._app = app + self._results = app.results + self._data = app.data + self._delta_columns = app.DELTA_COLUMNS + self.delta = False + self._power_marker = False + TreeModel.__init__(self) + + def _root_nodes(self): + nodes = [] + if self.power_marker: + for index, dupe in enumerate(self._results.dupes): + group = self._results.get_group_of_duplicate(dupe) + nodes.append(ResultNode(self, None, index, dupe, group)) + else: + for index, group in enumerate(self._results.groups): + nodes.append(ResultNode(self, None, index, group.ref, group)) + return nodes + + def columnCount(self, parent): + return len(self._data.COLUMNS) + + def data(self, index, role): + if not index.isValid(): + return QVariant() + node = index.internalPointer() + if role == Qt.DisplayRole: + data = node.deltaData if self.delta else node.normalData + return QVariant(data[index.column()]) + elif role == Qt.CheckStateRole: + if index.column() == 0 and node.dupe is not node.group.ref: + state = Qt.Checked if self._results.is_marked(node.dupe) else Qt.Unchecked + return QVariant(state) + elif role == Qt.ForegroundRole: + if node.dupe is node.group.ref or node.dupe.is_ref: + return QVariant(QBrush(Qt.blue)) + elif self.delta and index.column() in self._delta_columns: + return QVariant(QBrush(QColor(255, 142, 40))) # orange + elif role == Qt.EditRole: + if index.column() == 0: + return QVariant(node.normalData[index.column()]) + return QVariant() + + def dupesForIndexes(self, indexes): + nodes = [index.internalPointer() for index in indexes] + return [node.dupe for node in nodes] + + def flags(self, index): + if not index.isValid(): + return Qt.ItemIsEnabled + flags = Qt.ItemIsEnabled | Qt.ItemIsSelectable + if index.column() == 0: + flags |= Qt.ItemIsUserCheckable | Qt.ItemIsEditable + return flags + + def headerData(self, section, orientation, role): + if orientation == Qt.Horizontal and role == Qt.DisplayRole and section < len(self._data.COLUMNS): + return QVariant(self._data.COLUMNS[section]['display']) + + return QVariant() + + def setData(self, index, value, role): + if not index.isValid(): + return False + node = index.internalPointer() + if role == Qt.CheckStateRole: + if index.column() == 0: + self._app.toggle_marking_for_dupes([node.dupe]) + return True + if role == Qt.EditRole: + if index.column() == 0: + value = unicode(value.toString()) + if self._app.rename_dupe(node.dupe, value): + node.reset() + return True + return False + + def sort(self, column, order): + if self.power_marker: + self._results.sort_dupes(column, order == Qt.AscendingOrder, self.delta) + else: + self._results.sort_groups(column, order == Qt.AscendingOrder) + self.reset() + + def toggleMarked(self, indexes): + assert indexes + dupes = self.dupesForIndexes(indexes) + self._app.toggle_marking_for_dupes(dupes) + + #--- Properties + @property + def power_marker(self): + return self._power_marker + + @power_marker.setter + def power_marker(self, value): + if value == self._power_marker: + return + self._power_marker = value + self.reset() + + +class ResultsView(QTreeView): + #--- Override + def keyPressEvent(self, event): + if event.text() == ' ': + self.model().toggleMarked(self.selectionModel().selectedRows()) + return + QTreeView.keyPressEvent(self, event) + + def setModel(self, model): + assert isinstance(model, ResultsModel) + QTreeView.setModel(self, model) + + #--- Public + def selectedDupes(self): + return self.model().dupesForIndexes(self.selectionModel().selectedRows()) + diff --git a/pe/qt/base/tree_model.py b/pe/qt/base/tree_model.py new file mode 100644 index 00000000..b3a994b3 --- /dev/null +++ b/pe/qt/base/tree_model.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# Unit Name: tree_model +# Created By: Virgil Dupras +# Created On: 2009-05-04 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import Qt, QAbstractItemModel, QVariant, QModelIndex + +class TreeNode(object): + def __init__(self, parent, row): + self.parent = parent + self.row = row + self._children = None + + def _get_children(self): + raise NotImplementedError() + + @property + def children(self): + if self._children is None: + self._children = self._get_children() + return self._children + + +class TreeModel(QAbstractItemModel): + def __init__(self): + QAbstractItemModel.__init__(self) + self._nodes = None + + def _root_nodes(self): + raise NotImplementedError() + + def index(self, row, column, parent): + if not self.nodes: + return QModelIndex() + if not parent.isValid(): + return self.createIndex(row, column, self.nodes[row]) + node = parent.internalPointer() + return self.createIndex(row, column, node.children[row]) + + def parent(self, index): + if not index.isValid(): + return QModelIndex() + node = index.internalPointer() + if node.parent is None: + return QModelIndex() + else: + return self.createIndex(node.parent.row, 0, node.parent) + + def reset(self): + self._nodes = None + QAbstractItemModel.reset(self) + + def rowCount(self, parent): + if not parent.isValid(): + return len(self.nodes) + node = parent.internalPointer() + return len(node.children) + + @property + def nodes(self): + if self._nodes is None: + self._nodes = self._root_nodes() + return self._nodes + diff --git a/pe/qt/block.py b/pe/qt/block.py new file mode 100644 index 00000000..0270aba1 --- /dev/null +++ b/pe/qt/block.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# Unit Name: block +# Created By: Virgil Dupras +# Created On: 2009-05-10 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from _block import getblocks + +# Converted to Cython +# def getblock(image): +# width = image.width() +# height = image.height() +# if width: +# pixel_count = width * height +# red = green = blue = 0 +# s = image.bits().asstring(image.numBytes()) +# for i in xrange(pixel_count): +# offset = i * 3 +# red += ord(s[offset]) +# green += ord(s[offset + 1]) +# blue += ord(s[offset + 2]) +# return (red // pixel_count, green // pixel_count, blue // pixel_count) +# else: +# return (0, 0, 0) +# +# def getblocks(image, block_count_per_side): +# width = image.width() +# height = image.height() +# if not width: +# return [] +# block_width = max(width // block_count_per_side, 1) +# block_height = max(height // block_count_per_side, 1) +# result = [] +# for ih in xrange(block_count_per_side): +# top = min(ih * block_height, height - block_height) +# for iw in range(block_count_per_side): +# left = min(iw * block_width, width - block_width) +# crop = image.copy(left, top, block_width, block_height) +# result.append(getblock(crop)) +# return result diff --git a/pe/qt/build.py b/pe/qt/build.py new file mode 100644 index 00000000..6e454952 --- /dev/null +++ b/pe/qt/build.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python +# Unit Name: build +# Created By: Virgil Dupras +# Created On: 2009-05-22 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +# On Windows, PyInstaller is used to build an exe (py2exe creates a very bad looking icon +# The release version is outdated. Use at least r672 on http://svn.pyinstaller.org/trunk + +import os +import shutil +from app import DupeGuru + +def print_and_do(cmd): + print cmd + os.system(cmd) + +# Removing build and dist +shutil.rmtree('build') +shutil.rmtree('dist') + +version = DupeGuru.VERSION +versioncomma = version.replace('.', ', ') + ', 0' +verinfo = open('verinfo').read() +verinfo = verinfo.replace('$versioncomma', versioncomma).replace('$version', version) +fp = open('verinfo_tmp', 'w') +fp.write(verinfo) +fp.close() +print_and_do("python C:\\Python26\\pyinstaller\\Build.py dgpe.spec") +os.remove('verinfo_tmp') + +print_and_do("xcopy /Y C:\\src\\vs_comp\\msvcrt dist") +print_and_do("xcopy /Y /S /I help\\dupeguru_pe_help dist\\help") + +aicom = '"\\Program Files\\Caphyon\\Advanced Installer\\AdvancedInstaller.com"' +shutil.copy('installer.aip', 'installer_tmp.aip') # this is so we don'a have to re-commit installer.aip at every version change +print_and_do('%s /edit installer_tmp.aip /SetVersion %s' % (aicom, version)) +print_and_do('%s /build installer_tmp.aip -force' % aicom) +os.remove('installer_tmp.aip') \ No newline at end of file diff --git a/pe/qt/details_dialog.py b/pe/qt/details_dialog.py new file mode 100644 index 00000000..0c7503a6 --- /dev/null +++ b/pe/qt/details_dialog.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# Unit Name: details_dialog +# Created By: Virgil Dupras +# Created On: 2009-04-27 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import Qt, SIGNAL, QAbstractTableModel, QVariant +from PyQt4.QtGui import QDialog, QHeaderView, QPixmap + +from base.details_table import DetailsModel +from details_dialog_ui import Ui_DetailsDialog + +class DetailsDialog(QDialog, Ui_DetailsDialog): + def __init__(self, parent, app): + QDialog.__init__(self, parent, Qt.Tool) + self.app = app + self.selectedPixmap = None + self.referencePixmap = None + self.setupUi(self) + self.model = DetailsModel(app) + self.tableView.setModel(self.model) + self.connect(app, SIGNAL('duplicateSelected()'), self.duplicateSelected) + + def _update(self): + dupe = self.app.selected_dupe + if dupe is None: + return + group = self.app.results.get_group_of_duplicate(dupe) + ref = group.ref + + self.selectedPixmap = QPixmap(unicode(dupe.path)) + if ref is dupe: + self.referencePixmap = self.selectedPixmap + else: + self.referencePixmap = QPixmap(unicode(ref.path)) + self._updateImages() + + def _updateImages(self): + if self.selectedPixmap is not None: + target_size = self.selectedImage.size() + scaledPixmap = self.selectedPixmap.scaled(target_size, Qt.KeepAspectRatio, Qt.SmoothTransformation) + self.selectedImage.setPixmap(scaledPixmap) + if self.referencePixmap is not None: + target_size = self.referenceImage.size() + scaledPixmap = self.referencePixmap.scaled(target_size, Qt.KeepAspectRatio, Qt.SmoothTransformation) + self.referenceImage.setPixmap(scaledPixmap) + + #--- Override + def resizeEvent(self, event): + self._updateImages() + + def show(self): + QDialog.show(self) + self._update() + + #--- Events + def duplicateSelected(self): + if self.isVisible(): + self._update() + diff --git a/pe/qt/details_dialog.ui b/pe/qt/details_dialog.ui new file mode 100644 index 00000000..cee1adb1 --- /dev/null +++ b/pe/qt/details_dialog.ui @@ -0,0 +1,113 @@ + + + DetailsDialog + + + + 0 + 0 + 502 + 295 + + + + + 250 + 250 + + + + Details + + + + 0 + + + 0 + + + + + 4 + + + + + + 0 + 0 + + + + + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + + + false + + + Qt::AlignCenter + + + + + + + + + + 0 + 0 + + + + + 0 + 188 + + + + + 16777215 + 188 + + + + true + + + QAbstractItemView::SelectRows + + + false + + + + + + + + DetailsTable + QTableView +
base.details_table
+
+
+ + +
diff --git a/pe/qt/dgpe.spec b/pe/qt/dgpe.spec new file mode 100644 index 00000000..06e92f4e --- /dev/null +++ b/pe/qt/dgpe.spec @@ -0,0 +1,19 @@ +# -*- mode: python -*- +a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), 'start.py'], + pathex=['C:\\src\\dupeguru\\pe\\qt']) +pyz = PYZ(a.pure) +exe = EXE(pyz, + a.scripts, + exclude_binaries=1, + name=os.path.join('build\\pyi.win32\\dupeGuru PE', 'dupeGuru PE.exe'), + debug=False, + strip=False, + upx=True, + console=False , icon='base\\images\\dgpe_logo.ico', version='verinfo_tmp') +coll = COLLECT( exe, + a.binaries, + a.zipfiles, + a.datas, + strip=False, + upx=True, + name=os.path.join('dist')) diff --git a/pe/qt/dupeguru/__init__.py b/pe/qt/dupeguru/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/pe/qt/dupeguru/__init__.py @@ -0,0 +1 @@ + diff --git a/pe/qt/dupeguru/app.py b/pe/qt/dupeguru/app.py new file mode 100644 index 00000000..0e03603d --- /dev/null +++ b/pe/qt/dupeguru/app.py @@ -0,0 +1,229 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.app +Created By: Virgil Dupras +Created On: 2006/11/11 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:02:48 +0200 (Thu, 28 May 2009) $ + $Revision: 4388 $ +Copyright 2006 Hardcoded Software (http://www.hardcoded.net) +""" +import os +import os.path as op +import logging + +from hsfs import IT_ATTRS, IT_EXTRA +from hsutil import job, io, files +from hsutil.path import Path +from hsutil.reg import RegistrableApplication, RegistrationRequired +from hsutil.misc import flatten, first +from hsutil.str import escape + +import directories +import results +import scanner + +JOB_SCAN = 'job_scan' +JOB_LOAD = 'job_load' +JOB_MOVE = 'job_move' +JOB_COPY = 'job_copy' +JOB_DELETE = 'job_delete' + +class NoScannableFileError(Exception): + pass + +class AllFilesAreRefError(Exception): + pass + +class DupeGuru(RegistrableApplication): + def __init__(self, data_module, appdata, appid): + RegistrableApplication.__init__(self, appid) + self.appdata = appdata + if not op.exists(self.appdata): + os.makedirs(self.appdata) + self.data = data_module + self.directories = directories.Directories() + self.results = results.Results(data_module) + self.scanner = scanner.Scanner() + self.action_count = 0 + self.last_op_error_count = 0 + self.options = { + 'escape_filter_regexp': True, + 'clean_empty_dirs': False, + } + + 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): + def op(dupe): + j.add_progress() + return self._do_delete_dupe(dupe) + + j.start_job(self.results.mark_count) + self.last_op_error_count = self.results.perform_on_marked(op, True) + + def _do_delete_dupe(self, dupe): + if not io.exists(dupe.path): + dupe.parent = None + return True + self._recycle_dupe(dupe) + self.clean_empty_dirs(dupe.path[:-1]) + if not io.exists(dupe.path): + dupe.parent = None + return True + logging.warning(u"Could not send {0} to trash.".format(unicode(dupe.path))) + return False + + def _do_load(self, j): + self.directories.LoadFromFile(op.join(self.appdata, 'last_directories.xml')) + j = j.start_subjob([1, 9]) + self.results.load_from_xml(op.join(self.appdata, 'last_results.xml'), self._get_file, j) + files = flatten(g[:] for g in self.results.groups) + for file in j.iter_with_progress(files, 'Reading metadata %d/%d'): + file._read_all_info(sections=[IT_ATTRS, IT_EXTRA]) + + def _get_file(self, str_path): + p = Path(str_path) + for d in self.directories: + if p not in d.path: + continue + result = d.find_path(p[d.path:]) + if result is not None: + return result + + @staticmethod + def _recycle_dupe(dupe): + raise NotImplementedError() + + def _start_job(self, jobid, func): + # func(j) + raise NotImplementedError() + + def AddDirectory(self, d): + try: + self.directories.add_path(Path(d)) + return 0 + except directories.AlreadyThereError: + return 1 + except directories.InvalidPathError: + return 2 + + def AddToIgnoreList(self, dupe): + g = self.results.get_group_of_duplicate(dupe) + for other in g: + if other is not dupe: + self.scanner.ignore_list.Ignore(unicode(other.path), unicode(dupe.path)) + + def ApplyFilter(self, filter): + self.results.apply_filter(None) + if self.options['escape_filter_regexp']: + filter = escape(filter, '()[]\\.|+?^') + filter = escape(filter, '*', '.') + self.results.apply_filter(filter) + + def clean_empty_dirs(self, path): + if self.options['clean_empty_dirs']: + while files.delete_if_empty(path, ['.DS_Store']): + path = path[:-1] + + def CopyOrMove(self, dupe, copy, destination, dest_type): + """ + copy: True = Copy False = Move + destination: string. + dest_type: 0 = right in destination. + 1 = relative re-creation. + 2 = absolute re-creation. + """ + source_path = dupe.path + location_path = dupe.root.path + dest_path = Path(destination) + if dest_type == 2: + dest_path = dest_path + source_path[1:-1] #Remove drive letter and filename + elif dest_type == 1: + dest_path = dest_path + source_path[location_path:-1] + if not io.exists(dest_path): + io.makedirs(dest_path) + try: + if copy: + files.copy(source_path, dest_path) + else: + files.move(source_path, dest_path) + self.clean_empty_dirs(source_path[:-1]) + except (IOError, OSError) as e: + operation = 'Copy' if copy else 'Move' + logging.warning('%s operation failed on %s. Error: %s' % (operation, unicode(dupe.path), unicode(e))) + return False + return True + + def copy_or_move_marked(self, copy, destination, recreate_path): + def do(j): + def op(dupe): + j.add_progress() + return self.CopyOrMove(dupe, copy, destination, recreate_path) + + j.start_job(self.results.mark_count) + self.last_op_error_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): + self._demo_check() + self._start_job(JOB_DELETE, self._do_delete) + + def load(self): + self._start_job(JOB_LOAD, self._do_load) + self.LoadIgnoreList() + + def LoadIgnoreList(self): + p = op.join(self.appdata, 'ignore_list.xml') + self.scanner.ignore_list.load_from_xml(p) + + def make_reference(self, duplicates): + changed_groups = set() + for dupe in duplicates: + g = self.results.get_group_of_duplicate(dupe) + if g not in changed_groups: + self.results.make_ref(dupe) + changed_groups.add(g) + + def Save(self): + self.directories.SaveToFile(op.join(self.appdata, 'last_directories.xml')) + self.results.save_to_xml(op.join(self.appdata, 'last_results.xml')) + + def SaveIgnoreList(self): + p = op.join(self.appdata, 'ignore_list.xml') + self.scanner.ignore_list.save_to_xml(p) + + def start_scanning(self): + def do(j): + j.set_progress(0, 'Collecting files to scan') + files = list(self.directories.get_files()) + logging.info('Scanning %d files' % len(files)) + self.results.groups = self.scanner.GetDupeGroups(files, j) + + files = self.directories.get_files() + first_file = first(files) + if first_file is None: + raise NoScannableFileError() + if first_file.is_ref and all(f.is_ref for f in files): + raise AllFilesAreRefError() + self.results.groups = [] + self._start_job(JOB_SCAN, do) + + #--- Properties + @property + def stat_line(self): + result = self.results.stat_line + if self.scanner.discarded_file_count: + result = '%s (%d discarded)' % (result, self.scanner.discarded_file_count) + return result + diff --git a/pe/qt/dupeguru/app_cocoa.py b/pe/qt/dupeguru/app_cocoa.py new file mode 100644 index 00000000..4974d700 --- /dev/null +++ b/pe/qt/dupeguru/app_cocoa.py @@ -0,0 +1,304 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.app_cocoa +Created By: Virgil Dupras +Created On: 2006/11/11 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:33:32 +0200 (Thu, 28 May 2009) $ + $Revision: 4392 $ +Copyright 2006 Hardcoded Software (http://www.hardcoded.net) +""" +from AppKit import * +import logging +import os.path as op + +import hsfs as fs +from hsfs.phys.bundle import Bundle +from hsutil.cocoa import install_exception_hook +from hsutil.str import get_file_ext +from hsutil import io, cocoa, job +from hsutil.reg import RegistrationRequired + +import export, app, data + +JOBID2TITLE = { + app.JOB_SCAN: "Scanning for duplicates", + app.JOB_LOAD: "Loading", + app.JOB_MOVE: "Moving", + app.JOB_COPY: "Copying", + app.JOB_DELETE: "Sending to Trash", +} + +class DGDirectory(fs.phys.Directory): + def _create_sub_dir(self,name,with_parent = True): + ext = get_file_ext(name) + if ext == 'app': + if with_parent: + parent = self + else: + parent = None + return Bundle(parent,name) + else: + return super(DGDirectory,self)._create_sub_dir(name,with_parent) + + +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): + 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() + if data_module is None: + data_module = data + appdata = op.expanduser(op.join('~', '.hsoftdata', appdata_subdir)) + app.DupeGuru.__init__(self, data_module, appdata, appid) + self.progress = cocoa.ThreadedJobPerformer() + self.directories.dirclass = DGDirectory + self.display_delta_values = False + self.selected_dupes = [] + self.RefreshDetailsTable(None,None) + + #--- Override + @staticmethod + def _recycle_dupe(dupe): + if not io.exists(dupe.path): + dupe.parent = None + return True + directory = unicode(dupe.parent.path) + filename = dupe.name + result, tag = NSWorkspace.sharedWorkspace().performFileOperation_source_destination_files_tag_( + NSWorkspaceRecycleOperation, directory, '', [filename]) + if not io.exists(dupe.path): + dupe.parent = None + return True + logging.warning('Could not send %s to trash. tag: %d' % (unicode(dupe.path), tag)) + return False + + def _start_job(self, jobid, func): + try: + j = self.progress.create_job() + self.progress.run_threaded(func, args=(j, )) + except job.JobInProgressError: + NSNotificationCenter.defaultCenter().postNotificationName_object_('JobInProgress', self) + else: + ud = {'desc': JOBID2TITLE[jobid], 'jobid':jobid} + 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) + + def GetDirectory(self,node_path,curr_dir=None): + if not node_path: + return curr_dir + if curr_dir is not None: + l = curr_dir.dirs + else: + l = self.directories + d = l[node_path[0]] + return self.GetDirectory(node_path[1:],d) + + def RefreshDetailsTable(self,dupe,group): + l1 = self.data.GetDisplayInfo(dupe,group,False) + if group is not None: + l2 = self.data.GetDisplayInfo(group.ref,group,False) + else: + l2 = l1 #To have a list of empty '---' values + names = [c['display'] for c in self.data.COLUMNS] + self.details_table = zip(names,l1,l2) + + #---Public + def AddSelectedToIgnoreList(self): + for dupe in self.selected_dupes: + self.AddToIgnoreList(dupe) + + copy_or_move_marked = demo_method(app.DupeGuru.copy_or_move_marked) + delete_marked = demo_method(app.DupeGuru.delete_marked) + + def ExportToXHTML(self,column_ids,xslt_path,css_path): + columns = [] + for index,column in enumerate(self.data.COLUMNS): + display = column['display'] + enabled = str(index) in column_ids + columns.append((display,enabled)) + xml_path = op.join(self.appdata,'results_export.xml') + self.results.save_to_xml(xml_path,self.data.GetDisplayInfo) + return export.export_to_xhtml(xml_path,xslt_path,css_path,columns) + + def MakeSelectedReference(self): + self.make_reference(self.selected_dupes) + + def OpenSelected(self): + if self.selected_dupes: + path = unicode(self.selected_dupes[0].path) + NSWorkspace.sharedWorkspace().openFile_(path) + + def PurgeIgnoreList(self): + self.scanner.ignore_list.Filter(lambda f,s:op.exists(f) and op.exists(s)) + + def RefreshDetailsWithSelected(self): + if self.selected_dupes: + self.RefreshDetailsTable( + self.selected_dupes[0], + self.results.get_group_of_duplicate(self.selected_dupes[0]) + ) + else: + self.RefreshDetailsTable(None,None) + + def RemoveDirectory(self,index): + try: + del self.directories[index] + except IndexError: + pass + + def RemoveSelected(self): + self.results.remove_duplicates(self.selected_dupes) + + def RenameSelected(self,newname): + try: + d = self.selected_dupes[0] + d = d.move(d.parent,newname) + return True + except (IndexError,fs.FSError),e: + logging.warning("dupeGuru Warning: %s" % str(e)) + return False + + def RevealSelected(self): + if self.selected_dupes: + path = unicode(self.selected_dupes[0].path) + NSWorkspace.sharedWorkspace().selectFile_inFileViewerRootedAtPath_(path,'') + + def start_scanning(self): + self.RefreshDetailsTable(None, None) + try: + app.DupeGuru.start_scanning(self) + return 0 + except app.NoScannableFileError: + return 3 + except app.AllFilesAreRefError: + return 1 + + 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.selected_dupes = [dupe for dupe in selected if dupe is not None] + + def SelectPowerMarkerNodePaths(self,node_paths): + rows = [p[0] for p in node_paths] + self.selected_dupes = [ + self.results.dupes[row] for row in rows if row in xrange(len(self.results.dupes)) + ] + + def SetDirectoryState(self,node_path,state): + d = self.GetDirectory(node_path) + self.directories.SetState(d.path,state) + + def sort_dupes(self,key,asc): + self.results.sort_dupes(key,asc,self.display_delta_values) + + def sort_groups(self,key,asc): + self.results.sort_groups(key,asc) + + def ToggleSelectedMarkState(self): + for dupe in self.selected_dupes: + self.results.mark_toggle(dupe) + + #---Data + def GetOutlineViewMaxLevel(self, tag): + if tag == 0: + return 2 + elif tag == 1: + return 0 + elif tag == 2: + return 1 + + def GetOutlineViewChildCounts(self, tag, node_path): + if self.progress._job_running: + return [] + if tag == 0: #Normal results + assert not node_path # no other value is possible + return [len(g.dupes) for g in self.results.groups] + elif tag == 1: #Directories + dirs = self.GetDirectory(node_path).dirs if node_path else self.directories + return [d.dircount for d in dirs] + else: #Power Marker + assert not node_path # no other value is possible + return [0 for d in self.results.dupes] + + def GetOutlineViewValues(self, tag, node_path): + if self.progress._job_running: + return + if not node_path: + return + if tag in (0,2): #Normal results / Power Marker + if tag == 0: + g, d = self.GetObjects(node_path) + if d is None: + d = g.ref + else: + d = self.results.dupes[node_path[0]] + g = self.results.get_group_of_duplicate(d) + result = self.data.GetDisplayInfo(d, g, self.display_delta_values) + return result + elif tag == 1: #Directories + d = self.GetDirectory(node_path) + return [ + d.name, + self.directories.GetState(d.path) + ] + + def GetOutlineViewMarked(self, tag, node_path): + # 0=unmarked 1=marked 2=unmarkable + if self.progress._job_running: + return + if not node_path: + return 2 + if tag == 1: #Directories + return 2 + if tag == 0: #Normal results + g, d = self.GetObjects(node_path) + else: #Power Marker + d = self.results.dupes[node_path[0]] + if (d is None) or (not self.results.is_markable(d)): + return 2 + elif self.results.is_marked(d): + return 1 + else: + return 0 + + def GetTableViewCount(self, tag): + if self.progress._job_running: + return 0 + return len(self.details_table) + + def GetTableViewMarkedIndexes(self,tag): + return [] + + def GetTableViewValues(self,tag,row): + return self.details_table[row] + + diff --git a/pe/qt/dupeguru/app_cocoa_test.py b/pe/qt/dupeguru/app_cocoa_test.py new file mode 100644 index 00000000..ad8b937a --- /dev/null +++ b/pe/qt/dupeguru/app_cocoa_test.py @@ -0,0 +1,320 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.tests.app_cocoa +Created By: Virgil Dupras +Created On: 2006/11/11 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-29 17:51:41 +0200 (Fri, 29 May 2009) $ + $Revision: 4409 $ +Copyright 2006 Hardcoded Software (http://www.hardcoded.net) +""" +import tempfile +import shutil +import logging + +from hsutil.path import Path +from hsutil.testcase import TestCase +from hsutil.decorators import log_calls +import hsfs.phys +import os.path as op + +from . import engine, data +try: + from .app_cocoa import DupeGuru as DupeGuruBase, DGDirectory +except ImportError: + from nose.plugins.skip import SkipTest + raise SkipTest("These tests can only be run on OS X") +from .results_test import GetTestGroups + +class DupeGuru(DupeGuruBase): + def __init__(self): + DupeGuruBase.__init__(self, data, '/tmp', appid=4) + + def _start_job(self, jobid, func): + func(nulljob) + + +def r2np(rows): + #Transforms a list of rows [1,2,3] into a list of node paths [[1],[2],[3]] + return [[i] for i in rows] + +class TCDupeGuru(TestCase): + def setUp(self): + self.app = DupeGuru() + self.objects,self.matches,self.groups = GetTestGroups() + self.app.results.groups = self.groups + + def test_GetObjects(self): + app = self.app + objects = self.objects + groups = self.groups + g,d = app.GetObjects([0]) + self.assert_(g is groups[0]) + self.assert_(d is None) + g,d = app.GetObjects([0,0]) + self.assert_(g is groups[0]) + self.assert_(d is objects[1]) + g,d = app.GetObjects([1,0]) + self.assert_(g is groups[1]) + self.assert_(d is objects[4]) + + def test_GetObjects_after_sort(self): + app = self.app + objects = self.objects + groups = self.groups[:] #To keep the old order in memory + app.sort_groups(0,False) #0 = Filename + #Now, the group order is supposed to be reversed + g,d = app.GetObjects([0,0]) + self.assert_(g is groups[1]) + 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_selectResultNodePaths(self): + app = self.app + objects = self.objects + app.SelectResultNodePaths([[0,0],[0,1]]) + self.assertEqual(2,len(app.selected_dupes)) + self.assert_(app.selected_dupes[0] is objects[1]) + self.assert_(app.selected_dupes[1] is objects[2]) + + def test_selectResultNodePaths_with_ref(self): + app = self.app + objects = self.objects + app.SelectResultNodePaths([[0,0],[0,1],[1]]) + self.assertEqual(3,len(app.selected_dupes)) + self.assert_(app.selected_dupes[0] is objects[1]) + self.assert_(app.selected_dupes[1] is objects[2]) + self.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): + app = self.app + objects = self.objects + groups = self.groups[:] #To keep the old order in memory + app.sort_groups(0,False) #0 = Filename + #Now, the group order is supposed to be reversed + app.SelectResultNodePaths([[0,0],[1],[1,0]]) + self.assertEqual(3,len(app.selected_dupes)) + self.assert_(app.selected_dupes[0] is objects[4]) + self.assert_(app.selected_dupes[1] is groups[0].ref) + self.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_selectPowerMarkerRows(self): + app = self.app + objects = self.objects + app.SelectPowerMarkerNodePaths(r2np([0,1,2])) + self.assertEqual(3,len(app.selected_dupes)) + self.assert_(app.selected_dupes[0] is objects[1]) + self.assert_(app.selected_dupes[1] is objects[2]) + self.assert_(app.selected_dupes[2] is objects[4]) + + def test_selectPowerMarkerRows_empty(self): + self.app.SelectPowerMarkerNodePaths([]) + self.assertEqual(0,len(self.app.selected_dupes)) + + def test_selectPowerMarkerRows_after_sort(self): + app = self.app + objects = self.objects + app.sort_dupes(0,False) #0 = Filename + app.SelectPowerMarkerNodePaths(r2np([0,1,2])) + self.assertEqual(3,len(app.selected_dupes)) + self.assert_(app.selected_dupes[0] is objects[4]) + self.assert_(app.selected_dupes[1] is objects[2]) + self.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): + app = self.app + objects = self.objects + app.ToggleSelectedMarkState() + self.assertEqual(0,app.results.mark_count) + app.SelectPowerMarkerNodePaths(r2np([0,2])) + app.ToggleSelectedMarkState() + self.assertEqual(2,app.results.mark_count) + self.assert_(not app.results.is_marked(objects[0])) + self.assert_(app.results.is_marked(objects[1])) + self.assert_(not app.results.is_marked(objects[2])) + self.assert_(not app.results.is_marked(objects[3])) + self.assert_(app.results.is_marked(objects[4])) + + def test_refreshDetailsWithSelected(self): + def mock_refresh(dupe,group): + self.called = True + if self.app.selected_dupes: + self.assert_(dupe is self.app.selected_dupes[0]) + self.assert_(group is self.app.results.get_group_of_duplicate(dupe)) + else: + self.assert_(dupe is None) + self.assert_(group is None) + + self.app.RefreshDetailsTable = mock_refresh + self.called = False + self.app.SelectPowerMarkerNodePaths(r2np([0,2])) + self.app.RefreshDetailsWithSelected() + self.assert_(self.called) + self.called = False + self.app.SelectPowerMarkerNodePaths([]) + self.app.RefreshDetailsWithSelected() + self.assert_(self.called) + + def test_makeSelectedReference(self): + app = self.app + objects = self.objects + groups = self.groups + app.SelectPowerMarkerNodePaths(r2np([0,2])) + app.MakeSelectedReference() + self.assert_(groups[0].ref is objects[1]) + self.assert_(groups[1].ref is objects[4]) + + def test_makeSelectedReference_by_selecting_two_dupes_in_the_same_group(self): + app = self.app + objects = self.objects + groups = self.groups + app.SelectPowerMarkerNodePaths(r2np([0,1,2])) + #Only 0 and 2 must go ref, not 1 because it is a part of the same group + app.MakeSelectedReference() + self.assert_(groups[0].ref is objects[1]) + self.assert_(groups[1].ref is objects[4]) + + def test_removeSelected(self): + app = self.app + app.SelectPowerMarkerNodePaths(r2np([0,2])) + app.RemoveSelected() + self.assertEqual(1,len(app.results.dupes)) + app.RemoveSelected() + self.assertEqual(1,len(app.results.dupes)) + app.SelectPowerMarkerNodePaths(r2np([0,2])) + app.RemoveSelected() + self.assertEqual(0,len(app.results.dupes)) + + def test_addDirectory_simple(self): + app = self.app + self.assertEqual(0,app.AddDirectory(self.datadirpath())) + self.assertEqual(1,len(app.directories)) + + def test_addDirectory_already_there(self): + app = self.app + self.assertEqual(0,app.AddDirectory(self.datadirpath())) + self.assertEqual(1,app.AddDirectory(self.datadirpath())) + + def test_addDirectory_does_not_exist(self): + app = self.app + self.assertEqual(2,app.AddDirectory('/does_not_exist')) + + def test_ignore(self): + app = self.app + app.SelectPowerMarkerNodePaths(r2np([2])) #The dupe of the second, 2 sized group + app.AddSelectedToIgnoreList() + self.assertEqual(1,len(app.scanner.ignore_list)) + app.SelectPowerMarkerNodePaths(r2np([0])) #first dupe of the 3 dupes group + app.AddSelectedToIgnoreList() + #BOTH the ref and the other dupe should have been added + self.assertEqual(3,len(app.scanner.ignore_list)) + + def test_purgeIgnoreList(self): + app = self.app + p1 = self.filepath('zerofile') + p2 = self.filepath('zerofill') + dne = '/does_not_exist' + app.scanner.ignore_list.Ignore(dne,p1) + app.scanner.ignore_list.Ignore(p2,dne) + app.scanner.ignore_list.Ignore(p1,p2) + app.PurgeIgnoreList() + self.assertEqual(1,len(app.scanner.ignore_list)) + self.assert_(app.scanner.ignore_list.AreIgnored(p1,p2)) + self.assert_(not app.scanner.ignore_list.AreIgnored(dne,p1)) + + def test_only_unicode_is_added_to_ignore_list(self): + def FakeIgnore(first,second): + if not isinstance(first,unicode): + self.fail() + if not isinstance(second,unicode): + self.fail() + + app = self.app + app.scanner.ignore_list.Ignore = FakeIgnore + app.SelectPowerMarkerNodePaths(r2np([2])) #The dupe of the second, 2 sized group + app.AddSelectedToIgnoreList() + + def test_dirclass(self): + self.assert_(self.app.directories.dirclass is DGDirectory) + + +class TCDupeGuru_renameSelected(TestCase): + def setUp(self): + p = Path(tempfile.mkdtemp()) + fp = open(str(p + 'foo bar 1'),mode='w') + fp.close() + fp = open(str(p + 'foo bar 2'),mode='w') + fp.close() + fp = open(str(p + 'foo bar 3'),mode='w') + fp.close() + refdir = hsfs.phys.Directory(None,str(p)) + matches = engine.MatchFactory().getmatches(refdir.files) + groups = engine.get_groups(matches) + g = groups[0] + g.prioritize(lambda x:x.name) + app = DupeGuru() + app.results.groups = groups + self.app = app + self.groups = groups + self.p = p + self.refdir = refdir + + def tearDown(self): + shutil.rmtree(str(self.p)) + + def test_simple(self): + app = self.app + refdir = self.refdir + g = self.groups[0] + app.SelectPowerMarkerNodePaths(r2np([0])) + self.assert_(app.RenameSelected('renamed')) + self.assert_('renamed' in refdir) + self.assert_('foo bar 2' not in refdir) + self.assert_(g.dupes[0] is refdir['renamed']) + self.assert_(g.dupes[0] in refdir) + + def test_none_selected(self): + app = self.app + refdir = self.refdir + g = self.groups[0] + app.SelectPowerMarkerNodePaths([]) + self.mock(logging, 'warning', log_calls(lambda msg: None)) + self.assert_(not app.RenameSelected('renamed')) + msg = logging.warning.calls[0]['msg'] + self.assertEqual('dupeGuru Warning: list index out of range', msg) + self.assert_('renamed' not in refdir) + self.assert_('foo bar 2' in refdir) + self.assert_(g.dupes[0] is refdir['foo bar 2']) + + def test_name_already_exists(self): + app = self.app + refdir = self.refdir + g = self.groups[0] + app.SelectPowerMarkerNodePaths(r2np([0])) + self.mock(logging, 'warning', log_calls(lambda msg: None)) + self.assert_(not app.RenameSelected('foo bar 1')) + msg = logging.warning.calls[0]['msg'] + self.assert_(msg.startswith('dupeGuru Warning: \'foo bar 2\' already exists in')) + self.assert_('foo bar 1' in refdir) + self.assert_('foo bar 2' in refdir) + self.assert_(g.dupes[0] is refdir['foo bar 2']) + diff --git a/pe/qt/dupeguru/app_me_cocoa.py b/pe/qt/dupeguru/app_me_cocoa.py new file mode 100644 index 00000000..51a61767 --- /dev/null +++ b/pe/qt/dupeguru/app_me_cocoa.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.app_me_cocoa +Created By: Virgil Dupras +Created On: 2006/11/16 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:33:32 +0200 (Thu, 28 May 2009) $ + $Revision: 4392 $ +Copyright 2006 Hardcoded Software (http://www.hardcoded.net) +""" +import os.path as op +import logging +from appscript import app, k, CommandError +import time + +from hsutil.cocoa import as_fetch +import hsfs.phys.music + +import app_cocoa, data_me, scanner + +JOB_REMOVE_DEAD_TRACKS = 'jobRemoveDeadTracks' +JOB_SCAN_DEAD_TRACKS = 'jobScanDeadTracks' + +app_cocoa.JOBID2TITLE.update({ + JOB_REMOVE_DEAD_TRACKS: "Removing dead tracks from your iTunes Library", + JOB_SCAN_DEAD_TRACKS: "Scanning the iTunes Library", +}) + +class DupeGuruME(app_cocoa.DupeGuru): + def __init__(self): + app_cocoa.DupeGuru.__init__(self, data_me, 'dupeguru_me', appid=1) + self.scanner = scanner.ScannerME() + self.directories.dirclass = hsfs.phys.music.Directory + self.dead_tracks = [] + + def remove_dead_tracks(self): + def do(j): + a = app('iTunes') + for index, track in enumerate(j.iter_with_progress(self.dead_tracks)): + if index % 100 == 0: + time.sleep(.1) + try: + track.delete() + except CommandError as e: + logging.warning('Error while trying to remove a track from iTunes: %s' % unicode(e)) + + self._start_job(JOB_REMOVE_DEAD_TRACKS, do) + + def scan_dead_tracks(self): + def do(j): + a = app('iTunes') + try: + [source] = [s for s in a.sources() if s.kind() == k.library] + [library] = source.library_playlists() + except ValueError: + logging.warning('Some unexpected iTunes configuration encountered') + return + self.dead_tracks = [] + tracks = as_fetch(library.file_tracks, k.file_track) + for index, track in enumerate(j.iter_with_progress(tracks)): + if index % 100 == 0: + time.sleep(.1) + if track.location() == k.missing_value: + self.dead_tracks.append(track) + logging.info('Found %d dead tracks' % len(self.dead_tracks)) + + self._start_job(JOB_SCAN_DEAD_TRACKS, do) + diff --git a/pe/qt/dupeguru/app_pe_cocoa.py b/pe/qt/dupeguru/app_pe_cocoa.py new file mode 100644 index 00000000..5969d1c3 --- /dev/null +++ b/pe/qt/dupeguru/app_pe_cocoa.py @@ -0,0 +1,212 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.app_pe_cocoa +Created By: Virgil Dupras +Created On: 2006/11/13 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:33:32 +0200 (Thu, 28 May 2009) $ + $Revision: 4392 $ +Copyright 2006 Hardcoded Software (http://www.hardcoded.net) +""" +import os +import os.path as op +import logging +import plistlib + +import objc +from Foundation import * +from AppKit import * +from appscript import app, k + +from hsutil import job, io +import hsfs as fs +from hsfs import phys +from hsutil import files +from hsutil.str import get_file_ext +from hsutil.path import Path +from hsutil.cocoa import as_fetch + +import app_cocoa, data_pe, directories, picture.matchbase +from picture.cache import string_to_colors, Cache + +mainBundle = NSBundle.mainBundle() +PictureBlocks = mainBundle.classNamed_('PictureBlocks') +assert PictureBlocks is not None + +class Photo(phys.File): + cls_info_map = { + 'size': fs.IT_ATTRS, + 'ctime': fs.IT_ATTRS, + 'mtime': fs.IT_ATTRS, + 'md5': fs.IT_MD5, + 'md5partial': fs.IT_MD5, + 'dimensions': fs.IT_EXTRA, + } + + def _initialize_info(self,section): + super(Photo, self)._initialize_info(section) + if section == fs.IT_EXTRA: + self._info.update({ + 'dimensions': (0,0), + }) + + def _read_info(self,section): + super(Photo, self)._read_info(section) + if section == fs.IT_EXTRA: + size = PictureBlocks.getImageSize_(unicode(self.path)) + self._info['dimensions'] = (size.width, size.height) + + def get_blocks(self, block_count_per_side): + try: + blocks = PictureBlocks.getBlocksFromImagePath_blockCount_scanArea_(unicode(self.path), block_count_per_side, 0) + except Exception, e: + raise IOError('The reading of "%s" failed with "%s"' % (unicode(self.path), unicode(e))) + if not blocks: + raise IOError('The picture %s could not be read' % unicode(self.path)) + return string_to_colors(blocks) + + +class IPhoto(Photo): + def __init__(self, parent, whole_path): + super(IPhoto, self).__init__(parent, whole_path[-1]) + self.whole_path = whole_path + + def _build_path(self): + return self.whole_path + + @property + def display_path(self): + return super(IPhoto, self)._build_path() + + +class Directory(phys.Directory): + cls_file_class = Photo + cls_supported_exts = ('png', 'jpg', 'jpeg', 'gif', 'psd', 'bmp', 'tiff', 'nef', 'cr2') + + def _fetch_subitems(self): + subdirs, subfiles = super(Directory,self)._fetch_subitems() + return subdirs, [name for name in subfiles if get_file_ext(name) in self.cls_supported_exts] + + +class IPhotoLibrary(fs.Directory): + def __init__(self, plistpath): + self.plistpath = plistpath + self.refpath = plistpath[:-1] + # the AlbumData.xml file lives right in the library path + super(IPhotoLibrary, self).__init__(None, 'iPhoto Library') + + def _update_photo(self, photo_data): + if photo_data['MediaType'] != 'Image': + return + photo_path = Path(photo_data['ImagePath']) + subpath = photo_path[len(self.refpath):-1] + subdir = self + for element in subpath: + try: + subdir = subdir[element] + except KeyError: + subdir = fs.Directory(subdir, element) + IPhoto(subdir, photo_path) + + def update(self): + self.clear() + s = open(unicode(self.plistpath)).read() + # There was a case where a guy had 0x10 chars in his plist, causing expat errors on loading + s = s.replace('\x10', '') + plist = plistlib.readPlistFromString(s) + for photo_data in plist['Master Image List'].values(): + self._update_photo(photo_data) + + def force_update(self): # Don't update + pass + + +class DupeGuruPE(app_cocoa.DupeGuru): + def __init__(self): + app_cocoa.DupeGuru.__init__(self, data_pe, 'dupeguru_pe', appid=5) + self.scanner.match_factory = picture.matchbase.AsyncMatchFactory() + self.directories.dirclass = Directory + self.directories.special_dirclasses[Path('iPhoto Library')] = lambda _, __: self._create_iphoto_library() + p = op.join(self.appdata, 'cached_pictures.db') + self.scanner.match_factory.cached_blocks = Cache(p) + + def _create_iphoto_library(self): + ud = NSUserDefaults.standardUserDefaults() + prefs = ud.persistentDomainForName_('com.apple.iApps') + plisturl = NSURL.URLWithString_(prefs['iPhotoRecentDatabases'][0]) + plistpath = Path(plisturl.path()) + return IPhotoLibrary(plistpath) + + def _do_delete(self, j): + def op(dupe): + j.add_progress() + return self._do_delete_dupe(dupe) + + marked = [dupe for dupe in self.results.dupes if self.results.is_marked(dupe)] + self.path2iphoto = {} + if any(isinstance(dupe, IPhoto) for dupe in marked): + a = app('iPhoto') + a.select(a.photo_library_album()) + photos = as_fetch(a.photo_library_album().photos, k.item) + for photo in photos: + self.path2iphoto[photo.image_path()] = photo + self.last_op_error_count = self.results.perform_on_marked(op, True) + del self.path2iphoto + + def _do_delete_dupe(self, dupe): + if isinstance(dupe, IPhoto): + photo = self.path2iphoto[unicode(dupe.path)] + app('iPhoto').remove(photo) + return True + else: + return app_cocoa.DupeGuru._do_delete_dupe(self, dupe) + + def _do_load(self, j): + self.directories.LoadFromFile(op.join(self.appdata, 'last_directories.xml')) + for d in self.directories: + if isinstance(d, IPhotoLibrary): + d.update() + self.results.load_from_xml(op.join(self.appdata, 'last_results.xml'), self._get_file, j) + + def _get_file(self, str_path): + p = Path(str_path) + for d in self.directories: + result = None + if p in d.path: + result = d.find_path(p[d.path:]) + if isinstance(d, IPhotoLibrary) and p in d.refpath: + result = d.find_path(p[d.refpath:]) + if result is not None: + return result + + def AddDirectory(self, d): + try: + added = self.directories.add_path(Path(d)) + if d == 'iPhoto Library': + added.update() + return 0 + except directories.AlreadyThereError: + return 1 + + def CopyOrMove(self, dupe, copy, destination, dest_type): + if isinstance(dupe, IPhoto): + copy = True + return app_cocoa.DupeGuru.CopyOrMove(self, dupe, copy, destination, dest_type) + + def start_scanning(self): + for directory in self.directories: + if isinstance(directory, IPhotoLibrary): + self.directories.SetState(directory.refpath, directories.STATE_EXCLUDED) + return app_cocoa.DupeGuru.start_scanning(self) + + def selected_dupe_path(self): + if not self.selected_dupes: + return None + return self.selected_dupes[0].path + + def selected_dupe_ref_path(self): + if not self.selected_dupes: + return None + ref = self.results.get_group_of_duplicate(self.selected_dupes[0]).ref + return ref.path + diff --git a/pe/qt/dupeguru/app_se_cocoa.py b/pe/qt/dupeguru/app_se_cocoa.py new file mode 100644 index 00000000..3d8c62b2 --- /dev/null +++ b/pe/qt/dupeguru/app_se_cocoa.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +# Unit Name: app_se_cocoa +# Created By: Virgil Dupras +# Created On: 2009-05-24 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import app_cocoa, data + +class DupeGuru(app_cocoa.DupeGuru): + def __init__(self): + app_cocoa.DupeGuru.__init__(self, data, 'dupeguru', appid=4) + diff --git a/pe/qt/dupeguru/app_test.py b/pe/qt/dupeguru/app_test.py new file mode 100644 index 00000000..af47067f --- /dev/null +++ b/pe/qt/dupeguru/app_test.py @@ -0,0 +1,137 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.tests.app +Created By: Virgil Dupras +Created On: 2007-06-23 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:02:48 +0200 (Thu, 28 May 2009) $ + $Revision: 4388 $ +Copyright 2007 Hardcoded Software (http://www.hardcoded.net) +""" +import unittest +import os + +from hsutil.testcase import TestCase +from hsutil import io +from hsutil.path import Path +from hsutil.decorators import log_calls +import hsfs as fs +import hsfs.phys +import hsutil.files +from hsutil.job import nulljob + +from . import data, app +from .app import DupeGuru as DupeGuruBase + +class DupeGuru(DupeGuruBase): + def __init__(self): + DupeGuruBase.__init__(self, data, '/tmp', appid=4) + + def _start_job(self, jobid, func): + func(nulljob) + + +class TCDupeGuru(TestCase): + cls_tested_module = app + def test_ApplyFilter_calls_results_apply_filter(self): + app = DupeGuru() + self.mock(app.results, 'apply_filter', log_calls(app.results.apply_filter)) + app.ApplyFilter('foo') + self.assertEqual(2, len(app.results.apply_filter.calls)) + call = app.results.apply_filter.calls[0] + self.assert_(call['filter_str'] is None) + call = app.results.apply_filter.calls[1] + self.assertEqual('foo', call['filter_str']) + + def test_ApplyFilter_escapes_regexp(self): + app = DupeGuru() + self.mock(app.results, 'apply_filter', log_calls(app.results.apply_filter)) + app.ApplyFilter('()[]\\.|+?^abc') + call = app.results.apply_filter.calls[1] + self.assertEqual('\\(\\)\\[\\]\\\\\\.\\|\\+\\?\\^abc', call['filter_str']) + app.ApplyFilter('(*)') # In "simple mode", we want the * to behave as a wilcard + call = app.results.apply_filter.calls[3] + self.assertEqual('\(.*\)', call['filter_str']) + app.options['escape_filter_regexp'] = False + app.ApplyFilter('(abc)') + call = app.results.apply_filter.calls[5] + self.assertEqual('(abc)', call['filter_str']) + + def test_CopyOrMove(self): + # The goal here is just to have a test for a previous blowup I had. I know my test coverage + # for this unit is pathetic. What's done is done. My approach now is to add tests for + # every change I want to make. The blowup was caused by a missing import. + dupe_parent = fs.Directory(None, 'foo') + dupe = fs.File(dupe_parent, 'bar') + dupe.copy = log_calls(lambda dest, newname: None) + self.mock(hsutil.files, 'copy', log_calls(lambda source_path, dest_path: None)) + self.mock(os, 'makedirs', lambda path: None) # We don't want the test to create that fake directory + self.mock(fs.phys, 'Directory', fs.Directory) # We don't want an error because makedirs didn't work + app = DupeGuru() + app.CopyOrMove(dupe, True, 'some_destination', 0) + self.assertEqual(1, len(hsutil.files.copy.calls)) + call = hsutil.files.copy.calls[0] + self.assertEqual('some_destination', call['dest_path']) + self.assertEqual(dupe.path, call['source_path']) + + def test_CopyOrMove_clean_empty_dirs(self): + tmppath = Path(self.tmpdir()) + sourcepath = tmppath + 'source' + io.mkdir(sourcepath) + io.open(sourcepath + 'myfile', 'w') + tmpdir = hsfs.phys.Directory(None, unicode(tmppath)) + myfile = tmpdir['source']['myfile'] + app = DupeGuru() + self.mock(app, 'clean_empty_dirs', log_calls(lambda path: None)) + app.CopyOrMove(myfile, False, tmppath + 'dest', 0) + calls = app.clean_empty_dirs.calls + self.assertEqual(1, len(calls)) + self.assertEqual(sourcepath, calls[0]['path']) + + def test_Scan_with_objects_evaluating_to_false(self): + # At some point, any() was used in a wrong way that made Scan() wrongly return 1 + app = DupeGuru() + f1, f2 = [fs.File(None, 'foo') for i in range(2)] + f1.is_ref, f2.is_ref = (False, False) + assert not (bool(f1) and bool(f2)) + app.directories.get_files = lambda: [f1, f2] + app.directories._dirs.append('this is just so Scan() doesnt return 3') + app.start_scanning() # no exception + + +class TCDupeGuru_clean_empty_dirs(TestCase): + cls_tested_module = app + def setUp(self): + self.mock(hsutil.files, 'delete_if_empty', log_calls(lambda path, files_to_delete=[]: None)) + self.app = DupeGuru() + + def test_option_off(self): + self.app.clean_empty_dirs(Path('/foo/bar')) + self.assertEqual(0, len(hsutil.files.delete_if_empty.calls)) + + def test_option_on(self): + self.app.options['clean_empty_dirs'] = True + self.app.clean_empty_dirs(Path('/foo/bar')) + calls = hsutil.files.delete_if_empty.calls + self.assertEqual(1, len(calls)) + self.assertEqual(Path('/foo/bar'), calls[0]['path']) + self.assertEqual(['.DS_Store'], calls[0]['files_to_delete']) + + def test_recurse_up(self): + # delete_if_empty must be recursively called up in the path until it returns False + @log_calls + def mock_delete_if_empty(path, files_to_delete=[]): + return len(path) > 1 + + self.mock(hsutil.files, 'delete_if_empty', mock_delete_if_empty) + self.app.options['clean_empty_dirs'] = True + self.app.clean_empty_dirs(Path('not-empty/empty/empty')) + calls = hsutil.files.delete_if_empty.calls + self.assertEqual(3, len(calls)) + self.assertEqual(Path('not-empty/empty/empty'), calls[0]['path']) + self.assertEqual(Path('not-empty/empty'), calls[1]['path']) + self.assertEqual(Path('not-empty'), calls[2]['path']) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/pe/qt/dupeguru/data.py b/pe/qt/dupeguru/data.py new file mode 100644 index 00000000..568a3400 --- /dev/null +++ b/pe/qt/dupeguru/data.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.data +Created By: Virgil Dupras +Created On: 2006/03/15 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" + +from hsutil.str import format_time, FT_DECIMAL, format_size + +import time + +def format_path(p): + return unicode(p[:-1]) + +def format_timestamp(t, delta): + if delta: + return format_time(t, FT_DECIMAL) + else: + if t > 0: + return time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(t)) + else: + return '---' + +def format_words(w): + def do_format(w): + if isinstance(w, list): + return '(%s)' % ', '.join(do_format(item) for item in w) + else: + return w.replace('\n', ' ') + + return ', '.join(do_format(item) for item in w) + +def format_perc(p): + return "%0.0f" % p + +def format_dupe_count(c): + return str(c) if c else '---' + +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'}, +] + +def GetDisplayInfo(dupe, group, delta=False): + if (dupe is None) or (group is None): + return ['---'] * len(COLUMNS) + 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), + 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/pe/qt/dupeguru/data_me.py b/pe/qt/dupeguru/data_me.py new file mode 100644 index 00000000..70d3ae66 --- /dev/null +++ b/pe/qt/dupeguru/data_me.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.data +Created By: Virgil Dupras +Created On: 2006/03/15 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" + +from hsutil.str import format_time, FT_MINUTES, format_size +from .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 (MB)'}, + {'attr':'duration','display':'Time'}, + {'attr':'bitrate','display':'Bitrate'}, + {'attr':'samplerate','display':'Sample Rate'}, + {'attr':'extension','display':'Kind'}, + {'attr':'ctime','display':'Creation'}, + {'attr':'mtime','display':'Modification'}, + {'attr':'title','display':'Title'}, + {'attr':'artist','display':'Artist'}, + {'attr':'album','display':'Album'}, + {'attr':'genre','display':'Genre'}, + {'attr':'year','display':'Year'}, + {'attr':'track','display':'Track Number'}, + {'attr':'comment','display':'Comment'}, + {'attr':'percentage','display':'Match %'}, + {'attr':'words','display':'Words Used'}, + {'attr':'dupe_count','display':'Dupe Count'}, +] + +def GetDisplayInfo(dupe, group, delta=False): + if (dupe is None) or (group is None): + return ['---'] * len(COLUMNS) + size = dupe.size + duration = dupe.duration + bitrate = dupe.bitrate + samplerate = dupe.samplerate + 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 + duration -= r.duration + bitrate -= r.bitrate + samplerate -= r.samplerate + 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, 2, 2, False), + format_time(duration, FT_MINUTES), + str(bitrate), + str(samplerate), + dupe.extension, + format_timestamp(ctime,delta and m), + format_timestamp(mtime,delta and m), + dupe.title, + dupe.artist, + dupe.album, + dupe.genre, + dupe.year, + str(dupe.track), + dupe.comment, + format_perc(percentage), + format_words(dupe.words), + format_dupe_count(dupe_count) + ] + +def GetDupeSortKey(dupe, get_group, key, delta): + if key == 16: + m = get_group().get_match_of(dupe) + return m.percentage + if key == 18: + return 0 + r = cmp_value(getattr(dupe, COLUMNS[key]['attr'])) + if delta and (key in (2, 3, 4, 7, 8)): + r -= cmp_value(getattr(get_group().ref, COLUMNS[key]['attr'])) + return r + +def GetGroupSortKey(group, key): + if key == 16: + return group.percentage + if key == 18: + return len(group) + return cmp_value(getattr(group.ref, COLUMNS[key]['attr'])) diff --git a/pe/qt/dupeguru/data_pe.py b/pe/qt/dupeguru/data_pe.py new file mode 100644 index 00000000..94bdd99d --- /dev/null +++ b/pe/qt/dupeguru/data_pe.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.data +Created By: Virgil Dupras +Created On: 2006/03/15 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +from hsutil.str import format_size +from .data import format_path, format_timestamp, format_perc, format_dupe_count, cmp_value + +def format_dimensions(dimensions): + return '%d x %d' % (dimensions[0], dimensions[1]) + +COLUMNS = [ + {'attr':'name','display':'Filename'}, + {'attr':'path','display':'Directory'}, + {'attr':'size','display':'Size (KB)'}, + {'attr':'extension','display':'Kind'}, + {'attr':'dimensions','display':'Dimensions'}, + {'attr':'ctime','display':'Creation'}, + {'attr':'mtime','display':'Modification'}, + {'attr':'percentage','display':'Match %'}, + {'attr':'dupe_count','display':'Dupe Count'}, +] + +def GetDisplayInfo(dupe,group,delta=False): + if (dupe is None) or (group is None): + return ['---'] * len(COLUMNS) + 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) + dupe_path = getattr(dupe, 'display_path', dupe.path) + return [ + dupe.name, + format_path(dupe_path), + format_size(size, 0, 1, False), + dupe.extension, + format_dimensions(dupe.dimensions), + format_timestamp(ctime, delta and m), + format_timestamp(mtime, delta and m), + format_perc(percentage), + format_dupe_count(dupe_count) + ] + +def GetDupeSortKey(dupe, get_group, key, delta): + if key == 7: + 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, 5, 6)): + r -= cmp_value(getattr(get_group().ref, COLUMNS[key]['attr'])) + return r + +def GetGroupSortKey(group, key): + if key == 7: + return group.percentage + if key == 8: + return len(group) + return cmp_value(getattr(group.ref, COLUMNS[key]['attr'])) + diff --git a/pe/qt/dupeguru/directories.py b/pe/qt/dupeguru/directories.py new file mode 100644 index 00000000..3d73b5c5 --- /dev/null +++ b/pe/qt/dupeguru/directories.py @@ -0,0 +1,161 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.directories +Created By: Virgil Dupras +Created On: 2006/02/27 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:02:48 +0200 (Thu, 28 May 2009) $ + $Revision: 4388 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import xml.dom.minidom + +from hsfs import phys +import hsfs as fs +from hsutil.files import FileOrPath +from hsutil.path import Path + +(STATE_NORMAL, +STATE_REFERENCE, +STATE_EXCLUDED) = range(3) + +class AlreadyThereError(Exception): + """The path being added is already in the directory list""" + +class InvalidPathError(Exception): + """The path being added is invalid""" + +class Directories(object): + #---Override + def __init__(self): + self._dirs = [] + self.states = {} + self.dirclass = phys.Directory + self.special_dirclasses = {} + + def __contains__(self,path): + for d in self._dirs: + if path in d.path: + return True + return False + + def __delitem__(self,key): + self._dirs.__delitem__(key) + + def __getitem__(self,key): + return self._dirs.__getitem__(key) + + def __len__(self): + return len(self._dirs) + + #---Private + def _get_files(self, from_dir, state=STATE_NORMAL): + state = self.states.get(from_dir.path, state) + result = [] + for subdir in from_dir.dirs: + for file in self._get_files(subdir, state): + yield file + if state != STATE_EXCLUDED: + for file in from_dir.files: + file.is_ref = state == STATE_REFERENCE + yield file + + #---Public + def add_path(self, path): + """Adds 'path' to self, if not already there. + + Raises AlreadyThereError if 'path' is already in self. If path is a directory containing + some of the directories already present in self, 'path' will be added, but all directories + under it will be removed. Can also raise InvalidPathError if 'path' does not exist. + """ + if path in self: + raise AlreadyThereError + self._dirs = [d for d in self._dirs if d.path not in path] + try: + dirclass = self.special_dirclasses.get(path, self.dirclass) + d = dirclass(None, unicode(path)) + d[:] #If an InvalidPath exception has to be raised, it will be raised here + self._dirs.append(d) + return d + except fs.InvalidPath: + raise InvalidPathError + + def get_files(self): + """Returns a list of all files that are not excluded. + + Returned files also have their 'is_ref' attr set. + """ + for d in self._dirs: + d.force_update() + try: + for file in self._get_files(d): + yield file + except fs.InvalidPath: + pass + + def GetState(self, path): + """Returns the state of 'path' (One of the STATE_* const.) + + Raises LookupError if 'path' is not in self. + """ + if path not in self: + raise LookupError("The path '%s' is not in the directory list." % str(path)) + try: + return self.states[path] + except KeyError: + if path[-1].startswith('.'): # hidden + return STATE_EXCLUDED + parent = path[:-1] + if parent in self: + return self.GetState(parent) + else: + return STATE_NORMAL + + def LoadFromFile(self,infile): + try: + doc = xml.dom.minidom.parse(infile) + except: + return + root_dir_nodes = doc.getElementsByTagName('root_directory') + for rdn in root_dir_nodes: + if not rdn.getAttributeNode('path'): + continue + path = rdn.getAttributeNode('path').nodeValue + try: + self.add_path(Path(path)) + except (AlreadyThereError,InvalidPathError): + pass + state_nodes = doc.getElementsByTagName('state') + for sn in state_nodes: + if not (sn.getAttributeNode('path') and sn.getAttributeNode('value')): + continue + path = sn.getAttributeNode('path').nodeValue + state = sn.getAttributeNode('value').nodeValue + self.SetState(Path(path), int(state)) + + def Remove(self,directory): + self._dirs.remove(directory) + + def SaveToFile(self,outfile): + with FileOrPath(outfile, 'wb') as fp: + doc = xml.dom.minidom.Document() + root = doc.appendChild(doc.createElement('directories')) + for root_dir in self: + root_dir_node = root.appendChild(doc.createElement('root_directory')) + root_dir_node.setAttribute('path', unicode(root_dir.path).encode('utf-8')) + for path,state in self.states.iteritems(): + state_node = root.appendChild(doc.createElement('state')) + state_node.setAttribute('path', unicode(path).encode('utf-8')) + state_node.setAttribute('value', str(state)) + doc.writexml(fp,'\t','\t','\n',encoding='utf-8') + + def SetState(self,path,state): + try: + if self.GetState(path) == state: + return + self.states[path] = state + if (self.GetState(path[:-1]) == state) and (not path[-1].startswith('.')): + del self.states[path] + except LookupError: + pass + diff --git a/pe/qt/dupeguru/directories_test.py b/pe/qt/dupeguru/directories_test.py new file mode 100644 index 00000000..7d34c343 --- /dev/null +++ b/pe/qt/dupeguru/directories_test.py @@ -0,0 +1,280 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.tests.directories +Created By: Virgil Dupras +Created On: 2006/02/27 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-29 08:51:14 +0200 (Fri, 29 May 2009) $ + $Revision: 4398 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import unittest +import os.path as op +import os +import time +import shutil + +from hsutil import job, io +from hsutil.path import Path +from hsutil.testcase import TestCase +import hsfs.phys +from hsfs.phys import phys_test + +from directories import * + +testpath = Path(TestCase.datadirpath()) + +class TCDirectories(TestCase): + def test_empty(self): + d = Directories() + self.assertEqual(0,len(d)) + self.assert_('foobar' not in d) + + def test_add_path(self): + d = Directories() + p = testpath + 'utils' + added = d.add_path(p) + self.assertEqual(1,len(d)) + self.assert_(p in d) + self.assert_((p + 'foobar') in d) + self.assert_(p[:-1] not in d) + self.assertEqual(p,added.path) + self.assert_(d[0] is added) + p = self.tmppath() + d.add_path(p) + self.assertEqual(2,len(d)) + self.assert_(p in d) + + def test_AddPath_when_path_is_already_there(self): + d = Directories() + p = testpath + 'utils' + d.add_path(p) + self.assertRaises(AlreadyThereError, d.add_path, p) + self.assertRaises(AlreadyThereError, d.add_path, p + 'foobar') + self.assertEqual(1, len(d)) + + def test_AddPath_containing_paths_already_there(self): + d = Directories() + d.add_path(testpath + 'utils') + self.assertEqual(1, len(d)) + added = d.add_path(testpath) + self.assertEqual(1, len(d)) + self.assert_(added is d[0]) + + def test_AddPath_non_latin(self): + p = Path(self.tmpdir()) + to_add = p + u'unicode\u201a' + os.mkdir(unicode(to_add)) + d = Directories() + try: + d.add_path(to_add) + except UnicodeDecodeError: + self.fail() + + def test_del(self): + d = Directories() + d.add_path(testpath + 'utils') + try: + del d[1] + self.fail() + except IndexError: + pass + d.add_path(self.tmppath()) + del d[1] + self.assertEqual(1, len(d)) + + def test_states(self): + d = Directories() + p = testpath + 'utils' + d.add_path(p) + self.assertEqual(STATE_NORMAL,d.GetState(p)) + d.SetState(p,STATE_REFERENCE) + self.assertEqual(STATE_REFERENCE,d.GetState(p)) + self.assertEqual(STATE_REFERENCE,d.GetState(p + 'dir1')) + self.assertEqual(1,len(d.states)) + self.assertEqual(p,d.states.keys()[0]) + self.assertEqual(STATE_REFERENCE,d.states[p]) + + def test_GetState_with_path_not_there(self): + d = Directories() + d.add_path(testpath + 'utils') + self.assertRaises(LookupError,d.GetState,testpath) + + def test_states_remain_when_larger_directory_eat_smaller_ones(self): + d = Directories() + p = testpath + 'utils' + d.add_path(p) + d.SetState(p,STATE_EXCLUDED) + d.add_path(testpath) + d.SetState(testpath,STATE_REFERENCE) + self.assertEqual(STATE_EXCLUDED,d.GetState(p)) + self.assertEqual(STATE_EXCLUDED,d.GetState(p + 'dir1')) + self.assertEqual(STATE_REFERENCE,d.GetState(testpath)) + + def test_SetState_keep_state_dict_size_to_minimum(self): + d = Directories() + p = Path(phys_test.create_fake_fs(self.tmpdir())) + d.add_path(p) + d.SetState(p,STATE_REFERENCE) + d.SetState(p + 'dir1',STATE_REFERENCE) + self.assertEqual(1,len(d.states)) + self.assertEqual(STATE_REFERENCE,d.GetState(p + 'dir1')) + d.SetState(p + 'dir1',STATE_NORMAL) + self.assertEqual(2,len(d.states)) + self.assertEqual(STATE_NORMAL,d.GetState(p + 'dir1')) + d.SetState(p + 'dir1',STATE_REFERENCE) + self.assertEqual(1,len(d.states)) + self.assertEqual(STATE_REFERENCE,d.GetState(p + 'dir1')) + + def test_get_files(self): + d = Directories() + p = Path(phys_test.create_fake_fs(self.tmpdir())) + d.add_path(p) + d.SetState(p + 'dir1',STATE_REFERENCE) + d.SetState(p + 'dir2',STATE_EXCLUDED) + files = d.get_files() + self.assertEqual(5, len(list(files))) + for f in files: + if f.parent.path == p + 'dir1': + self.assert_(f.is_ref) + else: + self.assert_(not f.is_ref) + + def test_get_files_with_inherited_exclusion(self): + d = Directories() + p = testpath + 'utils' + d.add_path(p) + d.SetState(p,STATE_EXCLUDED) + self.assertEqual([], list(d.get_files())) + + def test_save_and_load(self): + d1 = Directories() + d2 = Directories() + p1 = self.tmppath() + p2 = self.tmppath() + d1.add_path(p1) + d1.add_path(p2) + d1.SetState(p1, STATE_REFERENCE) + d1.SetState(p1 + 'dir1',STATE_EXCLUDED) + tmpxml = op.join(self.tmpdir(), 'directories_testunit.xml') + d1.SaveToFile(tmpxml) + d2.LoadFromFile(tmpxml) + self.assertEqual(2, len(d2)) + self.assertEqual(STATE_REFERENCE,d2.GetState(p1)) + self.assertEqual(STATE_EXCLUDED,d2.GetState(p1 + 'dir1')) + + def test_invalid_path(self): + d = Directories() + p = Path('does_not_exist') + self.assertRaises(InvalidPathError, d.add_path, p) + self.assertEqual(0, len(d)) + + def test_SetState_on_invalid_path(self): + d = Directories() + try: + d.SetState(Path('foobar',),STATE_NORMAL) + except LookupError: + self.fail() + + def test_default_dirclass(self): + self.assert_(Directories().dirclass is hsfs.phys.Directory) + + def test_dirclass(self): + class MySpecialDirclass(hsfs.phys.Directory): pass + d = Directories() + d.dirclass = MySpecialDirclass + d.add_path(testpath) + self.assert_(isinstance(d[0], MySpecialDirclass)) + + def test_LoadFromFile_with_invalid_path(self): + #This test simulates a load from file resulting in a + #InvalidPath raise. Other directories must be loaded. + d1 = Directories() + d1.add_path(testpath + 'utils') + #Will raise InvalidPath upon loading + d1.add_path(self.tmppath()).name = 'does_not_exist' + tmpxml = op.join(self.tmpdir(), 'directories_testunit.xml') + d1.SaveToFile(tmpxml) + d2 = Directories() + d2.LoadFromFile(tmpxml) + self.assertEqual(1, len(d2)) + + def test_LoadFromFile_with_same_paths(self): + #This test simulates a load from file resulting in a + #AlreadyExists raise. Other directories must be loaded. + d1 = Directories() + p1 = self.tmppath() + p2 = self.tmppath() + d1.add_path(p1) + d1.add_path(p2) + #Will raise AlreadyExists upon loading + d1.add_path(self.tmppath()).name = unicode(p1) + tmpxml = op.join(self.tmpdir(), 'directories_testunit.xml') + d1.SaveToFile(tmpxml) + d2 = Directories() + d2.LoadFromFile(tmpxml) + self.assertEqual(2, len(d2)) + + def test_Remove(self): + d = Directories() + d1 = d.add_path(self.tmppath()) + d2 = d.add_path(self.tmppath()) + d.Remove(d1) + self.assertEqual(1, len(d)) + self.assert_(d[0] is d2) + + def test_unicode_save(self): + d = Directories() + p1 = self.tmppath() + u'hello\xe9' + io.mkdir(p1) + io.mkdir(p1 + u'foo\xe9') + d.add_path(p1) + d.SetState(d[0][0].path, STATE_EXCLUDED) + tmpxml = op.join(self.tmpdir(), 'directories_testunit.xml') + try: + d.SaveToFile(tmpxml) + except UnicodeDecodeError: + self.fail() + + def test_get_files_refreshes_its_directories(self): + d = Directories() + p = Path(phys_test.create_fake_fs(self.tmpdir())) + d.add_path(p) + files = d.get_files() + self.assertEqual(6, len(list(files))) + time.sleep(1) + os.remove(str(p + ('dir1','file1.test'))) + files = d.get_files() + self.assertEqual(5, len(list(files))) + + def test_get_files_does_not_choke_on_non_existing_directories(self): + d = Directories() + p = Path(self.tmpdir()) + d.add_path(p) + io.rmtree(p) + self.assertEqual([], list(d.get_files())) + + def test_GetState_returns_excluded_by_default_for_hidden_directories(self): + d = Directories() + p = Path(self.tmpdir()) + hidden_dir_path = p + '.foo' + io.mkdir(p + '.foo') + d.add_path(p) + self.assertEqual(d.GetState(hidden_dir_path), STATE_EXCLUDED) + # But it can be overriden + d.SetState(hidden_dir_path, STATE_NORMAL) + self.assertEqual(d.GetState(hidden_dir_path), STATE_NORMAL) + + def test_special_dirclasses(self): + # if a path is in special_dirclasses, use this class instead + class MySpecialDirclass(hsfs.phys.Directory): pass + d = Directories() + p1 = self.tmppath() + p2 = self.tmppath() + d.special_dirclasses[p1] = MySpecialDirclass + self.assert_(isinstance(d.add_path(p2), hsfs.phys.Directory)) + self.assert_(isinstance(d.add_path(p1), MySpecialDirclass)) + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/pe/qt/dupeguru/engine.py b/pe/qt/dupeguru/engine.py new file mode 100644 index 00000000..a826902d --- /dev/null +++ b/pe/qt/dupeguru/engine.py @@ -0,0 +1,360 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.engine +Created By: Virgil Dupras +Created On: 2006/01/29 +Last modified by:$Author: virgil $ +Last modified on:$Date: $ + $Revision: $ +Copyright 2007 Hardcoded Software (http://www.hardcoded.net) +""" +from __future__ import division +import difflib +import logging +import string +from collections import defaultdict, namedtuple +from unicodedata import normalize + +from hsutil.str import multi_replace +from hsutil import job + +(WEIGHT_WORDS, +MATCH_SIMILAR_WORDS, +NO_FIELD_ORDER) = range(3) + +JOB_REFRESH_RATE = 100 + +def getwords(s): + if isinstance(s, unicode): + s = normalize('NFD', s) + s = multi_replace(s, "-_&+():;\\[]{}.,<>/?~!@#$*", ' ').lower() + s = ''.join(c for c in s if c in string.ascii_letters + string.digits + string.whitespace) + return filter(None, s.split(' ')) # filter() is to remove empty elements + +def getfields(s): + fields = [getwords(field) for field in s.split(' - ')] + return filter(None, fields) + +def unpack_fields(fields): + result = [] + for field in fields: + if isinstance(field, list): + result += field + else: + result.append(field) + return result + +def compare(first, second, flags=()): + """Returns the % of words that match between first and second + + The result is a int in the range 0..100. + First and second can be either a string or a list. + """ + if not (first and second): + return 0 + if any(isinstance(element, list) for element in first): + return compare_fields(first, second, flags) + second = second[:] #We must use a copy of second because we remove items from it + match_similar = MATCH_SIMILAR_WORDS in flags + weight_words = WEIGHT_WORDS in flags + joined = first + second + total_count = (sum(len(word) for word in joined) if weight_words else len(joined)) + match_count = 0 + in_order = True + for word in first: + if match_similar and (word not in second): + similar = difflib.get_close_matches(word, second, 1, 0.8) + if similar: + word = similar[0] + if word in second: + if second[0] != word: + in_order = False + second.remove(word) + match_count += (len(word) if weight_words else 1) + result = round(((match_count * 2) / total_count) * 100) + if (result == 100) and (not in_order): + result = 99 # We cannot consider a match exact unless the ordering is the same + return result + +def compare_fields(first, second, flags=()): + """Returns the score for the lowest matching fields. + + first and second must be lists of lists of string. + """ + if len(first) != len(second): + return 0 + if NO_FIELD_ORDER in flags: + results = [] + #We don't want to remove field directly in the list. We must work on a copy. + second = second[:] + for field1 in first: + max = 0 + matched_field = None + for field2 in second: + r = compare(field1, field2, flags) + if r > max: + max = r + matched_field = field2 + results.append(max) + if matched_field: + second.remove(matched_field) + else: + results = [compare(word1, word2, flags) for word1, word2 in zip(first, second)] + return min(results) if results else 0 + +def build_word_dict(objects, j=job.nulljob): + """Returns a dict of objects mapped by their words. + + objects must have a 'words' attribute being a list of strings or a list of lists of strings. + + The result will be a dict with words as keys, lists of objects as values. + """ + result = defaultdict(set) + for object in j.iter_with_progress(objects, 'Prepared %d/%d files', JOB_REFRESH_RATE): + for word in unpack_fields(object.words): + result[word].add(object) + return result + +def merge_similar_words(word_dict): + """Take all keys in word_dict that are similar, and merge them together. + """ + keys = word_dict.keys() + keys.sort(key=len)# we want the shortest word to stay + while keys: + key = keys.pop(0) + similars = difflib.get_close_matches(key, keys, 100, 0.8) + if not similars: + continue + objects = word_dict[key] + for similar in similars: + objects |= word_dict[similar] + del word_dict[similar] + keys.remove(similar) + +def reduce_common_words(word_dict, threshold): + """Remove all objects from word_dict values where the object count >= threshold + + The exception to this removal are the objects where all the words of the object are common. + Because if we remove them, we will miss some duplicates! + """ + uncommon_words = set(word for word, objects in word_dict.items() if len(objects) < threshold) + for word, objects in word_dict.items(): + if len(objects) < threshold: + continue + reduced = set() + for o in objects: + if not any(w in uncommon_words for w in unpack_fields(o.words)): + reduced.add(o) + if reduced: + word_dict[word] = reduced + else: + del word_dict[word] + +Match = namedtuple('Match', 'first second percentage') +def get_match(first, second, flags=()): + #it is assumed here that first and second both have a "words" attribute + percentage = compare(first.words, second.words, flags) + return Match(first, second, percentage) + +class MatchFactory(object): + common_word_threshold = 50 + match_similar_words = False + min_match_percentage = 0 + weight_words = False + no_field_order = False + limit = 5000000 + + def getmatches(self, objects, j=job.nulljob): + j = j.start_subjob(2) + sj = j.start_subjob(2) + for o in objects: + if not hasattr(o, 'words'): + o.words = getwords(o.name) + word_dict = build_word_dict(objects, sj) + reduce_common_words(word_dict, self.common_word_threshold) + if self.match_similar_words: + merge_similar_words(word_dict) + match_flags = [] + if self.weight_words: + match_flags.append(WEIGHT_WORDS) + if self.match_similar_words: + match_flags.append(MATCH_SIMILAR_WORDS) + if self.no_field_order: + match_flags.append(NO_FIELD_ORDER) + j.start_job(len(word_dict), '0 matches found') + compared = defaultdict(set) + result = [] + try: + # This whole 'popping' thing is there to avoid taking too much memory at the same time. + while word_dict: + items = word_dict.popitem()[1] + while items: + ref = items.pop() + compared_already = compared[ref] + to_compare = items - compared_already + compared_already |= to_compare + for other in to_compare: + m = get_match(ref, other, match_flags) + if m.percentage >= self.min_match_percentage: + result.append(m) + if len(result) >= self.limit: + return result + j.add_progress(desc='%d matches found' % len(result)) + except MemoryError: + # This is the place where the memory usage is at its peak during the scan. + # Just continue the process with an incomplete list of matches. + del compared # This should give us enough room to call logging. + logging.warning('Memory Overflow. Matches: %d. Word dict: %d' % (len(result), len(word_dict))) + return result + return result + + +class Group(object): + #---Override + def __init__(self): + self._clear() + + def __contains__(self, item): + return item in self.unordered + + def __getitem__(self, key): + return self.ordered.__getitem__(key) + + def __iter__(self): + return iter(self.ordered) + + def __len__(self): + return len(self.ordered) + + #---Private + def _clear(self): + self._percentage = None + self._matches_for_ref = None + self.matches = set() + self.candidates = defaultdict(set) + self.ordered = [] + self.unordered = set() + + def _get_matches_for_ref(self): + if self._matches_for_ref is None: + ref = self.ref + self._matches_for_ref = [match for match in self.matches if ref in match] + return self._matches_for_ref + + #---Public + def add_match(self, match): + def add_candidate(item, match): + matches = self.candidates[item] + matches.add(match) + if self.unordered <= matches: + self.ordered.append(item) + self.unordered.add(item) + + if match in self.matches: + return + self.matches.add(match) + first, second, _ = match + if first not in self.unordered: + add_candidate(first, second) + if second not in self.unordered: + add_candidate(second, first) + self._percentage = None + self._matches_for_ref = None + + def clean_matches(self): + self.matches = set(m for m in self.matches if (m.first in self.unordered) and (m.second in self.unordered)) + self.candidates = defaultdict(set) + + def get_match_of(self, item): + if item is self.ref: + return + for m in self._get_matches_for_ref(): + if item in m: + return m + + def prioritize(self, key_func, tie_breaker=None): + # tie_breaker(ref, dupe) --> True if dupe should be ref + self.ordered.sort(key=key_func) + if tie_breaker is None: + return + ref = self.ref + key_value = key_func(ref) + for dupe in self.dupes: + if key_func(dupe) != key_value: + break + if tie_breaker(ref, dupe): + ref = dupe + if ref is not self.ref: + self.switch_ref(ref) + + def remove_dupe(self, item, clean_matches=True): + try: + self.ordered.remove(item) + self.unordered.remove(item) + self._percentage = None + self._matches_for_ref = None + if (len(self) > 1) and any(not getattr(item, 'is_ref', False) for item in self): + if clean_matches: + self.matches = set(m for m in self.matches if item not in m) + else: + self._clear() + except ValueError: + pass + + def switch_ref(self, with_dupe): + try: + self.ordered.remove(with_dupe) + self.ordered.insert(0, with_dupe) + self._percentage = None + self._matches_for_ref = None + except ValueError: + pass + + dupes = property(lambda self: self[1:]) + + @property + def percentage(self): + if self._percentage is None: + if self.dupes: + matches = self._get_matches_for_ref() + self._percentage = sum(match.percentage for match in matches) // len(matches) + else: + self._percentage = 0 + return self._percentage + + @property + def ref(self): + if self: + return self[0] + + +def get_groups(matches, j=job.nulljob): + matches.sort(key=lambda match: -match.percentage) + dupe2group = {} + groups = [] + for match in j.iter_with_progress(matches, 'Grouped %d/%d matches', JOB_REFRESH_RATE): + first, second, _ = match + first_group = dupe2group.get(first) + second_group = dupe2group.get(second) + if first_group: + if second_group: + if first_group is second_group: + target_group = first_group + else: + continue + else: + target_group = first_group + dupe2group[second] = target_group + else: + if second_group: + target_group = second_group + dupe2group[first] = target_group + else: + target_group = Group() + groups.append(target_group) + dupe2group[first] = target_group + dupe2group[second] = target_group + target_group.add_match(match) + for group in groups: + group.clean_matches() + return groups diff --git a/pe/qt/dupeguru/engine_test.py b/pe/qt/dupeguru/engine_test.py new file mode 100644 index 00000000..8e9706d9 --- /dev/null +++ b/pe/qt/dupeguru/engine_test.py @@ -0,0 +1,822 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.engine_test +Created By: Virgil Dupras +Created On: 2006/01/29 +Last modified by:$Author: virgil $ +Last modified on:$Date: $ + $Revision: $ +Copyright 2004-2008 Hardcoded Software (http://www.hardcoded.net) +""" +import unittest +import sys + +from hsutil import job +from hsutil.decorators import log_calls +from hsutil.testcase import TestCase + +from . import engine +from .engine import * + +class NamedObject(object): + def __init__(self, name="foobar", with_words=False): + self.name = name + if with_words: + self.words = getwords(name) + + +def get_match_triangle(): + o1 = NamedObject(with_words=True) + o2 = NamedObject(with_words=True) + o3 = NamedObject(with_words=True) + m1 = get_match(o1,o2) + m2 = get_match(o1,o3) + m3 = get_match(o2,o3) + return [m1, m2, m3] + +def get_test_group(): + m1, m2, m3 = get_match_triangle() + result = Group() + result.add_match(m1) + result.add_match(m2) + result.add_match(m3) + return result + +class TCgetwords(TestCase): + def test_spaces(self): + self.assertEqual(['a', 'b', 'c', 'd'], getwords("a b c d")) + self.assertEqual(['a', 'b', 'c', 'd'], getwords(" a b c d ")) + + def test_splitter_chars(self): + self.assertEqual( + [chr(i) for i in xrange(ord('a'),ord('z')+1)], + getwords("a-b_c&d+e(f)g;h\\i[j]k{l}m:n.o,pr/s?t~u!v@w#x$y*z") + ) + + def test_joiner_chars(self): + self.assertEqual(["aec"], getwords(u"a'e\u0301c")) + + def test_empty(self): + self.assertEqual([], getwords('')) + + def test_returns_lowercase(self): + self.assertEqual(['foo', 'bar'], getwords('FOO BAR')) + + def test_decompose_unicode(self): + self.assertEqual(getwords(u'foo\xe9bar'), ['fooebar']) + + +class TCgetfields(TestCase): + def test_simple(self): + self.assertEqual([['a', 'b'], ['c', 'd', 'e']], getfields('a b - c d e')) + + def test_empty(self): + self.assertEqual([], getfields('')) + + def test_cleans_empty_fields(self): + expected = [['a', 'bc', 'def']] + actual = getfields(' - a bc def') + self.assertEqual(expected, actual) + expected = [['bc', 'def']] + + +class TCunpack_fields(TestCase): + def test_with_fields(self): + expected = ['a', 'b', 'c', 'd', 'e', 'f'] + actual = unpack_fields([['a'], ['b', 'c'], ['d', 'e', 'f']]) + self.assertEqual(expected, actual) + + def test_without_fields(self): + expected = ['a', 'b', 'c', 'd', 'e', 'f'] + actual = unpack_fields(['a', 'b', 'c', 'd', 'e', 'f']) + self.assertEqual(expected, actual) + + def test_empty(self): + self.assertEqual([], unpack_fields([])) + + +class TCWordCompare(TestCase): + def test_list(self): + self.assertEqual(100, compare(['a', 'b', 'c', 'd'],['a', 'b', 'c', 'd'])) + self.assertEqual(86, compare(['a', 'b', 'c', 'd'],['a', 'b', 'c'])) + + def test_unordered(self): + #Sometimes, users don't want fuzzy matching too much When they set the slider + #to 100, they don't expect a filename with the same words, but not the same order, to match. + #Thus, we want to return 99 in that case. + self.assertEqual(99, compare(['a', 'b', 'c', 'd'], ['d', 'b', 'c', 'a'])) + + def test_word_occurs_twice(self): + #if a word occurs twice in first, but once in second, we want the word to be only counted once + self.assertEqual(89, compare(['a', 'b', 'c', 'd', 'a'], ['d', 'b', 'c', 'a'])) + + def test_uses_copy_of_lists(self): + first = ['foo', 'bar'] + second = ['bar', 'bleh'] + compare(first, second) + self.assertEqual(['foo', 'bar'], first) + self.assertEqual(['bar', 'bleh'], second) + + def test_word_weight(self): + self.assertEqual(int((6.0 / 13.0) * 100), compare(['foo', 'bar'], ['bar', 'bleh'], (WEIGHT_WORDS, ))) + + def test_similar_words(self): + self.assertEqual(100, compare(['the', 'white', 'stripes'],['the', 'whites', 'stripe'], (MATCH_SIMILAR_WORDS, ))) + + def test_empty(self): + self.assertEqual(0, compare([], [])) + + def test_with_fields(self): + self.assertEqual(67, compare([['a', 'b'], ['c', 'd', 'e']], [['a', 'b'], ['c', 'd', 'f']])) + + def test_propagate_flags_with_fields(self): + def mock_compare(first, second, flags): + self.assertEqual((0, 1, 2, 3, 5), flags) + + self.mock(engine, 'compare_fields', mock_compare) + compare([['a']], [['a']], (0, 1, 2, 3, 5)) + + +class TCWordCompareWithFields(TestCase): + def test_simple(self): + self.assertEqual(67, compare_fields([['a', 'b'], ['c', 'd', 'e']], [['a', 'b'], ['c', 'd', 'f']])) + + def test_empty(self): + self.assertEqual(0, compare_fields([], [])) + + def test_different_length(self): + self.assertEqual(0, compare_fields([['a'], ['b']], [['a'], ['b'], ['c']])) + + def test_propagates_flags(self): + def mock_compare(first, second, flags): + self.assertEqual((0, 1, 2, 3, 5), flags) + + self.mock(engine, 'compare_fields', mock_compare) + compare_fields([['a']], [['a']],(0, 1, 2, 3, 5)) + + def test_order(self): + first = [['a', 'b'], ['c', 'd', 'e']] + second = [['c', 'd', 'f'], ['a', 'b']] + self.assertEqual(0, compare_fields(first, second)) + + def test_no_order(self): + first = [['a','b'],['c','d','e']] + second = [['c','d','f'],['a','b']] + self.assertEqual(67, compare_fields(first, second, (NO_FIELD_ORDER, ))) + first = [['a','b'],['a','b']] #a field can only be matched once. + second = [['c','d','f'],['a','b']] + self.assertEqual(0, compare_fields(first, second, (NO_FIELD_ORDER, ))) + first = [['a','b'],['a','b','c']] + second = [['c','d','f'],['a','b']] + self.assertEqual(33, compare_fields(first, second, (NO_FIELD_ORDER, ))) + + def test_compare_fields_without_order_doesnt_alter_fields(self): + #The NO_ORDER comp type altered the fields! + first = [['a','b'],['c','d','e']] + second = [['c','d','f'],['a','b']] + self.assertEqual(67, compare_fields(first, second, (NO_FIELD_ORDER, ))) + self.assertEqual([['a','b'],['c','d','e']],first) + self.assertEqual([['c','d','f'],['a','b']],second) + + +class TCbuild_word_dict(TestCase): + def test_with_standard_words(self): + l = [NamedObject('foo bar',True)] + l.append(NamedObject('bar baz',True)) + l.append(NamedObject('baz bleh foo',True)) + d = build_word_dict(l) + self.assertEqual(4,len(d)) + self.assertEqual(2,len(d['foo'])) + self.assert_(l[0] in d['foo']) + self.assert_(l[2] in d['foo']) + self.assertEqual(2,len(d['bar'])) + self.assert_(l[0] in d['bar']) + self.assert_(l[1] in d['bar']) + self.assertEqual(2,len(d['baz'])) + self.assert_(l[1] in d['baz']) + self.assert_(l[2] in d['baz']) + self.assertEqual(1,len(d['bleh'])) + self.assert_(l[2] in d['bleh']) + + def test_unpack_fields(self): + o = NamedObject('') + o.words = [['foo','bar'],['baz']] + d = build_word_dict([o]) + self.assertEqual(3,len(d)) + self.assertEqual(1,len(d['foo'])) + + def test_words_are_unaltered(self): + o = NamedObject('') + o.words = [['foo','bar'],['baz']] + d = build_word_dict([o]) + self.assertEqual([['foo','bar'],['baz']],o.words) + + def test_object_instances_can_only_be_once_in_words_object_list(self): + o = NamedObject('foo foo',True) + d = build_word_dict([o]) + self.assertEqual(1,len(d['foo'])) + + def test_job(self): + def do_progress(p,d=''): + self.log.append(p) + return True + + j = job.Job(1,do_progress) + self.log = [] + s = "foo bar" + build_word_dict([NamedObject(s, True), NamedObject(s, True), NamedObject(s, True)], j) + self.assertEqual(0,self.log[0]) + self.assertEqual(33,self.log[1]) + self.assertEqual(66,self.log[2]) + self.assertEqual(100,self.log[3]) + + +class TCmerge_similar_words(TestCase): + def test_some_similar_words(self): + d = { + 'foobar':set([1]), + 'foobar1':set([2]), + 'foobar2':set([3]), + } + merge_similar_words(d) + self.assertEqual(1,len(d)) + self.assertEqual(3,len(d['foobar'])) + + + +class TCreduce_common_words(TestCase): + def test_typical(self): + d = { + 'foo': set([NamedObject('foo bar',True) for i in range(50)]), + 'bar': set([NamedObject('foo bar',True) for i in range(49)]) + } + reduce_common_words(d, 50) + self.assert_('foo' not in d) + self.assertEqual(49,len(d['bar'])) + + def test_dont_remove_objects_with_only_common_words(self): + d = { + 'common': set([NamedObject("common uncommon",True) for i in range(50)] + [NamedObject("common",True)]), + 'uncommon': set([NamedObject("common uncommon",True)]) + } + reduce_common_words(d, 50) + self.assertEqual(1,len(d['common'])) + self.assertEqual(1,len(d['uncommon'])) + + def test_values_still_are_set_instances(self): + d = { + 'common': set([NamedObject("common uncommon",True) for i in range(50)] + [NamedObject("common",True)]), + 'uncommon': set([NamedObject("common uncommon",True)]) + } + reduce_common_words(d, 50) + self.assert_(isinstance(d['common'],set)) + self.assert_(isinstance(d['uncommon'],set)) + + def test_dont_raise_KeyError_when_a_word_has_been_removed(self): + #If a word has been removed by the reduce, an object in a subsequent common word that + #contains the word that has been removed would cause a KeyError. + d = { + 'foo': set([NamedObject('foo bar baz',True) for i in range(50)]), + 'bar': set([NamedObject('foo bar baz',True) for i in range(50)]), + 'baz': set([NamedObject('foo bar baz',True) for i in range(49)]) + } + try: + reduce_common_words(d, 50) + except KeyError: + self.fail() + + def test_unpack_fields(self): + #object.words may be fields. + def create_it(): + o = NamedObject('') + o.words = [['foo','bar'],['baz']] + return o + + d = { + 'foo': set([create_it() for i in range(50)]) + } + try: + reduce_common_words(d, 50) + except TypeError: + self.fail("must support fields.") + + def test_consider_a_reduced_common_word_common_even_after_reduction(self): + #There was a bug in the code that causeda word that has already been reduced not to + #be counted as a common word for subsequent words. For example, if 'foo' is processed + #as a common word, keeping a "foo bar" file in it, and the 'bar' is processed, "foo bar" + #would not stay in 'bar' because 'foo' is not a common word anymore. + only_common = NamedObject('foo bar',True) + d = { + 'foo': set([NamedObject('foo bar baz',True) for i in range(49)] + [only_common]), + 'bar': set([NamedObject('foo bar baz',True) for i in range(49)] + [only_common]), + 'baz': set([NamedObject('foo bar baz',True) for i in range(49)]) + } + reduce_common_words(d, 50) + self.assertEqual(1,len(d['foo'])) + self.assertEqual(1,len(d['bar'])) + self.assertEqual(49,len(d['baz'])) + + +class TCget_match(TestCase): + def test_simple(self): + o1 = NamedObject("foo bar",True) + o2 = NamedObject("bar bleh",True) + m = get_match(o1,o2) + self.assertEqual(50,m.percentage) + self.assertEqual(['foo','bar'],m.first.words) + self.assertEqual(['bar','bleh'],m.second.words) + self.assert_(m.first is o1) + self.assert_(m.second is o2) + + def test_in(self): + o1 = NamedObject("foo",True) + o2 = NamedObject("bar",True) + m = get_match(o1,o2) + self.assert_(o1 in m) + self.assert_(o2 in m) + self.assert_(object() not in m) + + def test_word_weight(self): + self.assertEqual(int((6.0 / 13.0) * 100),get_match(NamedObject("foo bar",True),NamedObject("bar bleh",True),(WEIGHT_WORDS,)).percentage) + + +class TCMatchFactory(TestCase): + def test_empty(self): + self.assertEqual([],MatchFactory().getmatches([])) + + def test_defaults(self): + mf = MatchFactory() + self.assertEqual(50,mf.common_word_threshold) + self.assertEqual(False,mf.weight_words) + self.assertEqual(False,mf.match_similar_words) + self.assertEqual(False,mf.no_field_order) + self.assertEqual(0,mf.min_match_percentage) + + def test_simple(self): + l = [NamedObject("foo bar"),NamedObject("bar bleh"),NamedObject("a b c foo")] + r = MatchFactory().getmatches(l) + self.assertEqual(2,len(r)) + seek = [m for m in r if m.percentage == 50] #"foo bar" and "bar bleh" + m = seek[0] + self.assertEqual(['foo','bar'],m.first.words) + self.assertEqual(['bar','bleh'],m.second.words) + seek = [m for m in r if m.percentage == 33] #"foo bar" and "a b c foo" + m = seek[0] + self.assertEqual(['foo','bar'],m.first.words) + self.assertEqual(['a','b','c','foo'],m.second.words) + + def test_null_and_unrelated_objects(self): + l = [NamedObject("foo bar"),NamedObject("bar bleh"),NamedObject(""),NamedObject("unrelated object")] + r = MatchFactory().getmatches(l) + self.assertEqual(1,len(r)) + m = r[0] + self.assertEqual(50,m.percentage) + self.assertEqual(['foo','bar'],m.first.words) + self.assertEqual(['bar','bleh'],m.second.words) + + def test_twice_the_same_word(self): + l = [NamedObject("foo foo bar"),NamedObject("bar bleh")] + r = MatchFactory().getmatches(l) + self.assertEqual(1,len(r)) + + def test_twice_the_same_word_when_preworded(self): + l = [NamedObject("foo foo bar",True),NamedObject("bar bleh",True)] + r = MatchFactory().getmatches(l) + self.assertEqual(1,len(r)) + + def test_two_words_match(self): + l = [NamedObject("foo bar"),NamedObject("foo bar bleh")] + r = MatchFactory().getmatches(l) + self.assertEqual(1,len(r)) + + def test_match_files_with_only_common_words(self): + #If a word occurs more than 50 times, it is excluded from the matching process + #The problem with the common_word_threshold is that the files containing only common + #words will never be matched together. We *should* match them. + mf = MatchFactory() + mf.common_word_threshold = 50 + l = [NamedObject("foo") for i in range(50)] + r = mf.getmatches(l) + self.assertEqual(1225,len(r)) + + def test_use_words_already_there_if_there(self): + o1 = NamedObject('foo') + o2 = NamedObject('bar') + o2.words = ['foo'] + self.assertEqual(1,len(MatchFactory().getmatches([o1,o2]))) + + def test_job(self): + def do_progress(p,d=''): + self.log.append(p) + return True + + j = job.Job(1,do_progress) + self.log = [] + s = "foo bar" + MatchFactory().getmatches([NamedObject(s),NamedObject(s),NamedObject(s)],j) + self.assert_(len(self.log) > 2) + self.assertEqual(0,self.log[0]) + self.assertEqual(100,self.log[-1]) + + def test_weight_words(self): + mf = MatchFactory() + mf.weight_words = True + l = [NamedObject("foo bar"),NamedObject("bar bleh")] + m = mf.getmatches(l)[0] + self.assertEqual(int((6.0 / 13.0) * 100),m.percentage) + + def test_similar_word(self): + mf = MatchFactory() + mf.match_similar_words = True + l = [NamedObject("foobar"),NamedObject("foobars")] + self.assertEqual(1,len(mf.getmatches(l))) + self.assertEqual(100,mf.getmatches(l)[0].percentage) + l = [NamedObject("foobar"),NamedObject("foo")] + self.assertEqual(0,len(mf.getmatches(l))) #too far + l = [NamedObject("bizkit"),NamedObject("bizket")] + self.assertEqual(1,len(mf.getmatches(l))) + l = [NamedObject("foobar"),NamedObject("foosbar")] + self.assertEqual(1,len(mf.getmatches(l))) + + def test_single_object_with_similar_words(self): + mf = MatchFactory() + mf.match_similar_words = True + l = [NamedObject("foo foos")] + self.assertEqual(0,len(mf.getmatches(l))) + + def test_double_words_get_counted_only_once(self): + mf = MatchFactory() + l = [NamedObject("foo bar foo bleh"),NamedObject("foo bar bleh bar")] + m = mf.getmatches(l)[0] + self.assertEqual(75,m.percentage) + + def test_with_fields(self): + mf = MatchFactory() + o1 = NamedObject("foo bar - foo bleh") + o2 = NamedObject("foo bar - bleh bar") + o1.words = getfields(o1.name) + o2.words = getfields(o2.name) + m = mf.getmatches([o1, o2])[0] + self.assertEqual(50, m.percentage) + + def test_with_fields_no_order(self): + mf = MatchFactory() + mf.no_field_order = True + o1 = NamedObject("foo bar - foo bleh") + o2 = NamedObject("bleh bang - foo bar") + o1.words = getfields(o1.name) + o2.words = getfields(o2.name) + m = mf.getmatches([o1, o2])[0] + self.assertEqual(50 ,m.percentage) + + def test_only_match_similar_when_the_option_is_set(self): + mf = MatchFactory() + mf.match_similar_words = False + l = [NamedObject("foobar"),NamedObject("foobars")] + self.assertEqual(0,len(mf.getmatches(l))) + + def test_dont_recurse_do_match(self): + # with nosetests, the stack is increased. The number has to be high enough not to be failing falsely + sys.setrecursionlimit(100) + mf = MatchFactory() + files = [NamedObject('foo bar') for i in range(101)] + try: + mf.getmatches(files) + except RuntimeError: + self.fail() + finally: + sys.setrecursionlimit(1000) + + def test_min_match_percentage(self): + l = [NamedObject("foo bar"),NamedObject("bar bleh"),NamedObject("a b c foo")] + mf = MatchFactory() + mf.min_match_percentage = 50 + r = mf.getmatches(l) + self.assertEqual(1,len(r)) #Only "foo bar" / "bar bleh" should match + + def test_limit(self): + l = [NamedObject(),NamedObject(),NamedObject()] + mf = MatchFactory() + mf.limit = 2 + r = mf.getmatches(l) + self.assertEqual(2,len(r)) + + def test_MemoryError(self): + @log_calls + def mocked_match(first, second, flags): + if len(mocked_match.calls) > 42: + raise MemoryError() + return Match(first, second, 0) + + objects = [NamedObject() for i in range(10)] # results in 45 matches + self.mock(engine, 'get_match', mocked_match) + mf = MatchFactory() + try: + r = mf.getmatches(objects) + except MemoryError: + self.fail('MemorryError must be handled') + self.assertEqual(42, len(r)) + + +class TCGroup(TestCase): + def test_empy(self): + g = Group() + self.assertEqual(None,g.ref) + self.assertEqual([],g.dupes) + self.assertEqual(0,len(g.matches)) + + def test_add_match(self): + g = Group() + m = get_match(NamedObject("foo",True),NamedObject("bar",True)) + g.add_match(m) + self.assert_(g.ref is m.first) + self.assertEqual([m.second],g.dupes) + self.assertEqual(1,len(g.matches)) + self.assert_(m in g.matches) + + def test_multiple_add_match(self): + g = Group() + o1 = NamedObject("a",True) + o2 = NamedObject("b",True) + o3 = NamedObject("c",True) + o4 = NamedObject("d",True) + g.add_match(get_match(o1,o2)) + self.assert_(g.ref is o1) + self.assertEqual([o2],g.dupes) + self.assertEqual(1,len(g.matches)) + g.add_match(get_match(o1,o3)) + self.assertEqual([o2],g.dupes) + self.assertEqual(2,len(g.matches)) + g.add_match(get_match(o2,o3)) + self.assertEqual([o2,o3],g.dupes) + self.assertEqual(3,len(g.matches)) + g.add_match(get_match(o1,o4)) + self.assertEqual([o2,o3],g.dupes) + self.assertEqual(4,len(g.matches)) + g.add_match(get_match(o2,o4)) + self.assertEqual([o2,o3],g.dupes) + self.assertEqual(5,len(g.matches)) + g.add_match(get_match(o3,o4)) + self.assertEqual([o2,o3,o4],g.dupes) + self.assertEqual(6,len(g.matches)) + + def test_len(self): + g = Group() + self.assertEqual(0,len(g)) + g.add_match(get_match(NamedObject("foo",True),NamedObject("bar",True))) + self.assertEqual(2,len(g)) + + def test_add_same_match_twice(self): + g = Group() + m = get_match(NamedObject("foo",True),NamedObject("foo",True)) + g.add_match(m) + self.assertEqual(2,len(g)) + self.assertEqual(1,len(g.matches)) + g.add_match(m) + self.assertEqual(2,len(g)) + self.assertEqual(1,len(g.matches)) + + def test_in(self): + g = Group() + o1 = NamedObject("foo",True) + o2 = NamedObject("bar",True) + self.assert_(o1 not in g) + g.add_match(get_match(o1,o2)) + self.assert_(o1 in g) + self.assert_(o2 in g) + + def test_remove(self): + g = Group() + o1 = NamedObject("foo",True) + o2 = NamedObject("bar",True) + o3 = NamedObject("bleh",True) + g.add_match(get_match(o1,o2)) + g.add_match(get_match(o1,o3)) + g.add_match(get_match(o2,o3)) + self.assertEqual(3,len(g.matches)) + self.assertEqual(3,len(g)) + g.remove_dupe(o3) + self.assertEqual(1,len(g.matches)) + self.assertEqual(2,len(g)) + g.remove_dupe(o1) + self.assertEqual(0,len(g.matches)) + self.assertEqual(0,len(g)) + + def test_remove_with_ref_dupes(self): + g = Group() + o1 = NamedObject("foo",True) + o2 = NamedObject("bar",True) + o3 = NamedObject("bleh",True) + g.add_match(get_match(o1,o2)) + g.add_match(get_match(o1,o3)) + g.add_match(get_match(o2,o3)) + o1.is_ref = True + o2.is_ref = True + g.remove_dupe(o3) + self.assertEqual(0,len(g)) + + def test_switch_ref(self): + o1 = NamedObject(with_words=True) + o2 = NamedObject(with_words=True) + g = Group() + g.add_match(get_match(o1,o2)) + self.assert_(o1 is g.ref) + g.switch_ref(o2) + self.assert_(o2 is g.ref) + self.assertEqual([o1],g.dupes) + g.switch_ref(o2) + self.assert_(o2 is g.ref) + g.switch_ref(NamedObject('',True)) + self.assert_(o2 is g.ref) + + def test_get_match_of(self): + g = Group() + for m in get_match_triangle(): + g.add_match(m) + o = g.dupes[0] + m = g.get_match_of(o) + self.assert_(g.ref in m) + self.assert_(o in m) + self.assert_(g.get_match_of(NamedObject('',True)) is None) + self.assert_(g.get_match_of(g.ref) is None) + + def test_percentage(self): + #percentage should return the avg percentage in relation to the ref + m1,m2,m3 = get_match_triangle() + m1 = Match(m1[0], m1[1], 100) + m2 = Match(m2[0], m2[1], 50) + m3 = Match(m3[0], m3[1], 33) + g = Group() + g.add_match(m1) + g.add_match(m2) + g.add_match(m3) + self.assertEqual(75,g.percentage) + g.switch_ref(g.dupes[0]) + self.assertEqual(66,g.percentage) + g.remove_dupe(g.dupes[0]) + self.assertEqual(33,g.percentage) + g.add_match(m1) + g.add_match(m2) + self.assertEqual(66,g.percentage) + + def test_percentage_on_empty_group(self): + g = Group() + self.assertEqual(0,g.percentage) + + def test_prioritize(self): + m1,m2,m3 = get_match_triangle() + o1 = m1.first + o2 = m1.second + o3 = m2.second + o1.name = 'c' + o2.name = 'b' + o3.name = 'a' + g = Group() + g.add_match(m1) + g.add_match(m2) + g.add_match(m3) + self.assert_(o1 is g.ref) + g.prioritize(lambda x:x.name) + self.assert_(o3 is g.ref) + + def test_prioritize_with_tie_breaker(self): + # if the ref has the same key as one or more of the dupe, run the tie_breaker func among them + g = get_test_group() + o1, o2, o3 = g.ordered + tie_breaker = lambda ref, dupe: dupe is o3 + g.prioritize(lambda x:0, tie_breaker) + self.assertTrue(g.ref is o3) + + def test_prioritize_with_tie_breaker_runs_on_all_dupes(self): + # Even if a dupe is chosen to switch with ref with a tie breaker, we still run the tie breaker + # with other dupes and the newly chosen ref + g = get_test_group() + o1, o2, o3 = g.ordered + o1.foo = 1 + o2.foo = 2 + o3.foo = 3 + tie_breaker = lambda ref, dupe: dupe.foo > ref.foo + g.prioritize(lambda x:0, tie_breaker) + self.assertTrue(g.ref is o3) + + def test_prioritize_with_tie_breaker_runs_only_on_tie_dupes(self): + # The tie breaker only runs on dupes that had the same value for the key_func + g = get_test_group() + o1, o2, o3 = g.ordered + o1.foo = 2 + o2.foo = 2 + o3.foo = 1 + o1.bar = 1 + o2.bar = 2 + o3.bar = 3 + key_func = lambda x: -x.foo + tie_breaker = lambda ref, dupe: dupe.bar > ref.bar + g.prioritize(key_func, tie_breaker) + self.assertTrue(g.ref is o2) + + def test_list_like(self): + g = Group() + o1,o2 = (NamedObject("foo",True),NamedObject("bar",True)) + g.add_match(get_match(o1,o2)) + self.assert_(g[0] is o1) + self.assert_(g[1] is o2) + + def test_clean_matches(self): + g = Group() + o1,o2,o3 = (NamedObject("foo",True),NamedObject("bar",True),NamedObject("baz",True)) + g.add_match(get_match(o1,o2)) + g.add_match(get_match(o1,o3)) + g.clean_matches() + self.assertEqual(1,len(g.matches)) + self.assertEqual(0,len(g.candidates)) + + +class TCget_groups(TestCase): + def test_empty(self): + r = get_groups([]) + self.assertEqual([],r) + + def test_simple(self): + l = [NamedObject("foo bar"),NamedObject("bar bleh")] + matches = MatchFactory().getmatches(l) + m = matches[0] + r = get_groups(matches) + self.assertEqual(1,len(r)) + g = r[0] + self.assert_(g.ref is m.first) + self.assertEqual([m.second],g.dupes) + + def test_group_with_multiple_matches(self): + #This results in 3 matches + l = [NamedObject("foo"),NamedObject("foo"),NamedObject("foo")] + matches = MatchFactory().getmatches(l) + r = get_groups(matches) + self.assertEqual(1,len(r)) + g = r[0] + self.assertEqual(3,len(g)) + + def test_must_choose_a_group(self): + l = [NamedObject("a b"),NamedObject("a b"),NamedObject("b c"),NamedObject("c d"),NamedObject("c d")] + #There will be 2 groups here: group "a b" and group "c d" + #"b c" can go either of them, but not both. + matches = MatchFactory().getmatches(l) + r = get_groups(matches) + self.assertEqual(2,len(r)) + self.assertEqual(5,len(r[0])+len(r[1])) + + def test_should_all_go_in_the_same_group(self): + l = [NamedObject("a b"),NamedObject("a b"),NamedObject("a b"),NamedObject("a b")] + #There will be 2 groups here: group "a b" and group "c d" + #"b c" can fit in both, but it must be in only one of them + matches = MatchFactory().getmatches(l) + r = get_groups(matches) + self.assertEqual(1,len(r)) + + def test_give_priority_to_matches_with_higher_percentage(self): + o1 = NamedObject(with_words=True) + o2 = NamedObject(with_words=True) + o3 = NamedObject(with_words=True) + m1 = Match(o1, o2, 1) + m2 = Match(o2, o3, 2) + r = get_groups([m1,m2]) + self.assertEqual(1,len(r)) + g = r[0] + self.assertEqual(2,len(g)) + self.assert_(o1 not in g) + self.assert_(o2 in g) + self.assert_(o3 in g) + + def test_four_sized_group(self): + l = [NamedObject("foobar") for i in xrange(4)] + m = MatchFactory().getmatches(l) + r = get_groups(m) + self.assertEqual(1,len(r)) + self.assertEqual(4,len(r[0])) + + def test_referenced_by_ref2(self): + o1 = NamedObject(with_words=True) + o2 = NamedObject(with_words=True) + o3 = NamedObject(with_words=True) + m1 = get_match(o1,o2) + m2 = get_match(o3,o1) + m3 = get_match(o3,o2) + r = get_groups([m1,m2,m3]) + self.assertEqual(3,len(r[0])) + + def test_job(self): + def do_progress(p,d=''): + self.log.append(p) + return True + + self.log = [] + j = job.Job(1,do_progress) + m1,m2,m3 = get_match_triangle() + #101%: To make sure it is processed first so the job test works correctly + m4 = Match(NamedObject('a',True), NamedObject('a',True), 101) + get_groups([m1,m2,m3,m4],j) + self.assertEqual(0,self.log[0]) + self.assertEqual(100,self.log[-1]) + + +if __name__ == "__main__": + unittest.main() diff --git a/pe/qt/dupeguru/export.py b/pe/qt/dupeguru/export.py new file mode 100644 index 00000000..c6293a5d --- /dev/null +++ b/pe/qt/dupeguru/export.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.export +Created By: Virgil Dupras +Created On: 2006/09/16 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +from xml.dom import minidom +import tempfile +import os.path as op +import os +from StringIO import StringIO + +from hsutil.files import FileOrPath + +def output_column_xml(outfile, columns): + """Creates a xml file outfile with the supplied columns. + + outfile can be a filename or a file object. + columns is a list of 2 sized tuples (display,enabled) + """ + doc = minidom.Document() + root = doc.appendChild(doc.createElement('columns')) + for display,enabled in columns: + col_node = root.appendChild(doc.createElement('column')) + col_node.setAttribute('display', display) + col_node.setAttribute('enabled', {True:'y',False:'n'}[enabled]) + with FileOrPath(outfile, 'wb') as fp: + doc.writexml(fp, '\t','\t','\n', encoding='utf-8') + +def merge_css_into_xhtml(xhtml, css): + with FileOrPath(xhtml, 'r+') as xhtml: + with FileOrPath(css) as css: + try: + doc = minidom.parse(xhtml) + except Exception: + return False + head = doc.getElementsByTagName('head')[0] + links = head.getElementsByTagName('link') + for link in links: + if link.getAttribute('rel') == 'stylesheet': + head.removeChild(link) + style = head.appendChild(doc.createElement('style')) + style.setAttribute('type','text/css') + style.appendChild(doc.createTextNode(css.read())) + xhtml.truncate(0) + doc.writexml(xhtml, '\t','\t','\n', encoding='utf-8') + xhtml.seek(0) + return True + +def export_to_xhtml(xml, xslt, css, columns, cmd='xsltproc --path "%(folder)s" "%(xslt)s" "%(xml)s"'): + folder = op.split(xml)[0] + output_column_xml(op.join(folder,'columns.xml'),columns) + html = StringIO() + cmd = cmd % {'folder': folder, 'xslt': xslt, 'xml': xml} + html.write(os.popen(cmd).read()) + html.seek(0) + merge_css_into_xhtml(html,css) + html.seek(0) + html_path = op.join(folder,'export.htm') + html_file = open(html_path,'w') + html_file.write(html.read().encode('utf-8')) + html_file.close() + return html_path diff --git a/pe/qt/dupeguru/export_test.py b/pe/qt/dupeguru/export_test.py new file mode 100644 index 00000000..5c4a6d87 --- /dev/null +++ b/pe/qt/dupeguru/export_test.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.tests.export +Created By: Virgil Dupras +Created On: 2006/09/16 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import unittest +from xml.dom import minidom +from StringIO import StringIO + +from hsutil.testcase import TestCase + +from .export import * +from . import export + +class TCoutput_columns_xml(TestCase): + def test_empty_columns(self): + f = StringIO() + output_column_xml(f,[]) + f.seek(0) + doc = minidom.parse(f) + root = doc.documentElement + self.assertEqual('columns',root.nodeName) + self.assertEqual(0,len(root.childNodes)) + + def test_some_columns(self): + f = StringIO() + output_column_xml(f,[('foo',True),('bar',False),('baz',True)]) + f.seek(0) + doc = minidom.parse(f) + columns = doc.getElementsByTagName('column') + self.assertEqual(3,len(columns)) + c1,c2,c3 = columns + self.assertEqual('foo',c1.getAttribute('display')) + self.assertEqual('bar',c2.getAttribute('display')) + self.assertEqual('baz',c3.getAttribute('display')) + self.assertEqual('y',c1.getAttribute('enabled')) + self.assertEqual('n',c2.getAttribute('enabled')) + self.assertEqual('y',c3.getAttribute('enabled')) + + +class TCmerge_css_into_xhtml(TestCase): + def test_main(self): + css = StringIO() + css.write('foobar') + css.seek(0) + xhtml = StringIO() + xhtml.write(""" + + + + + dupeGuru - Duplicate file scanner + + + + + + """) + xhtml.seek(0) + self.assert_(merge_css_into_xhtml(xhtml,css)) + xhtml.seek(0) + doc = minidom.parse(xhtml) + head = doc.getElementsByTagName('head')[0] + #A style node should have been added in head. + styles = head.getElementsByTagName('style') + self.assertEqual(1,len(styles)) + style = styles[0] + self.assertEqual('text/css',style.getAttribute('type')) + self.assertEqual('foobar',style.firstChild.nodeValue.strip()) + #all should be removed + self.assertEqual(1,len(head.getElementsByTagName('link'))) + + def test_empty(self): + self.assert_(not merge_css_into_xhtml(StringIO(),StringIO())) + + def test_malformed(self): + xhtml = StringIO() + xhtml.write(""" + + """) + xhtml.seek(0) + self.assert_(not merge_css_into_xhtml(xhtml,StringIO())) + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/pe/qt/dupeguru/gen.py b/pe/qt/dupeguru/gen.py new file mode 100644 index 00000000..0a842372 --- /dev/null +++ b/pe/qt/dupeguru/gen.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# Unit Name: gen +# Created By: Virgil Dupras +# Created On: 2009-05-26 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import os +import os.path as op + +def move(src, dst): + if not op.exists(src): + return + if op.exists(dst): + os.remove(dst) + print 'Moving %s --> %s' % (src, dst) + os.rename(src, dst) + + +os.chdir(op.join('modules', 'block')) +os.system('python setup.py build_ext --inplace') +os.chdir(op.join('..', 'cache')) +os.system('python setup.py build_ext --inplace') +os.chdir(op.join('..', '..')) +move(op.join('modules', 'block', '_block.so'), op.join('picture', '_block.so')) +move(op.join('modules', 'block', '_block.pyd'), op.join('picture', '_block.pyd')) +move(op.join('modules', 'cache', '_cache.so'), op.join('picture', '_cache.so')) +move(op.join('modules', 'cache', '_cache.pyd'), op.join('picture', '_cache.pyd')) diff --git a/pe/qt/dupeguru/ignore.py b/pe/qt/dupeguru/ignore.py new file mode 100644 index 00000000..97060786 --- /dev/null +++ b/pe/qt/dupeguru/ignore.py @@ -0,0 +1,117 @@ +#!/usr/bin/env python +""" +Unit Name: ignore +Created By: Virgil Dupras +Created On: 2006/05/02 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +from hsutil.files import FileOrPath + +import xml.dom.minidom + +class IgnoreList(object): + """An ignore list implementation that is iterable, filterable and exportable to XML. + + Call Ignore to add an ignore list entry, and AreIgnore to check if 2 items are in the list. + When iterated, 2 sized tuples will be returned, the tuples containing 2 items ignored together. + """ + #---Override + def __init__(self): + self._ignored = {} + self._count = 0 + + def __iter__(self): + for first,seconds in self._ignored.iteritems(): + for second in seconds: + yield (first,second) + + def __len__(self): + return self._count + + #---Public + def AreIgnored(self,first,second): + def do_check(first,second): + try: + matches = self._ignored[first] + return second in matches + except KeyError: + return False + + return do_check(first,second) or do_check(second,first) + + def Clear(self): + self._ignored = {} + self._count = 0 + + def Filter(self,func): + """Applies a filter on all ignored items, and remove all matches where func(first,second) + doesn't return True. + """ + filtered = IgnoreList() + for first,second in self: + if func(first,second): + filtered.Ignore(first,second) + self._ignored = filtered._ignored + self._count = filtered._count + + def Ignore(self,first,second): + if self.AreIgnored(first,second): + return + try: + matches = self._ignored[first] + matches.add(second) + except KeyError: + try: + matches = self._ignored[second] + matches.add(first) + except KeyError: + matches = set() + matches.add(second) + self._ignored[first] = matches + self._count += 1 + + def load_from_xml(self,infile): + """Loads the ignore list from a XML created with save_to_xml. + + infile can be a file object or a filename. + """ + try: + doc = xml.dom.minidom.parse(infile) + except Exception: + return + file_nodes = doc.getElementsByTagName('file') + for fn in file_nodes: + if not fn.getAttributeNode('path'): + continue + file_path = fn.getAttributeNode('path').nodeValue + subfile_nodes = fn.getElementsByTagName('file') + for sfn in subfile_nodes: + if not sfn.getAttributeNode('path'): + continue + subfile_path = sfn.getAttributeNode('path').nodeValue + self.Ignore(file_path,subfile_path) + + def save_to_xml(self,outfile): + """Create a XML file that can be used by load_from_xml. + + outfile can be a file object or a filename. + """ + doc = xml.dom.minidom.Document() + root = doc.appendChild(doc.createElement('ignore_list')) + for file,subfiles in self._ignored.items(): + file_node = root.appendChild(doc.createElement('file')) + if isinstance(file,unicode): + file = file.encode('utf-8') + file_node.setAttribute('path',file) + for subfile in subfiles: + subfile_node = file_node.appendChild(doc.createElement('file')) + if isinstance(subfile,unicode): + subfile = subfile.encode('utf-8') + subfile_node.setAttribute('path',subfile) + with FileOrPath(outfile, 'wb') as fp: + doc.writexml(fp,'\t','\t','\n',encoding='utf-8') + + diff --git a/pe/qt/dupeguru/ignore_test.py b/pe/qt/dupeguru/ignore_test.py new file mode 100644 index 00000000..8ff91f52 --- /dev/null +++ b/pe/qt/dupeguru/ignore_test.py @@ -0,0 +1,158 @@ +#!/usr/bin/env python +""" +Unit Name: ignore +Created By: Virgil Dupras +Created On: 2006/05/02 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import unittest +import cStringIO +import xml.dom.minidom + +from .ignore import * + +class TCIgnoreList(unittest.TestCase): + def test_empty(self): + il = IgnoreList() + self.assertEqual(0,len(il)) + self.assert_(not il.AreIgnored('foo','bar')) + + def test_simple(self): + il = IgnoreList() + il.Ignore('foo','bar') + self.assert_(il.AreIgnored('foo','bar')) + self.assert_(il.AreIgnored('bar','foo')) + self.assert_(not il.AreIgnored('foo','bleh')) + self.assert_(not il.AreIgnored('bleh','bar')) + self.assertEqual(1,len(il)) + + def test_multiple(self): + il = IgnoreList() + il.Ignore('foo','bar') + il.Ignore('foo','bleh') + il.Ignore('bleh','bar') + il.Ignore('aybabtu','bleh') + self.assert_(il.AreIgnored('foo','bar')) + self.assert_(il.AreIgnored('bar','foo')) + self.assert_(il.AreIgnored('foo','bleh')) + self.assert_(il.AreIgnored('bleh','bar')) + self.assert_(not il.AreIgnored('aybabtu','bar')) + self.assertEqual(4,len(il)) + + def test_clear(self): + il = IgnoreList() + il.Ignore('foo','bar') + il.Clear() + self.assert_(not il.AreIgnored('foo','bar')) + self.assert_(not il.AreIgnored('bar','foo')) + self.assertEqual(0,len(il)) + + def test_add_same_twice(self): + il = IgnoreList() + il.Ignore('foo','bar') + il.Ignore('bar','foo') + self.assertEqual(1,len(il)) + + def test_save_to_xml(self): + il = IgnoreList() + il.Ignore('foo','bar') + il.Ignore('foo','bleh') + il.Ignore('bleh','bar') + f = cStringIO.StringIO() + il.save_to_xml(f) + f.seek(0) + doc = xml.dom.minidom.parse(f) + root = doc.documentElement + self.assertEqual('ignore_list',root.nodeName) + children = [c for c in root.childNodes if c.localName] + self.assertEqual(2,len(children)) + self.assertEqual(2,len([c for c in children if c.nodeName == 'file'])) + f1,f2 = children + subchildren = [c for c in f1.childNodes if c.localName == 'file'] +\ + [c for c in f2.childNodes if c.localName == 'file'] + self.assertEqual(3,len(subchildren)) + + def test_SaveThenLoad(self): + il = IgnoreList() + il.Ignore('foo','bar') + il.Ignore('foo','bleh') + il.Ignore('bleh','bar') + il.Ignore(u'\u00e9','bar') + f = cStringIO.StringIO() + il.save_to_xml(f) + f.seek(0) + il = IgnoreList() + il.load_from_xml(f) + self.assertEqual(4,len(il)) + self.assert_(il.AreIgnored(u'\u00e9','bar')) + + def test_LoadXML_with_empty_file_tags(self): + f = cStringIO.StringIO() + f.write('') + f.seek(0) + il = IgnoreList() + il.load_from_xml(f) + self.assertEqual(0,len(il)) + + def test_AreIgnore_works_when_a_child_is_a_key_somewhere_else(self): + il = IgnoreList() + il.Ignore('foo','bar') + il.Ignore('bar','baz') + self.assert_(il.AreIgnored('bar','foo')) + + + def test_no_dupes_when_a_child_is_a_key_somewhere_else(self): + il = IgnoreList() + il.Ignore('foo','bar') + il.Ignore('bar','baz') + il.Ignore('bar','foo') + self.assertEqual(2,len(il)) + + def test_iterate(self): + #It must be possible to iterate through ignore list + il = IgnoreList() + expected = [('foo','bar'),('bar','baz'),('foo','baz')] + for i in expected: + il.Ignore(i[0],i[1]) + for i in il: + expected.remove(i) #No exception should be raised + self.assert_(not expected) #expected should be empty + + def test_filter(self): + il = IgnoreList() + il.Ignore('foo','bar') + il.Ignore('bar','baz') + il.Ignore('foo','baz') + il.Filter(lambda f,s: f == 'bar') + self.assertEqual(1,len(il)) + self.assert_(not il.AreIgnored('foo','bar')) + self.assert_(il.AreIgnored('bar','baz')) + + def test_save_with_non_ascii_non_unicode_items(self): + il = IgnoreList() + il.Ignore('\xac','\xbf') + f = cStringIO.StringIO() + try: + il.save_to_xml(f) + except Exception,e: + self.fail(str(e)) + + def test_len(self): + il = IgnoreList() + self.assertEqual(0,len(il)) + il.Ignore('foo','bar') + self.assertEqual(1,len(il)) + + def test_nonzero(self): + il = IgnoreList() + self.assert_(not il) + il.Ignore('foo','bar') + self.assert_(il) + + +if __name__ == "__main__": + unittest.main() + diff --git a/pe/qt/dupeguru/modules/block/block.pyx b/pe/qt/dupeguru/modules/block/block.pyx new file mode 100644 index 00000000..db4c7500 --- /dev/null +++ b/pe/qt/dupeguru/modules/block/block.pyx @@ -0,0 +1,93 @@ +# Created By: Virgil Dupras +# Created On: 2009-04-23 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +cdef extern from "stdlib.h": + int abs(int n) # required so that abs() is applied on ints, not python objects + +class NoBlocksError(Exception): + """avgdiff/maxdiff has been called with empty lists""" + +class DifferentBlockCountError(Exception): + """avgdiff/maxdiff has been called with 2 block lists of different size.""" + + +cdef object getblock(object image): + """Returns a 3 sized tuple containing the mean color of 'image'. + + image: a PIL image or crop. + """ + cdef int pixel_count, red, green, blue, r, g, b + if image.size[0]: + pixel_count = image.size[0] * image.size[1] + red = green = blue = 0 + for r, g, b in image.getdata(): + red += r + green += g + blue += b + return (red // pixel_count, green // pixel_count, blue // pixel_count) + else: + return (0, 0, 0) + +def getblocks2(image, int block_count_per_side): + """Returns a list of blocks (3 sized tuples). + + image: A PIL image to base the blocks on. + block_count_per_side: This integer determine the number of blocks the function will return. + If it is 10, for example, 100 blocks will be returns (10 width, 10 height). The blocks will not + necessarely cover square areas. The area covered by each block will be proportional to the image + itself. + """ + if not image.size[0]: + return [] + cdef int width, height, block_width, block_height, ih, iw, top, bottom, left, right + width, height = image.size + block_width = max(width // block_count_per_side, 1) + block_height = max(height // block_count_per_side, 1) + result = [] + for ih in range(block_count_per_side): + top = min(ih * block_height, height - block_height) + bottom = top + block_height + for iw in range(block_count_per_side): + left = min(iw * block_width, width - block_width) + right = left + block_width + box = (left, top, right, bottom) + crop = image.crop(box) + result.append(getblock(crop)) + return result + +cdef int diff(first, second): + """Returns the difference between the first block and the second. + + It returns an absolute sum of the 3 differences (RGB). + """ + cdef int r1, g1, b1, r2, g2, b2 + r1, g1, b1 = first + r2, g2, b2 = second + return abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2) + +def avgdiff(first, second, int limit, int min_iterations): + """Returns the average diff between first blocks and seconds. + + If the result surpasses limit, limit + 1 is returned, except if less than min_iterations + iterations have been made in the blocks. + """ + cdef int count, sum, i, iteration_count + count = len(first) + if count != len(second): + raise DifferentBlockCountError() + if not count: + raise NoBlocksError() + sum = 0 + for i in range(count): + iteration_count = i + 1 + item1 = first[i] + item2 = second[i] + sum += diff(item1, item2) + if sum > limit * iteration_count and iteration_count >= min_iterations: + return limit + 1 + result = sum // count + if (not result) and sum: + result = 1 + return result \ No newline at end of file diff --git a/pe/qt/dupeguru/modules/block/setup.py b/pe/qt/dupeguru/modules/block/setup.py new file mode 100644 index 00000000..9d8f4cb5 --- /dev/null +++ b/pe/qt/dupeguru/modules/block/setup.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +# Created By: Virgil Dupras +# Created On: 2009-04-23 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from distutils.core import setup +from distutils.extension import Extension +from Cython.Distutils import build_ext + +setup( + cmdclass = {'build_ext': build_ext}, + ext_modules = [Extension("_block", ["block.pyx"])] +) \ No newline at end of file diff --git a/pe/qt/dupeguru/modules/cache/cache.pyx b/pe/qt/dupeguru/modules/cache/cache.pyx new file mode 100644 index 00000000..7bd2407d --- /dev/null +++ b/pe/qt/dupeguru/modules/cache/cache.pyx @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# Created By: Virgil Dupras +# Created On: 2009-04-23 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +# ok, this is hacky and stuff, but I don't know C well enough to play with char buffers, copy +# them around and stuff +cdef int xchar_to_int(char c): + if 48 <= c <= 57: # 0-9 + return c - 48 + elif 65 <= c <= 70: # A-F + return c - 55 + elif 97 <= c <= 102: # a-f + return c - 87 + +def string_to_colors(s): + """Transform the string 's' in a list of 3 sized tuples. + """ + result = [] + cdef int i, char_count, r, g, b + cdef char* cs + char_count = len(s) + char_count = (char_count // 6) * 6 + cs = s + for i in range(0, char_count, 6): + r = xchar_to_int(cs[i]) << 4 + r += xchar_to_int(cs[i+1]) + g = xchar_to_int(cs[i+2]) << 4 + g += xchar_to_int(cs[i+3]) + b = xchar_to_int(cs[i+4]) << 4 + b += xchar_to_int(cs[i+5]) + result.append((r, g, b)) + return result diff --git a/pe/qt/dupeguru/modules/cache/setup.py b/pe/qt/dupeguru/modules/cache/setup.py new file mode 100644 index 00000000..2b6cd31b --- /dev/null +++ b/pe/qt/dupeguru/modules/cache/setup.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +# Created By: Virgil Dupras +# Created On: 2009-04-23 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from distutils.core import setup +from distutils.extension import Extension +from Cython.Distutils import build_ext + +setup( + cmdclass = {'build_ext': build_ext}, + ext_modules = [Extension("_cache", ["cache.pyx"])] +) \ No newline at end of file diff --git a/pe/qt/dupeguru/picture/__init__.py b/pe/qt/dupeguru/picture/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pe/qt/dupeguru/picture/block.py b/pe/qt/dupeguru/picture/block.py new file mode 100644 index 00000000..70015a50 --- /dev/null +++ b/pe/qt/dupeguru/picture/block.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python +""" +Unit Name: hs.picture.block +Created By: Virgil Dupras +Created On: 2006/09/01 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-26 18:12:39 +0200 (Tue, 26 May 2009) $ + $Revision: 4365 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +from _block import NoBlocksError, DifferentBlockCountError, avgdiff, getblocks2 + +# Converted to Cython +# def getblock(image): +# """Returns a 3 sized tuple containing the mean color of 'image'. +# +# image: a PIL image or crop. +# """ +# if image.size[0]: +# pixel_count = image.size[0] * image.size[1] +# red = green = blue = 0 +# for r,g,b in image.getdata(): +# red += r +# green += g +# blue += b +# return (red // pixel_count, green // pixel_count, blue // pixel_count) +# else: +# return (0,0,0) + +# This is not used anymore +# def getblocks(image,blocksize): +# """Returns a list of blocks (3 sized tuples). +# +# image: A PIL image to base the blocks on. +# blocksize: The size of the blocks to be create. This is a single integer, defining +# both width and height (blocks are square). +# """ +# if min(image.size) < blocksize: +# return () +# result = [] +# for i in xrange(image.size[1] // blocksize): +# for j in xrange(image.size[0] // blocksize): +# box = (blocksize * j, blocksize * i, blocksize * (j + 1), blocksize * (i + 1)) +# crop = image.crop(box) +# result.append(getblock(crop)) +# return result + +# Converted to Cython +# def getblocks2(image,block_count_per_side): +# """Returns a list of blocks (3 sized tuples). +# +# image: A PIL image to base the blocks on. +# block_count_per_side: This integer determine the number of blocks the function will return. +# If it is 10, for example, 100 blocks will be returns (10 width, 10 height). The blocks will not +# necessarely cover square areas. The area covered by each block will be proportional to the image +# itself. +# """ +# if not image.size[0]: +# return [] +# width,height = image.size +# block_width = max(width // block_count_per_side,1) +# block_height = max(height // block_count_per_side,1) +# result = [] +# for ih in range(block_count_per_side): +# top = min(ih * block_height, height - block_height) +# bottom = top + block_height +# for iw in range(block_count_per_side): +# left = min(iw * block_width, width - block_width) +# right = left + block_width +# box = (left,top,right,bottom) +# crop = image.crop(box) +# result.append(getblock(crop)) +# return result + +# Converted to Cython +# def diff(first, second): +# """Returns the difference between the first block and the second. +# +# It returns an absolute sum of the 3 differences (RGB). +# """ +# r1, g1, b1 = first +# r2, g2, b2 = second +# return abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2) + +# Converted to Cython +# def avgdiff(first, second, limit=768, min_iterations=1): +# """Returns the average diff between first blocks and seconds. +# +# If the result surpasses limit, limit + 1 is returned, except if less than min_iterations +# iterations have been made in the blocks. +# """ +# if len(first) != len(second): +# raise DifferentBlockCountError +# if not first: +# raise NoBlocksError +# count = len(first) +# sum = 0 +# zipped = izip(xrange(1, count + 1), first, second) +# for i, first, second in zipped: +# sum += diff(first, second) +# if sum > limit * i and i >= min_iterations: +# return limit + 1 +# result = sum // count +# if (not result) and sum: +# result = 1 +# return result + +# This is not used anymore +# def maxdiff(first,second,limit=768): +# """Returns the max diff between first blocks and seconds. +# +# If the result surpasses limit, the first max being over limit is returned. +# """ +# if len(first) != len(second): +# raise DifferentBlockCountError +# if not first: +# raise NoBlocksError +# result = 0 +# zipped = zip(first,second) +# for first,second in zipped: +# result = max(result,diff(first,second)) +# if result > limit: +# return result +# return result diff --git a/pe/qt/dupeguru/picture/block_test.py b/pe/qt/dupeguru/picture/block_test.py new file mode 100644 index 00000000..a06cf617 --- /dev/null +++ b/pe/qt/dupeguru/picture/block_test.py @@ -0,0 +1,313 @@ +#!/usr/bin/env python +""" +Unit Name: tests.picture.block +Created By: Virgil Dupras +Created On: 2006/09/01 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +# The commented out tests are tests for function that have been converted to pure C for speed +import unittest + +from .block import * + +def my_avgdiff(first, second, limit=768, min_iter=3): # this is so I don't have to re-write every call + return avgdiff(first, second, limit, min_iter) + +BLACK = (0,0,0) +RED = (0xff,0,0) +GREEN = (0,0xff,0) +BLUE = (0,0,0xff) + +class FakeImage(object): + def __init__(self, size, data): + self.size = size + self.data = data + + def getdata(self): + return self.data + + def crop(self, box): + pixels = [] + for i in range(box[1], box[3]): + for j in range(box[0], box[2]): + pixel = self.data[i * self.size[0] + j] + pixels.append(pixel) + return FakeImage((box[2] - box[0], box[3] - box[1]), pixels) + +def empty(): + return FakeImage((0,0), []) + +def single_pixel(): #one red pixel + return FakeImage((1, 1), [(0xff,0,0)]) + +def four_pixels(): + pixels = [RED,(0,0x80,0xff),(0x80,0,0),(0,0x40,0x80)] + return FakeImage((2, 2), pixels) + +class TCgetblock(unittest.TestCase): + def test_single_pixel(self): + im = single_pixel() + [b] = getblocks2(im, 1) + self.assertEqual(RED,b) + + def test_no_pixel(self): + im = empty() + self.assertEqual([], getblocks2(im, 1)) + + def test_four_pixels(self): + im = four_pixels() + [b] = getblocks2(im, 1) + meanred = (0xff + 0x80) // 4 + meangreen = (0x80 + 0x40) // 4 + meanblue = (0xff + 0x80) // 4 + self.assertEqual((meanred,meangreen,meanblue),b) + + +# class TCdiff(unittest.TestCase): +# def test_diff(self): +# b1 = (10, 20, 30) +# b2 = (1, 2, 3) +# self.assertEqual(9 + 18 + 27,diff(b1,b2)) +# +# def test_diff_negative(self): +# b1 = (10, 20, 30) +# b2 = (1, 2, 3) +# self.assertEqual(9 + 18 + 27,diff(b2,b1)) +# +# def test_diff_mixed_positive_and_negative(self): +# b1 = (1, 5, 10) +# b2 = (10, 1, 15) +# self.assertEqual(9 + 4 + 5,diff(b1,b2)) +# + +# class TCgetblocks(unittest.TestCase): +# def test_empty_image(self): +# im = empty() +# blocks = getblocks(im,1) +# self.assertEqual(0,len(blocks)) +# +# def test_one_block_image(self): +# im = four_pixels() +# blocks = getblocks2(im, 1) +# self.assertEqual(1,len(blocks)) +# block = blocks[0] +# meanred = (0xff + 0x80) // 4 +# meangreen = (0x80 + 0x40) // 4 +# meanblue = (0xff + 0x80) // 4 +# self.assertEqual((meanred,meangreen,meanblue),block) +# +# def test_not_enough_height_to_fit_a_block(self): +# im = FakeImage((2,1), [BLACK, BLACK]) +# blocks = getblocks(im,2) +# self.assertEqual(0,len(blocks)) +# +# def xtest_dont_include_leftovers(self): +# # this test is disabled because getblocks is not used and getblock in cdeffed +# pixels = [ +# RED,(0,0x80,0xff),BLACK, +# (0x80,0,0),(0,0x40,0x80),BLACK, +# BLACK,BLACK,BLACK +# ] +# im = FakeImage((3,3), pixels) +# blocks = getblocks(im,2) +# block = blocks[0] +# #Because the block is smaller than the image, only blocksize must be considered. +# meanred = (0xff + 0x80) // 4 +# meangreen = (0x80 + 0x40) // 4 +# meanblue = (0xff + 0x80) // 4 +# self.assertEqual((meanred,meangreen,meanblue),block) +# +# def xtest_two_blocks(self): +# # this test is disabled because getblocks is not used and getblock in cdeffed +# pixels = [BLACK for i in xrange(4 * 2)] +# pixels[0] = RED +# pixels[1] = (0,0x80,0xff) +# pixels[4] = (0x80,0,0) +# pixels[5] = (0,0x40,0x80) +# im = FakeImage((4, 2), pixels) +# blocks = getblocks(im,2) +# self.assertEqual(2,len(blocks)) +# block = blocks[0] +# #Because the block is smaller than the image, only blocksize must be considered. +# meanred = (0xff + 0x80) // 4 +# meangreen = (0x80 + 0x40) // 4 +# meanblue = (0xff + 0x80) // 4 +# self.assertEqual((meanred,meangreen,meanblue),block) +# self.assertEqual(BLACK,blocks[1]) +# +# def test_four_blocks(self): +# pixels = [BLACK for i in xrange(4 * 4)] +# pixels[0] = RED +# pixels[1] = (0,0x80,0xff) +# pixels[4] = (0x80,0,0) +# pixels[5] = (0,0x40,0x80) +# im = FakeImage((4, 4), pixels) +# blocks = getblocks2(im, 2) +# self.assertEqual(4,len(blocks)) +# block = blocks[0] +# #Because the block is smaller than the image, only blocksize must be considered. +# meanred = (0xff + 0x80) // 4 +# meangreen = (0x80 + 0x40) // 4 +# meanblue = (0xff + 0x80) // 4 +# self.assertEqual((meanred,meangreen,meanblue),block) +# self.assertEqual(BLACK,blocks[1]) +# self.assertEqual(BLACK,blocks[2]) +# self.assertEqual(BLACK,blocks[3]) +# + +class TCgetblocks2(unittest.TestCase): + def test_empty_image(self): + im = empty() + blocks = getblocks2(im,1) + self.assertEqual(0,len(blocks)) + + def test_one_block_image(self): + im = four_pixels() + blocks = getblocks2(im,1) + self.assertEqual(1,len(blocks)) + block = blocks[0] + meanred = (0xff + 0x80) // 4 + meangreen = (0x80 + 0x40) // 4 + meanblue = (0xff + 0x80) // 4 + self.assertEqual((meanred,meangreen,meanblue),block) + + def test_four_blocks_all_black(self): + im = FakeImage((2, 2), [BLACK, BLACK, BLACK, BLACK]) + blocks = getblocks2(im,2) + self.assertEqual(4,len(blocks)) + for block in blocks: + self.assertEqual(BLACK,block) + + def test_two_pixels_image_horizontal(self): + pixels = [RED,BLUE] + im = FakeImage((2, 1), pixels) + blocks = getblocks2(im,2) + self.assertEqual(4,len(blocks)) + self.assertEqual(RED,blocks[0]) + self.assertEqual(BLUE,blocks[1]) + self.assertEqual(RED,blocks[2]) + self.assertEqual(BLUE,blocks[3]) + + def test_two_pixels_image_vertical(self): + pixels = [RED,BLUE] + im = FakeImage((1, 2), pixels) + blocks = getblocks2(im,2) + self.assertEqual(4,len(blocks)) + self.assertEqual(RED,blocks[0]) + self.assertEqual(RED,blocks[1]) + self.assertEqual(BLUE,blocks[2]) + self.assertEqual(BLUE,blocks[3]) + + +class TCavgdiff(unittest.TestCase): + def test_empty(self): + self.assertRaises(NoBlocksError, my_avgdiff, [], []) + + def test_two_blocks(self): + im = empty() + b1 = (5,10,15) + b2 = (255,250,245) + b3 = (0,0,0) + b4 = (255,0,255) + blocks1 = [b1,b2] + blocks2 = [b3,b4] + expected1 = 5 + 10 + 15 + expected2 = 0 + 250 + 10 + expected = (expected1 + expected2) // 2 + self.assertEqual(expected, my_avgdiff(blocks1, blocks2)) + + def test_blocks_not_the_same_size(self): + b = (0,0,0) + self.assertRaises(DifferentBlockCountError,my_avgdiff,[b,b],[b]) + + def test_first_arg_is_empty_but_not_second(self): + #Don't return 0 (as when the 2 lists are empty), raise! + b = (0,0,0) + self.assertRaises(DifferentBlockCountError,my_avgdiff,[],[b]) + + def test_limit(self): + ref = (0,0,0) + b1 = (10,10,10) #avg 30 + b2 = (20,20,20) #avg 45 + b3 = (30,30,30) #avg 60 + blocks1 = [ref,ref,ref] + blocks2 = [b1,b2,b3] + self.assertEqual(45,my_avgdiff(blocks1,blocks2,44)) + + def test_min_iterations(self): + ref = (0,0,0) + b1 = (10,10,10) #avg 30 + b2 = (20,20,20) #avg 45 + b3 = (10,10,10) #avg 40 + blocks1 = [ref,ref,ref] + blocks2 = [b1,b2,b3] + self.assertEqual(40,my_avgdiff(blocks1,blocks2,45 - 1,3)) + + # Bah, I don't know why this test fails, but I don't think it matters very much + # def test_just_over_the_limit(self): + # #A score just over the limit might return exactly the limit due to truncating. We should + # #ceil() the result in this case. + # ref = (0,0,0) + # b1 = (10,0,0) + # b2 = (11,0,0) + # blocks1 = [ref,ref] + # blocks2 = [b1,b2] + # self.assertEqual(11,my_avgdiff(blocks1,blocks2,10)) + # + def test_return_at_least_1_at_the_slightest_difference(self): + ref = (0,0,0) + b1 = (1,0,0) + blocks1 = [ref for i in xrange(250)] + blocks2 = [ref for i in xrange(250)] + blocks2[0] = b1 + self.assertEqual(1,my_avgdiff(blocks1,blocks2)) + + def test_return_0_if_there_is_no_difference(self): + ref = (0,0,0) + blocks1 = [ref,ref] + blocks2 = [ref,ref] + self.assertEqual(0,my_avgdiff(blocks1,blocks2)) + + +# class TCmaxdiff(unittest.TestCase): +# def test_empty(self): +# self.assertRaises(NoBlocksError,maxdiff,[],[]) +# +# def test_two_blocks(self): +# b1 = (5,10,15) +# b2 = (255,250,245) +# b3 = (0,0,0) +# b4 = (255,0,255) +# blocks1 = [b1,b2] +# blocks2 = [b3,b4] +# expected1 = 5 + 10 + 15 +# expected2 = 0 + 250 + 10 +# expected = max(expected1,expected2) +# self.assertEqual(expected,maxdiff(blocks1,blocks2)) +# +# def test_blocks_not_the_same_size(self): +# b = (0,0,0) +# self.assertRaises(DifferentBlockCountError,maxdiff,[b,b],[b]) +# +# def test_first_arg_is_empty_but_not_second(self): +# #Don't return 0 (as when the 2 lists are empty), raise! +# b = (0,0,0) +# self.assertRaises(DifferentBlockCountError,maxdiff,[],[b]) +# +# def test_limit(self): +# b1 = (5,10,15) +# b2 = (255,250,245) +# b3 = (0,0,0) +# b4 = (255,0,255) +# blocks1 = [b1,b2] +# blocks2 = [b3,b4] +# expected1 = 5 + 10 + 15 +# expected2 = 0 + 250 + 10 +# self.assertEqual(expected1,maxdiff(blocks1,blocks2,expected1 - 1)) +# + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/pe/qt/dupeguru/picture/cache.py b/pe/qt/dupeguru/picture/cache.py new file mode 100644 index 00000000..6ff0d2d1 --- /dev/null +++ b/pe/qt/dupeguru/picture/cache.py @@ -0,0 +1,134 @@ +#!/usr/bin/env python +""" +Unit Name: hs.picture.cache +Created By: Virgil Dupras +Created On: 2006/09/14 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:33:32 +0200 (Thu, 28 May 2009) $ + $Revision: 4392 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import os +import logging +import sqlite3 as sqlite + +import hsutil.sqlite + +from _cache import string_to_colors + +def colors_to_string(colors): + """Transform the 3 sized tuples 'colors' into a hex string. + + [(0,100,255)] --> 0064ff + [(1,2,3),(4,5,6)] --> 010203040506 + """ + return ''.join(['%02x%02x%02x' % (r,g,b) for r,g,b in colors]) + +# This function is an important bottleneck of dupeGuru PE. It has been converted to Cython. +# def string_to_colors(s): +# """Transform the string 's' in a list of 3 sized tuples. +# """ +# result = [] +# for i in xrange(0, len(s), 6): +# number = int(s[i:i+6], 16) +# result.append((number >> 16, (number >> 8) & 0xff, number & 0xff)) +# return result + +class Cache(object): + """A class to cache picture blocks. + """ + def __init__(self, db=':memory:', threaded=True): + def create_tables(): + sql = "create table pictures(path TEXT, blocks TEXT)" + self.con.execute(sql); + sql = "create index idx_path on pictures (path)" + self.con.execute(sql) + + self.dbname = db + if threaded: + self.con = hsutil.sqlite.ThreadedConn(db, True) + else: + self.con = sqlite.connect(db, isolation_level=None) + try: + self.con.execute("select * from pictures where 1=2") + except sqlite.OperationalError: # new db + create_tables() + except sqlite.DatabaseError, e: # corrupted db + logging.warning('Could not create picture cache because of an error: %s', str(e)) + self.con.close() + os.remove(db) + if threaded: + self.con = hsutil.sqlite.ThreadedConn(db, True) + else: + self.con = sqlite.connect(db, isolation_level=None) + create_tables() + + def __contains__(self, key): + sql = "select count(*) from pictures where path = ?" + result = self.con.execute(sql, [key]).fetchall() + return result[0][0] > 0 + + def __delitem__(self, key): + if key not in self: + raise KeyError(key) + sql = "delete from pictures where path = ?" + self.con.execute(sql, [key]) + + # Optimized + def __getitem__(self, key): + if isinstance(key, int): + sql = "select blocks from pictures where rowid = ?" + else: + sql = "select blocks from pictures where path = ?" + result = self.con.execute(sql, [key]).fetchone() + if result: + result = string_to_colors(result[0]) + return result + else: + raise KeyError(key) + + def __iter__(self): + sql = "select path from pictures" + result = self.con.execute(sql) + return (row[0] for row in result) + + def __len__(self): + sql = "select count(*) from pictures" + result = self.con.execute(sql).fetchall() + return result[0][0] + + def __setitem__(self, key, value): + value = colors_to_string(value) + if key in self: + sql = "update pictures set blocks = ? where path = ?" + else: + sql = "insert into pictures(blocks,path) values(?,?)" + try: + self.con.execute(sql, [value, key]) + except sqlite.OperationalError: + logging.warning('Picture cache could not set %r for key %r', value, key) + except sqlite.DatabaseError, e: + logging.warning('DatabaseError while setting %r for key %r: %s', value, key, str(e)) + + def clear(self): + sql = "delete from pictures" + self.con.execute(sql) + + def filter(self, func): + to_delete = [key for key in self if not func(key)] + for key in to_delete: + del self[key] + + def get_id(self, path): + sql = "select rowid from pictures where path = ?" + result = self.con.execute(sql, [path]).fetchone() + if result: + return result[0] + else: + raise ValueError(path) + + def get_multiple(self, rowids): + sql = "select rowid, blocks from pictures where rowid in (%s)" % ','.join(map(str, rowids)) + cur = self.con.execute(sql) + return ((rowid, string_to_colors(blocks)) for rowid, blocks in cur) + diff --git a/pe/qt/dupeguru/picture/cache_test.py b/pe/qt/dupeguru/picture/cache_test.py new file mode 100644 index 00000000..f453112f --- /dev/null +++ b/pe/qt/dupeguru/picture/cache_test.py @@ -0,0 +1,159 @@ +#!/usr/bin/env python +""" +Unit Name: tests.picture.cache +Created By: Virgil Dupras +Created On: 2006/09/14 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import unittest +from StringIO import StringIO +import os.path as op +import os +import threading + +from hsutil.testcase import TestCase +from .cache import * + +class TCcolors_to_string(unittest.TestCase): + def test_no_color(self): + self.assertEqual('',colors_to_string([])) + + def test_single_color(self): + self.assertEqual('000000',colors_to_string([(0,0,0)])) + self.assertEqual('010101',colors_to_string([(1,1,1)])) + self.assertEqual('0a141e',colors_to_string([(10,20,30)])) + + def test_two_colors(self): + self.assertEqual('000102030405',colors_to_string([(0,1,2),(3,4,5)])) + + +class TCstring_to_colors(unittest.TestCase): + def test_empty(self): + self.assertEqual([],string_to_colors('')) + + def test_single_color(self): + self.assertEqual([(0,0,0)],string_to_colors('000000')) + self.assertEqual([(2,3,4)],string_to_colors('020304')) + self.assertEqual([(10,20,30)],string_to_colors('0a141e')) + + def test_two_colors(self): + self.assertEqual([(10,20,30),(40,50,60)],string_to_colors('0a141e28323c')) + + def test_incomplete_color(self): + # don't return anything if it's not a complete color + self.assertEqual([],string_to_colors('102')) + + +class TCCache(TestCase): + def test_empty(self): + c = Cache() + self.assertEqual(0,len(c)) + self.assertRaises(KeyError,c.__getitem__,'foo') + + def test_set_then_retrieve_blocks(self): + c = Cache() + b = [(0,0,0),(1,2,3)] + c['foo'] = b + self.assertEqual(b,c['foo']) + + def test_delitem(self): + c = Cache() + c['foo'] = '' + del c['foo'] + self.assert_('foo' not in c) + self.assertRaises(KeyError,c.__delitem__,'foo') + + def test_persistance(self): + DBNAME = op.join(self.tmpdir(), 'hstest.db') + c = Cache(DBNAME) + c['foo'] = [(1,2,3)] + del c + c = Cache(DBNAME) + self.assertEqual([(1,2,3)],c['foo']) + del c + os.remove(DBNAME) + + def test_filter(self): + c = Cache() + c['foo'] = '' + c['bar'] = '' + c['baz'] = '' + c.filter(lambda p:p != 'bar') #only 'bar' is removed + self.assertEqual(2,len(c)) + self.assert_('foo' in c) + self.assert_('baz' in c) + self.assert_('bar' not in c) + + def test_clear(self): + c = Cache() + c['foo'] = '' + c['bar'] = '' + c['baz'] = '' + c.clear() + self.assertEqual(0,len(c)) + self.assert_('foo' not in c) + self.assert_('baz' not in c) + self.assert_('bar' not in c) + + def test_corrupted_db(self): + dbname = op.join(self.tmpdir(), 'foo.db') + fp = open(dbname, 'w') + fp.write('invalid sqlite content') + fp.close() + c = Cache(dbname) # should not raise a DatabaseError + c['foo'] = [(1, 2, 3)] + del c + c = Cache(dbname) + self.assertEqual(c['foo'], [(1, 2, 3)]) + + def test_by_id(self): + # it's possible to use the cache by referring to the files by their row_id + c = Cache() + b = [(0,0,0),(1,2,3)] + c['foo'] = b + foo_id = c.get_id('foo') + self.assertEqual(c[foo_id], b) + + +class TCCacheSQLEscape(unittest.TestCase): + def test_contains(self): + c = Cache() + self.assert_("foo'bar" not in c) + + def test_getitem(self): + c = Cache() + self.assertRaises(KeyError, c.__getitem__, "foo'bar") + + def test_setitem(self): + c = Cache() + c["foo'bar"] = [] + + def test_delitem(self): + c = Cache() + c["foo'bar"] = [] + try: + del c["foo'bar"] + except KeyError: + self.fail() + + +class TCCacheThreaded(unittest.TestCase): + def test_access_cache(self): + def thread_run(): + try: + c['foo'] = [(1,2,3)] + except sqlite.ProgrammingError: + self.fail() + + c = Cache() + t = threading.Thread(target=thread_run) + t.start() + t.join() + self.assertEqual([(1,2,3)], c['foo']) + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/pe/qt/dupeguru/picture/matchbase.py b/pe/qt/dupeguru/picture/matchbase.py new file mode 100644 index 00000000..cf0d1e89 --- /dev/null +++ b/pe/qt/dupeguru/picture/matchbase.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python +""" +Unit Name: hs.picture._match +Created By: Virgil Dupras +Created On: 2007/02/25 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:02:48 +0200 (Thu, 28 May 2009) $ + $Revision: 4388 $ +Copyright 2007 Hardcoded Software (http://www.hardcoded.net) +""" +import logging +import multiprocessing +from Queue import Empty +from collections import defaultdict + +from hsutil import job +from hs.utils.misc import dedupe + +from dupeguru.engine import Match +from block import avgdiff, DifferentBlockCountError, NoBlocksError +from cache import Cache + +MIN_ITERATIONS = 3 + +def get_match(first,second,percentage): + if percentage < 0: + percentage = 0 + return Match(first,second,percentage) + +class MatchFactory(object): + cached_blocks = None + block_count_per_side = 15 + threshold = 75 + match_scaled = False + + def _do_getmatches(self, files, j): + raise NotImplementedError() + + def getmatches(self, files, j=job.nulljob): + # The MemoryError handlers in there use logging without first caring about whether or not + # there is enough memory left to carry on the operation because it is assumed that the + # MemoryError happens when trying to read an image file, which is freed from memory by the + # time that MemoryError is raised. + j = j.start_subjob([2, 8]) + logging.info('Preparing %d files' % len(files)) + prepared = self.prepare_files(files, j) + logging.info('Finished preparing %d files' % len(prepared)) + return self._do_getmatches(prepared, j) + + def prepare_files(self, files, j=job.nulljob): + prepared = [] # only files for which there was no error getting blocks + try: + for picture in j.iter_with_progress(files, 'Analyzed %d/%d pictures'): + picture.dimensions + picture.unicode_path = unicode(picture.path) + try: + if picture.unicode_path not in self.cached_blocks: + blocks = picture.get_blocks(self.block_count_per_side) + self.cached_blocks[picture.unicode_path] = blocks + prepared.append(picture) + except IOError as e: + logging.warning(unicode(e)) + except MemoryError: + logging.warning(u'Ran out of memory while reading %s of size %d' % (picture.unicode_path, picture.size)) + if picture.size < 10 * 1024 * 1024: # We're really running out of memory + raise + except MemoryError: + logging.warning('Ran out of memory while preparing files') + return prepared + + +def async_compare(ref_id, other_ids, dbname, threshold): + cache = Cache(dbname, threaded=False) + limit = 100 - threshold + ref_blocks = cache[ref_id] + pairs = cache.get_multiple(other_ids) + results = [] + for other_id, other_blocks in pairs: + try: + diff = avgdiff(ref_blocks, other_blocks, limit, MIN_ITERATIONS) + percentage = 100 - diff + except (DifferentBlockCountError, NoBlocksError): + percentage = 0 + if percentage >= threshold: + results.append((ref_id, other_id, percentage)) + cache.con.close() + return results + +class AsyncMatchFactory(MatchFactory): + def _do_getmatches(self, pictures, j): + def empty_out_queue(queue, into): + try: + while True: + into.append(queue.get(block=False)) + except Empty: + pass + + j = j.start_subjob([1, 8, 1], 'Preparing for matching') + cache = self.cached_blocks + id2picture = {} + dimensions2pictures = defaultdict(set) + for picture in pictures[:]: + try: + picture.cache_id = cache.get_id(picture.unicode_path) + id2picture[picture.cache_id] = picture + except ValueError: + pictures.remove(picture) + if not self.match_scaled: + dimensions2pictures[picture.dimensions].add(picture) + pool = multiprocessing.Pool() + async_results = [] + pictures_copy = set(pictures) + for ref in j.iter_with_progress(pictures): + others = pictures_copy if self.match_scaled else dimensions2pictures[ref.dimensions] + others.remove(ref) + if others: + cache_ids = [f.cache_id for f in others] + args = (ref.cache_id, cache_ids, self.cached_blocks.dbname, self.threshold) + async_results.append(pool.apply_async(async_compare, args)) + + matches = [] + for result in j.iter_with_progress(async_results, 'Matched %d/%d pictures'): + matches.extend(result.get()) + + result = [] + for ref_id, other_id, percentage in j.iter_with_progress(matches, 'Verified %d/%d matches', every=10): + ref = id2picture[ref_id] + other = id2picture[other_id] + if percentage == 100 and ref.md5 != other.md5: + percentage = 99 + if percentage >= self.threshold: + result.append(get_match(ref, other, percentage)) + return result + + +multiprocessing.freeze_support() \ No newline at end of file diff --git a/pe/qt/dupeguru/results.py b/pe/qt/dupeguru/results.py new file mode 100644 index 00000000..a7ded5c0 --- /dev/null +++ b/pe/qt/dupeguru/results.py @@ -0,0 +1,359 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.results +Created By: Virgil Dupras +Created On: 2006/02/23 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:33:32 +0200 (Thu, 28 May 2009) $ + $Revision: 4392 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import re +from xml.sax import handler, make_parser, SAXException +from xml.sax.saxutils import XMLGenerator +from xml.sax.xmlreader import AttributesImpl + +from . import engine +from hsutil.job import nulljob +from hsutil.markable import Markable +from hsutil.misc import flatten, cond, nonone +from hsutil.str import format_size +from hsutil.files import open_if_filename + +class Results(Markable): + #---Override + def __init__(self, data_module): + super(Results, self).__init__() + self.__groups = [] + self.__group_of_duplicate = {} + self.__groups_sort_descriptor = None # This is a tuple (key, asc) + self.__dupes = None + self.__dupes_sort_descriptor = None # This is a tuple (key, asc, delta) + self.__filters = None + self.__filtered_dupes = None + self.__filtered_groups = None + self.__recalculate_stats() + self.__marked_size = 0 + self.data = data_module + + def _did_mark(self, dupe): + self.__marked_size += dupe.size + + def _did_unmark(self, dupe): + self.__marked_size -= dupe.size + + def _get_markable_count(self): + return self.__total_count + + def _is_markable(self, dupe): + if dupe.is_ref: + return False + g = self.get_group_of_duplicate(dupe) + if not g: + return False + if dupe is g.ref: + return False + if self.__filtered_dupes and dupe not in self.__filtered_dupes: + return False + return True + + #---Private + def __get_dupe_list(self): + if self.__dupes is None: + self.__dupes = flatten(group.dupes for group in self.groups) + if self.__filtered_dupes: + self.__dupes = [dupe for dupe in self.__dupes if dupe in self.__filtered_dupes] + sd = self.__dupes_sort_descriptor + if sd: + self.sort_dupes(sd[0], sd[1], sd[2]) + return self.__dupes + + def __get_groups(self): + if self.__filtered_groups is None: + return self.__groups + else: + return self.__filtered_groups + + def __get_stat_line(self): + if self.__filtered_dupes is None: + mark_count = self.mark_count + marked_size = self.__marked_size + total_count = self.__total_count + total_size = self.__total_size + else: + mark_count = len([dupe for dupe in self.__filtered_dupes if self.is_marked(dupe)]) + marked_size = sum(dupe.size for dupe in self.__filtered_dupes if self.is_marked(dupe)) + total_count = len([dupe for dupe in self.__filtered_dupes if self.is_markable(dupe)]) + total_size = sum(dupe.size for dupe in self.__filtered_dupes if self.is_markable(dupe)) + if self.mark_inverted: + marked_size = self.__total_size - marked_size + result = '%d / %d (%s / %s) duplicates marked.' % ( + mark_count, + total_count, + format_size(marked_size, 2), + format_size(total_size, 2), + ) + if self.__filters: + result += ' filter: %s' % ' --> '.join(self.__filters) + return result + + def __recalculate_stats(self): + self.__total_size = 0 + self.__total_count = 0 + for group in self.groups: + markable = [dupe for dupe in group.dupes if self._is_markable(dupe)] + self.__total_count += len(markable) + self.__total_size += sum(dupe.size for dupe in markable) + + def __set_groups(self, new_groups): + self.mark_none() + self.__groups = new_groups + self.__group_of_duplicate = {} + for g in self.__groups: + for dupe in g: + self.__group_of_duplicate[dupe] = g + if not hasattr(dupe, 'is_ref'): + dupe.is_ref = False + old_filters = nonone(self.__filters, []) + self.apply_filter(None) + for filter_str in old_filters: + self.apply_filter(filter_str) + + #---Public + def apply_filter(self, filter_str): + ''' Applies a filter 'filter_str' to self.groups + + When you apply the filter, only dupes with the filename matching 'filter_str' will be in + in the results. To cancel the filter, just call apply_filter with 'filter_str' to None, + and the results will go back to normal. + + If call apply_filter on a filtered results, the filter will be applied + *on the filtered results*. + + 'filter_str' is a string containing a regexp to filter dupes with. + ''' + if not filter_str: + self.__filtered_dupes = None + self.__filtered_groups = None + self.__filters = None + else: + if not self.__filters: + self.__filters = [] + self.__filters.append(filter_str) + filter_re = re.compile(filter_str, re.IGNORECASE) + if self.__filtered_dupes is None: + self.__filtered_dupes = flatten(g[:] for g in self.groups) + self.__filtered_dupes = set(dupe for dupe in self.__filtered_dupes if filter_re.search(dupe.name)) + filtered_groups = set() + for dupe in self.__filtered_dupes: + filtered_groups.add(self.get_group_of_duplicate(dupe)) + self.__filtered_groups = list(filtered_groups) + self.__recalculate_stats() + sd = self.__groups_sort_descriptor + if sd: + self.sort_groups(sd[0], sd[1]) + self.__dupes = None + + def get_group_of_duplicate(self, dupe): + try: + return self.__group_of_duplicate[dupe] + except (TypeError, KeyError): + return None + + is_markable = _is_markable + + def load_from_xml(self, infile, get_file, j=nulljob): + self.apply_filter(None) + handler = _ResultsHandler(get_file) + parser = make_parser() + parser.setContentHandler(handler) + try: + infile, must_close = open_if_filename(infile) + except IOError: + return + BUFSIZE = 1024 * 1024 # 1mb buffer + infile.seek(0, 2) + j.start_job(infile.tell() // BUFSIZE) + infile.seek(0, 0) + try: + while True: + data = infile.read(BUFSIZE) + if not data: + break + parser.feed(data) + j.add_progress() + except SAXException: + return + self.groups = handler.groups + for dupe_file in handler.marked: + self.mark(dupe_file) + + def make_ref(self, dupe): + g = self.get_group_of_duplicate(dupe) + r = g.ref + self._remove_mark_flag(dupe) + g.switch_ref(dupe); + if not r.is_ref: + self.__total_count += 1 + self.__total_size += r.size + if not dupe.is_ref: + self.__total_count -= 1 + self.__total_size -= dupe.size + self.__dupes = None + + def perform_on_marked(self, func, remove_from_results): + problems = [] + for d in self.dupes: + if self.is_marked(d) and (not func(d)): + problems.append(d) + if remove_from_results: + to_remove = [d for d in self.dupes if self.is_marked(d) and (d not in problems)] + self.remove_duplicates(to_remove) + self.mark_none() + for d in problems: + self.mark(d) + return len(problems) + + def remove_duplicates(self, dupes): + '''Remove 'dupes' from their respective group, and remove the group is it ends up empty. + ''' + affected_groups = set() + for dupe in dupes: + group = self.get_group_of_duplicate(dupe) + if dupe not in group.dupes: + return + group.remove_dupe(dupe, False) + self._remove_mark_flag(dupe) + self.__total_count -= 1 + self.__total_size -= dupe.size + if not group: + self.__groups.remove(group) + if self.__filtered_groups: + self.__filtered_groups.remove(group) + else: + affected_groups.add(group) + for group in affected_groups: + group.clean_matches() + self.__dupes = None + + def save_to_xml(self, outfile, with_data=False): + self.apply_filter(None) + outfile, must_close = open_if_filename(outfile, 'wb') + writer = XMLGenerator(outfile, 'utf-8') + writer.startDocument() + empty_attrs = AttributesImpl({}) + writer.startElement('results', empty_attrs) + for g in self.groups: + writer.startElement('group', empty_attrs) + dupe2index = {} + for index, d in enumerate(g): + dupe2index[d] = index + try: + words = engine.unpack_fields(d.words) + except AttributeError: + words = () + attrs = AttributesImpl({ + 'path': unicode(d.path), + 'is_ref': cond(d.is_ref, 'y', 'n'), + 'words': ','.join(words), + 'marked': cond(self.is_marked(d), 'y', 'n') + }) + writer.startElement('file', attrs) + if with_data: + data_list = self.data.GetDisplayInfo(d, g) + for data in data_list: + attrs = AttributesImpl({ + 'value': data, + }) + writer.startElement('data', attrs) + writer.endElement('data') + writer.endElement('file') + for match in g.matches: + attrs = AttributesImpl({ + 'first': str(dupe2index[match.first]), + 'second': str(dupe2index[match.second]), + 'percentage': str(int(match.percentage)), + }) + writer.startElement('match', attrs) + writer.endElement('match') + writer.endElement('group') + writer.endElement('results') + writer.endDocument() + if must_close: + outfile.close() + + def sort_dupes(self, key, asc=True, delta=False): + if not self.__dupes: + self.__get_dupe_list() + self.__dupes.sort(key=lambda d: self.data.GetDupeSortKey(d, lambda: self.get_group_of_duplicate(d), key, delta)) + if not asc: + self.__dupes.reverse() + self.__dupes_sort_descriptor = (key,asc,delta) + + def sort_groups(self,key,asc=True): + self.groups.sort(key=lambda g: self.data.GetGroupSortKey(g, key)) + if not asc: + self.groups.reverse() + self.__groups_sort_descriptor = (key,asc) + + #---Properties + dupes = property(__get_dupe_list) + groups = property(__get_groups, __set_groups) + stat_line = property(__get_stat_line) + +class _ResultsHandler(handler.ContentHandler): + def __init__(self, get_file): + self.group = None + self.dupes = None + self.marked = set() + self.groups = [] + self.get_file = get_file + + def startElement(self, name, attrs): + if name == 'group': + self.group = engine.Group() + self.dupes = [] + return + if (name == 'file') and (self.group is not None): + if not (('path' in attrs) and ('words' in attrs)): + return + path = attrs['path'] + file = self.get_file(path) + if file is None: + return + file.words = attrs['words'].split(',') + file.is_ref = attrs.get('is_ref') == 'y' + self.dupes.append(file) + if attrs.get('marked') == 'y': + self.marked.add(file) + if (name == 'match') and (self.group is not None): + try: + first_file = self.dupes[int(attrs['first'])] + second_file = self.dupes[int(attrs['second'])] + percentage = int(attrs['percentage']) + self.group.add_match(engine.Match(first_file, second_file, percentage)) + except (IndexError, KeyError, ValueError): # Covers missing attr, non-int values and indexes out of bounds + pass + + def endElement(self, name): + def do_match(ref_file, other_files, group): + if not other_files: + return + for other_file in other_files: + group.add_match(engine.get_match(ref_file, other_file)) + do_match(other_files[0], other_files[1:], group) + + if name == 'group': + group = self.group + self.group = None + dupes = self.dupes + self.dupes = [] + if group is None: + return + if len(dupes) < 2: + return + if not group.matches: # elements not present, do it manually, without % + do_match(dupes[0], dupes[1:], group) + group.prioritize(lambda x: dupes.index(x)) + self.groups.append(group) + diff --git a/pe/qt/dupeguru/results_test.py b/pe/qt/dupeguru/results_test.py new file mode 100644 index 00000000..1e74efc6 --- /dev/null +++ b/pe/qt/dupeguru/results_test.py @@ -0,0 +1,742 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.tests.results +Created By: Virgil Dupras +Created On: 2006/02/23 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import unittest +import StringIO +import xml.dom.minidom +import os.path as op + +from hsutil.path import Path +from hsutil.testcase import TestCase +from hsutil.misc import first + +from . import engine_test +from . import data +from . import engine +from .results import * + +class NamedObject(engine_test.NamedObject): + size = 1 + path = property(lambda x:Path('basepath') + x.name) + is_ref = False + + def __nonzero__(self): + return False #Make sure that operations are made correctly when the bool value of files is false. + +# Returns a group set that looks like that: +# "foo bar" (1) +# "bar bleh" (1024) +# "foo bleh" (1) +# "ibabtu" (1) +# "ibabtu" (1) +def GetTestGroups(): + objects = [NamedObject("foo bar"),NamedObject("bar bleh"),NamedObject("foo bleh"),NamedObject("ibabtu"),NamedObject("ibabtu")] + objects[1].size = 1024 + matches = engine.MatchFactory().getmatches(objects) #we should have 5 matches + groups = engine.get_groups(matches) #We should have 2 groups + for g in groups: + g.prioritize(lambda x:objects.index(x)) #We want the dupes to be in the same order as the list is + groups.sort(key=len, reverse=True) # We want the group with 3 members to be first. + return (objects,matches,groups) + +class TCResultsEmpty(TestCase): + def setUp(self): + self.results = Results(data) + + def test_stat_line(self): + self.assertEqual("0 / 0 (0.00 B / 0.00 B) duplicates marked.",self.results.stat_line) + + def test_groups(self): + self.assertEqual(0,len(self.results.groups)) + + def test_get_group_of_duplicate(self): + self.assert_(self.results.get_group_of_duplicate('foo') is None) + + def test_save_to_xml(self): + f = StringIO.StringIO() + self.results.save_to_xml(f) + f.seek(0) + doc = xml.dom.minidom.parse(f) + root = doc.documentElement + self.assertEqual('results',root.nodeName) + + +class TCResultsWithSomeGroups(TestCase): + def setUp(self): + self.results = Results(data) + self.objects,self.matches,self.groups = GetTestGroups() + self.results.groups = self.groups + + def test_stat_line(self): + self.assertEqual("0 / 3 (0.00 B / 1.01 KB) duplicates marked.",self.results.stat_line) + + def test_groups(self): + self.assertEqual(2,len(self.results.groups)) + + def test_get_group_of_duplicate(self): + for o in self.objects: + g = self.results.get_group_of_duplicate(o) + self.assert_(isinstance(g, engine.Group)) + self.assert_(o in g) + self.assert_(self.results.get_group_of_duplicate(self.groups[0]) is None) + + def test_remove_duplicates(self): + g1,g2 = self.results.groups + self.results.remove_duplicates([g1.dupes[0]]) + self.assertEqual(2,len(g1)) + self.assert_(g1 in self.results.groups) + self.results.remove_duplicates([g1.ref]) + self.assertEqual(2,len(g1)) + self.assert_(g1 in self.results.groups) + self.results.remove_duplicates([g1.dupes[0]]) + self.assertEqual(0,len(g1)) + self.assert_(g1 not in self.results.groups) + self.results.remove_duplicates([g2.dupes[0]]) + self.assertEqual(0,len(g2)) + self.assert_(g2 not in self.results.groups) + self.assertEqual(0,len(self.results.groups)) + + def test_remove_duplicates_with_ref_files(self): + g1,g2 = self.results.groups + self.objects[0].is_ref = True + self.objects[1].is_ref = True + self.results.remove_duplicates([self.objects[2]]) + self.assertEqual(0,len(g1)) + self.assert_(g1 not in self.results.groups) + + def test_make_ref(self): + g = self.results.groups[0] + d = g.dupes[0] + self.results.make_ref(d) + self.assert_(d is g.ref) + + def test_sort_groups(self): + self.results.make_ref(self.objects[1]) #We want to make the 1024 sized object to go ref. + g1,g2 = self.groups + self.results.sort_groups(2) #2 is the key for size + self.assert_(self.results.groups[0] is g2) + self.assert_(self.results.groups[1] is g1) + self.results.sort_groups(2,False) + self.assert_(self.results.groups[0] is g1) + self.assert_(self.results.groups[1] is g2) + + def test_set_groups_when_sorted(self): + self.results.make_ref(self.objects[1]) #We want to make the 1024 sized object to go ref. + self.results.sort_groups(2) + objects,matches,groups = GetTestGroups() + g1,g2 = groups + g1.switch_ref(objects[1]) + self.results.groups = groups + self.assert_(self.results.groups[0] is g2) + self.assert_(self.results.groups[1] is g1) + + def test_get_dupe_list(self): + self.assertEqual([self.objects[1],self.objects[2],self.objects[4]],self.results.dupes) + + def test_dupe_list_is_cached(self): + self.assert_(self.results.dupes is self.results.dupes) + + def test_dupe_list_cache_is_invalidated_when_needed(self): + o1,o2,o3,o4,o5 = self.objects + self.assertEqual([o2,o3,o5],self.results.dupes) + self.results.make_ref(o2) + self.assertEqual([o1,o3,o5],self.results.dupes) + objects,matches,groups = GetTestGroups() + o1,o2,o3,o4,o5 = objects + self.results.groups = groups + self.assertEqual([o2,o3,o5],self.results.dupes) + + def test_dupe_list_sort(self): + o1,o2,o3,o4,o5 = self.objects + o1.size = 5 + o2.size = 4 + o3.size = 3 + o4.size = 2 + o5.size = 1 + self.results.sort_dupes(2) + self.assertEqual([o5,o3,o2],self.results.dupes) + self.results.sort_dupes(2,False) + self.assertEqual([o2,o3,o5],self.results.dupes) + + def test_dupe_list_remember_sort(self): + o1,o2,o3,o4,o5 = self.objects + o1.size = 5 + o2.size = 4 + o3.size = 3 + o4.size = 2 + o5.size = 1 + self.results.sort_dupes(2) + self.results.make_ref(o2) + self.assertEqual([o5,o3,o1],self.results.dupes) + + def test_dupe_list_sort_delta_values(self): + o1,o2,o3,o4,o5 = self.objects + o1.size = 10 + o2.size = 2 #-8 + o3.size = 3 #-7 + o4.size = 20 + o5.size = 1 #-19 + self.results.sort_dupes(2,delta=True) + self.assertEqual([o5,o2,o3],self.results.dupes) + + def test_sort_empty_list(self): + #There was an infinite loop when sorting an empty list. + r = Results(data) + r.sort_dupes(0) + self.assertEqual([],r.dupes) + + def test_dupe_list_update_on_remove_duplicates(self): + o1,o2,o3,o4,o5 = self.objects + self.assertEqual(3,len(self.results.dupes)) + self.results.remove_duplicates([o2]) + self.assertEqual(2,len(self.results.dupes)) + + +class TCResultsMarkings(TestCase): + def setUp(self): + self.results = Results(data) + self.objects,self.matches,self.groups = GetTestGroups() + self.results.groups = self.groups + + def test_stat_line(self): + self.assertEqual("0 / 3 (0.00 B / 1.01 KB) duplicates marked.",self.results.stat_line) + self.results.mark(self.objects[1]) + self.assertEqual("1 / 3 (1.00 KB / 1.01 KB) duplicates marked.",self.results.stat_line) + self.results.mark_invert() + self.assertEqual("2 / 3 (2.00 B / 1.01 KB) duplicates marked.",self.results.stat_line) + self.results.mark_invert() + self.results.unmark(self.objects[1]) + self.results.mark(self.objects[2]) + self.results.mark(self.objects[4]) + self.assertEqual("2 / 3 (2.00 B / 1.01 KB) duplicates marked.",self.results.stat_line) + self.results.mark(self.objects[0]) #this is a ref, it can't be counted + self.assertEqual("2 / 3 (2.00 B / 1.01 KB) duplicates marked.",self.results.stat_line) + self.results.groups = self.groups + self.assertEqual("0 / 3 (0.00 B / 1.01 KB) duplicates marked.",self.results.stat_line) + + def test_with_ref_duplicate(self): + self.objects[1].is_ref = True + self.results.groups = self.groups + self.assert_(not self.results.mark(self.objects[1])) + self.results.mark(self.objects[2]) + self.assertEqual("1 / 2 (1.00 B / 2.00 B) duplicates marked.",self.results.stat_line) + + def test_perform_on_marked(self): + def log_object(o): + log.append(o) + return True + + log = [] + self.results.mark_all() + self.results.perform_on_marked(log_object,False) + self.assert_(self.objects[1] in log) + self.assert_(self.objects[2] in log) + self.assert_(self.objects[4] in log) + self.assertEqual(3,len(log)) + log = [] + self.results.mark_none() + self.results.mark(self.objects[4]) + self.results.perform_on_marked(log_object,True) + self.assertEqual(1,len(log)) + self.assert_(self.objects[4] in log) + self.assertEqual(1,len(self.results.groups)) + + def test_perform_on_marked_with_problems(self): + def log_object(o): + log.append(o) + return o is not self.objects[1] + + log = [] + self.results.mark_all() + self.assert_(self.results.is_marked(self.objects[1])) + self.assertEqual(1,self.results.perform_on_marked(log_object, True)) + self.assertEqual(3,len(log)) + self.assertEqual(1,len(self.results.groups)) + self.assertEqual(2,len(self.results.groups[0])) + self.assert_(self.objects[1] in self.results.groups[0]) + self.assert_(not self.results.is_marked(self.objects[2])) + self.assert_(self.results.is_marked(self.objects[1])) + + def test_perform_on_marked_with_ref(self): + def log_object(o): + log.append(o) + return True + + log = [] + self.objects[0].is_ref = True + self.objects[1].is_ref = True + self.results.mark_all() + self.results.perform_on_marked(log_object,True) + self.assert_(self.objects[1] not in log) + self.assert_(self.objects[2] in log) + self.assert_(self.objects[4] in log) + self.assertEqual(2,len(log)) + self.assertEqual(0,len(self.results.groups)) + + def test_perform_on_marked_remove_objects_only_at_the_end(self): + def check_groups(o): + self.assertEqual(3,len(g1)) + self.assertEqual(2,len(g2)) + return True + + g1,g2 = self.results.groups + self.results.mark_all() + self.results.perform_on_marked(check_groups,True) + self.assertEqual(0,len(g1)) + self.assertEqual(0,len(g2)) + self.assertEqual(0,len(self.results.groups)) + + def test_remove_duplicates(self): + g1 = self.results.groups[0] + g2 = self.results.groups[1] + self.results.mark(g1.dupes[0]) + self.assertEqual("1 / 3 (1.00 KB / 1.01 KB) duplicates marked.",self.results.stat_line) + self.results.remove_duplicates([g1.dupes[1]]) + self.assertEqual("1 / 2 (1.00 KB / 1.01 KB) duplicates marked.",self.results.stat_line) + self.results.remove_duplicates([g1.dupes[0]]) + self.assertEqual("0 / 1 (0.00 B / 1.00 B) duplicates marked.",self.results.stat_line) + + def test_make_ref(self): + g = self.results.groups[0] + d = g.dupes[0] + self.results.mark(d) + self.assertEqual("1 / 3 (1.00 KB / 1.01 KB) duplicates marked.",self.results.stat_line) + self.results.make_ref(d) + self.assertEqual("0 / 3 (0.00 B / 3.00 B) duplicates marked.",self.results.stat_line) + self.results.make_ref(d) + self.assertEqual("0 / 3 (0.00 B / 3.00 B) duplicates marked.",self.results.stat_line) + + def test_SaveXML(self): + self.results.mark(self.objects[1]) + self.results.mark_invert() + f = StringIO.StringIO() + self.results.save_to_xml(f) + f.seek(0) + doc = xml.dom.minidom.parse(f) + root = doc.documentElement + g1,g2 = root.getElementsByTagName('group') + d1,d2,d3 = g1.getElementsByTagName('file') + self.assertEqual('n',d1.getAttributeNode('marked').nodeValue) + self.assertEqual('n',d2.getAttributeNode('marked').nodeValue) + self.assertEqual('y',d3.getAttributeNode('marked').nodeValue) + d1,d2 = g2.getElementsByTagName('file') + self.assertEqual('n',d1.getAttributeNode('marked').nodeValue) + self.assertEqual('y',d2.getAttributeNode('marked').nodeValue) + + def test_LoadXML(self): + def get_file(path): + return [f for f in self.objects if str(f.path) == path][0] + + self.objects[4].name = 'ibabtu 2' #we can't have 2 files with the same path + self.results.mark(self.objects[1]) + self.results.mark_invert() + f = StringIO.StringIO() + self.results.save_to_xml(f) + f.seek(0) + r = Results(data) + r.load_from_xml(f,get_file) + self.assert_(not r.is_marked(self.objects[0])) + self.assert_(not r.is_marked(self.objects[1])) + self.assert_(r.is_marked(self.objects[2])) + self.assert_(not r.is_marked(self.objects[3])) + self.assert_(r.is_marked(self.objects[4])) + + +class TCResultsXML(TestCase): + def setUp(self): + self.results = Results(data) + self.objects, self.matches, self.groups = GetTestGroups() + self.results.groups = self.groups + + def get_file(self, path): # use this as a callback for load_from_xml + return [o for o in self.objects if o.path == path][0] + + def test_save_to_xml(self): + self.objects[0].is_ref = True + self.objects[0].words = [['foo','bar']] + f = StringIO.StringIO() + self.results.save_to_xml(f) + f.seek(0) + doc = xml.dom.minidom.parse(f) + root = doc.documentElement + self.assertEqual('results',root.nodeName) + children = [c for c in root.childNodes if c.localName] + self.assertEqual(2,len(children)) + self.assertEqual(2,len([c for c in children if c.nodeName == 'group'])) + g1,g2 = children + children = [c for c in g1.childNodes if c.localName] + self.assertEqual(6,len(children)) + self.assertEqual(3,len([c for c in children if c.nodeName == 'file'])) + self.assertEqual(3,len([c for c in children if c.nodeName == 'match'])) + d1,d2,d3 = [c for c in children if c.nodeName == 'file'] + self.assertEqual(op.join('basepath','foo bar'),d1.getAttributeNode('path').nodeValue) + self.assertEqual(op.join('basepath','bar bleh'),d2.getAttributeNode('path').nodeValue) + self.assertEqual(op.join('basepath','foo bleh'),d3.getAttributeNode('path').nodeValue) + self.assertEqual('y',d1.getAttributeNode('is_ref').nodeValue) + self.assertEqual('n',d2.getAttributeNode('is_ref').nodeValue) + self.assertEqual('n',d3.getAttributeNode('is_ref').nodeValue) + self.assertEqual('foo,bar',d1.getAttributeNode('words').nodeValue) + self.assertEqual('bar,bleh',d2.getAttributeNode('words').nodeValue) + self.assertEqual('foo,bleh',d3.getAttributeNode('words').nodeValue) + children = [c for c in g2.childNodes if c.localName] + self.assertEqual(3,len(children)) + self.assertEqual(2,len([c for c in children if c.nodeName == 'file'])) + self.assertEqual(1,len([c for c in children if c.nodeName == 'match'])) + d1,d2 = [c for c in children if c.nodeName == 'file'] + self.assertEqual(op.join('basepath','ibabtu'),d1.getAttributeNode('path').nodeValue) + self.assertEqual(op.join('basepath','ibabtu'),d2.getAttributeNode('path').nodeValue) + self.assertEqual('n',d1.getAttributeNode('is_ref').nodeValue) + self.assertEqual('n',d2.getAttributeNode('is_ref').nodeValue) + self.assertEqual('ibabtu',d1.getAttributeNode('words').nodeValue) + self.assertEqual('ibabtu',d2.getAttributeNode('words').nodeValue) + + def test_save_to_xml_with_columns(self): + class FakeDataModule: + def GetDisplayInfo(self,dupe,group): + return [str(dupe.size),dupe.foo.upper()] + + for i,object in enumerate(self.objects): + object.size = i + object.foo = u'bar\u00e9' + f = StringIO.StringIO() + self.results.data = FakeDataModule() + self.results.save_to_xml(f,True) + f.seek(0) + doc = xml.dom.minidom.parse(f) + root = doc.documentElement + g1,g2 = root.getElementsByTagName('group') + d1,d2,d3 = g1.getElementsByTagName('file') + d4,d5 = g2.getElementsByTagName('file') + self.assertEqual('0',d1.getElementsByTagName('data')[0].getAttribute('value')) + self.assertEqual(u'BAR\u00c9',d1.getElementsByTagName('data')[1].getAttribute('value')) #\u00c9 is upper of \u00e9 + self.assertEqual('1',d2.getElementsByTagName('data')[0].getAttribute('value')) + self.assertEqual('2',d3.getElementsByTagName('data')[0].getAttribute('value')) + self.assertEqual('3',d4.getElementsByTagName('data')[0].getAttribute('value')) + self.assertEqual('4',d5.getElementsByTagName('data')[0].getAttribute('value')) + + def test_LoadXML(self): + def get_file(path): + return [f for f in self.objects if str(f.path) == path][0] + + self.objects[0].is_ref = True + self.objects[4].name = 'ibabtu 2' #we can't have 2 files with the same path + f = StringIO.StringIO() + self.results.save_to_xml(f) + f.seek(0) + r = Results(data) + r.load_from_xml(f,get_file) + self.assertEqual(2,len(r.groups)) + g1,g2 = r.groups + self.assertEqual(3,len(g1)) + self.assert_(g1[0].is_ref) + self.assert_(not g1[1].is_ref) + self.assert_(not g1[2].is_ref) + self.assert_(g1[0] is self.objects[0]) + self.assert_(g1[1] is self.objects[1]) + self.assert_(g1[2] is self.objects[2]) + self.assertEqual(['foo','bar'],g1[0].words) + self.assertEqual(['bar','bleh'],g1[1].words) + self.assertEqual(['foo','bleh'],g1[2].words) + self.assertEqual(2,len(g2)) + self.assert_(not g2[0].is_ref) + self.assert_(not g2[1].is_ref) + self.assert_(g2[0] is self.objects[3]) + self.assert_(g2[1] is self.objects[4]) + self.assertEqual(['ibabtu'],g2[0].words) + self.assertEqual(['ibabtu'],g2[1].words) + + def test_LoadXML_with_filename(self): + def get_file(path): + return [f for f in self.objects if str(f.path) == path][0] + + filename = op.join(self.tmpdir(), 'dupeguru_results.xml') + self.objects[4].name = 'ibabtu 2' #we can't have 2 files with the same path + self.results.save_to_xml(filename) + r = Results(data) + r.load_from_xml(filename,get_file) + self.assertEqual(2,len(r.groups)) + + def test_LoadXML_with_some_files_that_dont_exist_anymore(self): + def get_file(path): + if path.endswith('ibabtu 2'): + return None + return [f for f in self.objects if str(f.path) == path][0] + + self.objects[4].name = 'ibabtu 2' #we can't have 2 files with the same path + f = StringIO.StringIO() + self.results.save_to_xml(f) + f.seek(0) + r = Results(data) + r.load_from_xml(f,get_file) + self.assertEqual(1,len(r.groups)) + self.assertEqual(3,len(r.groups[0])) + + def test_LoadXML_missing_attributes_and_bogus_elements(self): + def get_file(path): + return [f for f in self.objects if str(f.path) == path][0] + + doc = xml.dom.minidom.Document() + root = doc.appendChild(doc.createElement('foobar')) #The root element shouldn't matter, really. + group_node = root.appendChild(doc.createElement('group')) + dupe_node = group_node.appendChild(doc.createElement('file')) #Perfectly correct file + dupe_node.setAttribute('path',op.join('basepath','foo bar')) + dupe_node.setAttribute('is_ref','y') + dupe_node.setAttribute('words','foo,bar') + dupe_node = group_node.appendChild(doc.createElement('file')) #is_ref missing, default to 'n' + dupe_node.setAttribute('path',op.join('basepath','foo bleh')) + dupe_node.setAttribute('words','foo,bleh') + dupe_node = group_node.appendChild(doc.createElement('file')) #words are missing, invalid. + dupe_node.setAttribute('path',op.join('basepath','bar bleh')) + dupe_node = group_node.appendChild(doc.createElement('file')) #path is missing, invalid. + dupe_node.setAttribute('words','foo,bleh') + dupe_node = group_node.appendChild(doc.createElement('foobar')) #Invalid element name + dupe_node.setAttribute('path',op.join('basepath','bar bleh')) + dupe_node.setAttribute('is_ref','y') + dupe_node.setAttribute('words','bar,bleh') + match_node = group_node.appendChild(doc.createElement('match')) # match pointing to a bad index + match_node.setAttribute('first', '42') + match_node.setAttribute('second', '45') + match_node = group_node.appendChild(doc.createElement('match')) # match with missing attrs + match_node = group_node.appendChild(doc.createElement('match')) # match with non-int values + match_node.setAttribute('first', 'foo') + match_node.setAttribute('second', 'bar') + match_node.setAttribute('percentage', 'baz') + group_node = root.appendChild(doc.createElement('foobar')) #invalid group + group_node = root.appendChild(doc.createElement('group')) #empty group + f = StringIO.StringIO() + doc.writexml(f,'\t','\t','\n',encoding='utf-8') + f.seek(0) + r = Results(data) + r.load_from_xml(f,get_file) + self.assertEqual(1,len(r.groups)) + self.assertEqual(2,len(r.groups[0])) + + def test_xml_non_ascii(self): + def get_file(path): + if path == op.join('basepath',u'\xe9foo bar'): + return objects[0] + if path == op.join('basepath',u'bar bleh'): + return objects[1] + + objects = [NamedObject(u"\xe9foo bar",True),NamedObject("bar bleh",True)] + matches = engine.MatchFactory().getmatches(objects) #we should have 5 matches + groups = engine.get_groups(matches) #We should have 2 groups + for g in groups: + g.prioritize(lambda x:objects.index(x)) #We want the dupes to be in the same order as the list is + results = Results(data) + results.groups = groups + f = StringIO.StringIO() + results.save_to_xml(f) + f.seek(0) + r = Results(data) + r.load_from_xml(f,get_file) + g = r.groups[0] + self.assertEqual(u"\xe9foo bar",g[0].name) + self.assertEqual(['efoo','bar'],g[0].words) + + def test_load_invalid_xml(self): + f = StringIO.StringIO() + f.write(' len(ref.path) + + def GetDupeGroups(self, files, j=job.nulljob): + j = j.start_subjob([8, 2]) + for f in [f for f in files if not hasattr(f, 'is_ref')]: + f.is_ref = False + if self.size_threshold: + files = [f for f in files if f.size >= self.size_threshold] + logging.info('Getting matches') + if self.match_factory is None: + matches = self._getmatches(files, j) + else: + matches = self.match_factory.getmatches(files, j) + logging.info('Found %d matches' % len(matches)) + if not self.mix_file_kind: + j.set_progress(100, 'Removing false matches') + matches = [m for m in matches if get_file_ext(m.first.name) == get_file_ext(m.second.name)] + if self.ignore_list: + j = j.start_subjob(2) + iter_matches = j.iter_with_progress(matches, 'Processed %d/%d matches against the ignore list') + matches = [m for m in iter_matches + if not self.ignore_list.AreIgnored(unicode(m.first.path), unicode(m.second.path))] + matched_files = dedupe([m.first for m in matches] + [m.second for m in matches]) + if self.scan_type in (SCAN_TYPE_CONTENT, SCAN_TYPE_CONTENT_AUDIO): + md5attrname = 'md5partial' if self.scan_type == SCAN_TYPE_CONTENT_AUDIO else 'md5' + md5 = lambda f: getattr(f, md5attrname) + j = j.start_subjob(2) + for matched_file in j.iter_with_progress(matched_files, 'Analyzed %d/%d matching files'): + md5(matched_file) + j.set_progress(100, 'Removing false matches') + matches = [m for m in matches if md5(m.first) == md5(m.second)] + words_for_content = ['--'] # We compared md5. No words were involved. + for m in matches: + m.first.words = words_for_content + m.second.words = words_for_content + logging.info('Grouping matches') + groups = engine.get_groups(matches, j) + groups = [g for g in groups if any(not f.is_ref for f in g)] + logging.info('Created %d groups' % len(groups)) + j.set_progress(100, 'Doing group prioritization') + for g in groups: + g.prioritize(self._key_func, self._tie_breaker) + matched_files = dedupe([m.first for m in matches] + [m.second for m in matches]) + self.discarded_file_count = len(matched_files) - sum(len(g) for g in groups) + return groups + + match_factory = None + match_similar_words = False + min_match_percentage = 80 + mix_file_kind = True + scan_type = SCAN_TYPE_FILENAME + scanned_tags = set(['artist', 'title']) + size_threshold = 0 + word_weighting = False + +class ScannerME(Scanner): # Scanner for Music Edition + @staticmethod + def _key_func(dupe): + return (not dupe.is_ref, -dupe.bitrate, -dupe.size) + diff --git a/pe/qt/dupeguru/scanner_test.py b/pe/qt/dupeguru/scanner_test.py new file mode 100644 index 00000000..89ad1417 --- /dev/null +++ b/pe/qt/dupeguru/scanner_test.py @@ -0,0 +1,468 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.tests.scanner +Created By: Virgil Dupras +Created On: 2006/03/03 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import unittest + +from hsutil import job +from hsutil.path import Path +from hsutil.testcase import TestCase + +from .engine import getwords, Match +from .ignore import IgnoreList +from .scanner import * + +class NamedObject(object): + def __init__(self, name="foobar", size=1): + self.name = name + self.size = size + self.path = Path('') + self.words = getwords(name) + + +no = NamedObject + +class TCScanner(TestCase): + def test_empty(self): + s = Scanner() + r = s.GetDupeGroups([]) + self.assertEqual([],r) + + def test_default_settings(self): + s = Scanner() + self.assertEqual(80,s.min_match_percentage) + self.assertEqual(SCAN_TYPE_FILENAME,s.scan_type) + self.assertEqual(True,s.mix_file_kind) + self.assertEqual(False,s.word_weighting) + self.assertEqual(False,s.match_similar_words) + self.assert_(isinstance(s.ignore_list,IgnoreList)) + + def test_simple_with_default_settings(self): + s = Scanner() + f = [no('foo bar'),no('foo bar'),no('foo bleh')] + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + g = r[0] + #'foo bleh' cannot be in the group because the default min match % is 80 + self.assertEqual(2,len(g)) + self.assert_(g.ref in f[:2]) + self.assert_(g.dupes[0] in f[:2]) + + def test_simple_with_lower_min_match(self): + s = Scanner() + s.min_match_percentage = 50 + f = [no('foo bar'),no('foo bar'),no('foo bleh')] + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + g = r[0] + self.assertEqual(3,len(g)) + + def test_trim_all_ref_groups(self): + s = Scanner() + f = [no('foo'),no('foo'),no('bar'),no('bar')] + f[2].is_ref = True + f[3].is_ref = True + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + + def test_priorize(self): + s = Scanner() + f = [no('foo'),no('foo'),no('bar'),no('bar')] + f[1].size = 2 + f[2].size = 3 + f[3].is_ref = True + r = s.GetDupeGroups(f) + g1,g2 = r + self.assert_(f[1] in (g1.ref,g2.ref)) + self.assert_(f[0] in (g1.dupes[0],g2.dupes[0])) + self.assert_(f[3] in (g1.ref,g2.ref)) + self.assert_(f[2] in (g1.dupes[0],g2.dupes[0])) + + def test_content_scan(self): + s = Scanner() + s.scan_type = SCAN_TYPE_CONTENT + f = [no('foo'), no('bar'), no('bleh')] + f[0].md5 = 'foobar' + f[1].md5 = 'foobar' + f[2].md5 = 'bleh' + r = s.GetDupeGroups(f) + self.assertEqual(len(r), 1) + self.assertEqual(len(r[0]), 2) + self.assertEqual(s.discarded_file_count, 0) # don't count the different md5 as discarded! + + def test_content_scan_compare_sizes_first(self): + class MyFile(no): + def get_md5(file): + self.fail() + md5 = property(get_md5) + + s = Scanner() + s.scan_type = SCAN_TYPE_CONTENT + f = [MyFile('foo',1),MyFile('bar',2)] + self.assertEqual(0,len(s.GetDupeGroups(f))) + + def test_min_match_perc_doesnt_matter_for_content_scan(self): + s = Scanner() + s.scan_type = SCAN_TYPE_CONTENT + f = [no('foo'),no('bar'),no('bleh')] + f[0].md5 = 'foobar' + f[1].md5 = 'foobar' + f[2].md5 = 'bleh' + s.min_match_percentage = 101 + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + self.assertEqual(2,len(r[0])) + s.min_match_percentage = 0 + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + self.assertEqual(2,len(r[0])) + + def test_content_scan_puts_md5_in_words_at_the_end(self): + s = Scanner() + s.scan_type = SCAN_TYPE_CONTENT + f = [no('foo'),no('bar')] + f[0].md5 = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f' + f[1].md5 = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f' + r = s.GetDupeGroups(f) + g = r[0] + self.assertEqual(['--'],g.ref.words) + self.assertEqual(['--'],g.dupes[0].words) + + def test_extension_is_not_counted_in_filename_scan(self): + s = Scanner() + s.min_match_percentage = 100 + f = [no('foo.bar'),no('foo.bleh')] + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + self.assertEqual(2,len(r[0])) + + def test_job(self): + def do_progress(progress,desc=''): + log.append(progress) + return True + s = Scanner() + log = [] + f = [no('foo bar'),no('foo bar'),no('foo bleh')] + r = s.GetDupeGroups(f, job.Job(1,do_progress)) + self.assertEqual(0,log[0]) + self.assertEqual(100,log[-1]) + + def test_mix_file_kind(self): + s = Scanner() + s.mix_file_kind = False + f = [no('foo.1'),no('foo.2')] + r = s.GetDupeGroups(f) + self.assertEqual(0,len(r)) + + def test_word_weighting(self): + s = Scanner() + s.min_match_percentage = 75 + s.word_weighting = True + f = [no('foo bar'),no('foo bar bleh')] + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + g = r[0] + m = g.get_match_of(g.dupes[0]) + self.assertEqual(75,m.percentage) # 16 letters, 12 matching + + def test_similar_words(self): + s = Scanner() + s.match_similar_words = True + f = [no('The White Stripes'),no('The Whites Stripe'),no('Limp Bizkit'),no('Limp Bizkitt')] + r = s.GetDupeGroups(f) + self.assertEqual(2,len(r)) + + def test_fields(self): + s = Scanner() + s.scan_type = SCAN_TYPE_FIELDS + f = [no('The White Stripes - Little Ghost'),no('The White Stripes - Little Acorn')] + r = s.GetDupeGroups(f) + self.assertEqual(0,len(r)) + + def test_fields_no_order(self): + s = Scanner() + s.scan_type = SCAN_TYPE_FIELDS_NO_ORDER + f = [no('The White Stripes - Little Ghost'),no('Little Ghost - The White Stripes')] + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + + def test_tag_scan(self): + s = Scanner() + s.scan_type = SCAN_TYPE_TAG + o1 = no('foo') + o2 = no('bar') + o1.artist = 'The White Stripes' + o1.title = 'The Air Near My Fingers' + o2.artist = 'The White Stripes' + o2.title = 'The Air Near My Fingers' + r = s.GetDupeGroups([o1,o2]) + self.assertEqual(1,len(r)) + + def test_tag_with_album_scan(self): + s = Scanner() + s.scan_type = SCAN_TYPE_TAG_WITH_ALBUM + o1 = no('foo') + o2 = no('bar') + o3 = no('bleh') + o1.artist = 'The White Stripes' + o1.title = 'The Air Near My Fingers' + o1.album = 'Elephant' + o2.artist = 'The White Stripes' + o2.title = 'The Air Near My Fingers' + o2.album = 'Elephant' + o3.artist = 'The White Stripes' + o3.title = 'The Air Near My Fingers' + o3.album = 'foobar' + r = s.GetDupeGroups([o1,o2,o3]) + self.assertEqual(1,len(r)) + + def test_that_dash_in_tags_dont_create_new_fields(self): + s = Scanner() + s.scan_type = SCAN_TYPE_TAG_WITH_ALBUM + s.min_match_percentage = 50 + o1 = no('foo') + o2 = no('bar') + o1.artist = 'The White Stripes - a' + o1.title = 'The Air Near My Fingers - a' + o1.album = 'Elephant - a' + o2.artist = 'The White Stripes - b' + o2.title = 'The Air Near My Fingers - b' + o2.album = 'Elephant - b' + r = s.GetDupeGroups([o1,o2]) + self.assertEqual(1,len(r)) + + def test_tag_scan_with_different_scanned(self): + s = Scanner() + s.scan_type = SCAN_TYPE_TAG + s.scanned_tags = set(['track', 'year']) + o1 = no('foo') + o2 = no('bar') + o1.artist = 'The White Stripes' + o1.title = 'some title' + o1.track = 'foo' + o1.year = 'bar' + o2.artist = 'The White Stripes' + o2.title = 'another title' + o2.track = 'foo' + o2.year = 'bar' + r = s.GetDupeGroups([o1, o2]) + self.assertEqual(1, len(r)) + + def test_tag_scan_only_scans_existing_tags(self): + s = Scanner() + s.scan_type = SCAN_TYPE_TAG + s.scanned_tags = set(['artist', 'foo']) + o1 = no('foo') + o2 = no('bar') + o1.artist = 'The White Stripes' + o1.foo = 'foo' + o2.artist = 'The White Stripes' + o2.foo = 'bar' + r = s.GetDupeGroups([o1, o2]) + self.assertEqual(1, len(r)) # Because 'foo' is not scanned, they match + + def test_tag_scan_converts_to_str(self): + s = Scanner() + s.scan_type = SCAN_TYPE_TAG + s.scanned_tags = set(['track']) + o1 = no('foo') + o2 = no('bar') + o1.track = 42 + o2.track = 42 + try: + r = s.GetDupeGroups([o1, o2]) + except TypeError: + self.fail() + self.assertEqual(1, len(r)) + + def test_tag_scan_non_ascii(self): + s = Scanner() + s.scan_type = SCAN_TYPE_TAG + s.scanned_tags = set(['title']) + o1 = no('foo') + o2 = no('bar') + o1.title = u'foobar\u00e9' + o2.title = u'foobar\u00e9' + try: + r = s.GetDupeGroups([o1, o2]) + except UnicodeEncodeError: + self.fail() + self.assertEqual(1, len(r)) + + def test_audio_content_scan(self): + s = Scanner() + s.scan_type = SCAN_TYPE_CONTENT_AUDIO + f = [no('foo'),no('bar'),no('bleh')] + f[0].md5 = 'foo' + f[1].md5 = 'bar' + f[2].md5 = 'bleh' + f[0].md5partial = 'foo' + f[1].md5partial = 'foo' + f[2].md5partial = 'bleh' + f[0].audiosize = 1 + f[1].audiosize = 1 + f[2].audiosize = 1 + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + self.assertEqual(2,len(r[0])) + + def test_audio_content_scan_compare_sizes_first(self): + class MyFile(no): + def get_md5(file): + self.fail() + md5partial = property(get_md5) + + s = Scanner() + s.scan_type = SCAN_TYPE_CONTENT_AUDIO + f = [MyFile('foo'),MyFile('bar')] + f[0].audiosize = 1 + f[1].audiosize = 2 + self.assertEqual(0,len(s.GetDupeGroups(f))) + + def test_ignore_list(self): + s = Scanner() + f1 = no('foobar') + f2 = no('foobar') + f3 = no('foobar') + f1.path = Path('dir1/foobar') + f2.path = Path('dir2/foobar') + f3.path = Path('dir3/foobar') + s.ignore_list.Ignore(str(f1.path),str(f2.path)) + s.ignore_list.Ignore(str(f1.path),str(f3.path)) + r = s.GetDupeGroups([f1,f2,f3]) + self.assertEqual(1,len(r)) + g = r[0] + self.assertEqual(1,len(g.dupes)) + self.assert_(f1 not in g) + self.assert_(f2 in g) + self.assert_(f3 in g) + # Ignored matches are not counted as discarded + self.assertEqual(s.discarded_file_count, 0) + + def test_ignore_list_checks_for_unicode(self): + #scanner was calling path_str for ignore list checks. Since the Path changes, it must + #be unicode(path) + s = Scanner() + f1 = no('foobar') + f2 = no('foobar') + f3 = no('foobar') + f1.path = Path(u'foo1\u00e9') + f2.path = Path(u'foo2\u00e9') + f3.path = Path(u'foo3\u00e9') + s.ignore_list.Ignore(unicode(f1.path),unicode(f2.path)) + s.ignore_list.Ignore(unicode(f1.path),unicode(f3.path)) + r = s.GetDupeGroups([f1,f2,f3]) + self.assertEqual(1,len(r)) + g = r[0] + self.assertEqual(1,len(g.dupes)) + self.assert_(f1 not in g) + self.assert_(f2 in g) + self.assert_(f3 in g) + + def test_custom_match_factory(self): + class MatchFactory(object): + def getmatches(self,objects,j=None): + return [Match(objects[0], objects[1], 420)] + + + s = Scanner() + s.match_factory = MatchFactory() + o1,o2 = no('foo'),no('bar') + groups = s.GetDupeGroups([o1,o2]) + self.assertEqual(1,len(groups)) + g = groups[0] + self.assertEqual(2,len(g)) + g.switch_ref(o1) + m = g.get_match_of(o2) + self.assertEqual((o1,o2,420),m) + + def test_file_evaluates_to_false(self): + # A very wrong way to use any() was added at some point, causing resulting group list + # to be empty. + class FalseNamedObject(NamedObject): + def __nonzero__(self): + return False + + + s = Scanner() + f1 = FalseNamedObject('foobar') + f2 = FalseNamedObject('foobar') + r = s.GetDupeGroups([f1,f2]) + self.assertEqual(1,len(r)) + + def test_size_threshold(self): + # Only file equal or higher than the size_threshold in size are scanned + s = Scanner() + f1 = no('foo', 1) + f2 = no('foo', 2) + f3 = no('foo', 3) + s.size_threshold = 2 + groups = s.GetDupeGroups([f1,f2,f3]) + self.assertEqual(len(groups), 1) + [group] = groups + self.assertEqual(len(group), 2) + self.assertTrue(f1 not in group) + self.assertTrue(f2 in group) + self.assertTrue(f3 in group) + + def test_tie_breaker_path_deepness(self): + # If there is a tie in prioritization, path deepness is used as a tie breaker + s = Scanner() + o1, o2 = no('foo'), no('foo') + o1.path = Path('foo') + o2.path = Path('foo/bar') + [group] = s.GetDupeGroups([o1, o2]) + self.assertTrue(group.ref is o2) + + def test_tie_breaker_copy(self): + # if copy is in the words used (even if it has a deeper path), it becomes a dupe + s = Scanner() + o1, o2 = no('foo bar Copy'), no('foo bar') + o1.path = Path('deeper/path') + o2.path = Path('foo') + [group] = s.GetDupeGroups([o1, o2]) + self.assertTrue(group.ref is o2) + + def test_tie_breaker_same_name_plus_digit(self): + # if ref has the same words as dupe, but has some just one extra word which is a digit, it + # becomes a dupe + s = Scanner() + o1, o2 = no('foo bar 42'), no('foo bar') + o1.path = Path('deeper/path') + o2.path = Path('foo') + [group] = s.GetDupeGroups([o1, o2]) + self.assertTrue(group.ref is o2) + + def test_partial_group_match(self): + # Count the number od discarded matches (when a file doesn't match all other dupes of the + # group) in Scanner.discarded_file_count + s = Scanner() + o1, o2, o3 = no('a b'), no('a'), no('b') + s.min_match_percentage = 50 + [group] = s.GetDupeGroups([o1, o2, o3]) + self.assertEqual(len(group), 2) + self.assertTrue(o1 in group) + self.assertTrue(o2 in group) + self.assertTrue(o3 not in group) + self.assertEqual(s.discarded_file_count, 1) + + +class TCScannerME(TestCase): + def test_priorize(self): + # in ScannerME, bitrate goes first (right after is_ref) in priorization + s = ScannerME() + o1, o2 = no('foo'), no('foo') + o1.bitrate = 1 + o2.bitrate = 2 + [group] = s.GetDupeGroups([o1, o2]) + self.assertTrue(group.ref is o2) + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/pe/qt/gen.py b/pe/qt/gen.py new file mode 100644 index 00000000..8bec8d5b --- /dev/null +++ b/pe/qt/gen.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python +# Unit Name: gen +# Created By: Virgil Dupras +# Created On: 2009-05-22 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import os +import os.path as op + +def print_and_do(cmd): + print cmd + os.system(cmd) + +def move(src, dst): + if not op.exists(src): + return + if op.exists(dst): + os.remove(dst) + print 'Moving %s --> %s' % (src, dst) + os.rename(src, dst) + +os.chdir('dupeguru') +print_and_do('python gen.py') +os.chdir('..') + +os.chdir('base') +print_and_do('python gen.py') +os.chdir('..') + +os.chdir(op.join('modules', 'block')) +os.system('python setup.py build_ext --inplace') +move(op.join('modules', 'block', '_block.so'), op.join('picture', '_block.so')) +move(op.join('modules', 'block', '_block.pyd'), op.join('picture', '_block.pyd')) +os.chdir(op.join('..', '..')) + +print_and_do("pyuic4 details_dialog.ui > details_dialog_ui.py") +print_and_do("pyuic4 preferences_dialog.ui > preferences_dialog_ui.py") + +os.chdir('help') +print_and_do('python gen.py') +os.chdir('..') \ No newline at end of file diff --git a/pe/qt/help/changelog.yaml b/pe/qt/help/changelog.yaml new file mode 100644 index 00000000..f387c334 --- /dev/null +++ b/pe/qt/help/changelog.yaml @@ -0,0 +1,174 @@ +- date: 2009-05-27 + version: 1.7.2 + description: | + * Fixed a bug causing '.jpeg' files not to be scanned. + * Fixed a bug causing a GUI freeze at the beginning of a scan with a lot of files. + * Fixed a bug that sometimes caused a crash when an action was cancelled, and then started again. + * Improved scanning speed. +- date: 2009-05-26 + version: 1.7.1 + description: | + * Fixed a bug causing the "Match Scaled" preference to be inverted. +- date: 2009-05-20 + version: 1.7.0 + description: | + * Fixed the bug from 1.6.0 preventing PowerPC macs from running the application. + * Converted the Windows GUI to Qt, thus enabling multiprocessing and making the scanning process + faster. +- date: 2009-03-24 + description: "* **Improved** scanning speed, mainly on OS X where all cores of the\ + \ CPU are now used.\r\n* **Fixed** an occasional crash caused by permission issues.\r\ + \n* **Fixed** a bug where the \"X discarded\" notice would show a too large number\ + \ of discarded duplicates." + version: 1.6.0 +- date: 2008-09-10 + description: "
    \n\t\t\t\t\t\t
  • Added a notice in the status bar when\ + \ matches were discarded during the scan.
  • \n\t\t\t\t\t\t
  • Improved\ + \ duplicate prioritization (smartly chooses which file you will keep).
  • \n\t\ + \t\t\t\t\t
  • Improved scan progress feedback.
  • \n\t\t\t\t\t\t
  • Improved\ + \ responsiveness of the user interface for certain actions.
  • \n\t\t \ + \
" + version: 1.5.0 +- date: 2008-07-28 + description: "
    \n\t\t\t\t\t\t
  • Improved iPhoto compatibility on Mac\ + \ OS X.
  • \n\t\t\t\t\t\t
  • Improved the speed of results loading and\ + \ saving.
  • \n\t\t\t\t\t\t
  • Fixed a crash sometimes occurring during\ + \ duplicate deletion.
  • \n\t\t
" + version: 1.4.2 +- date: 2008-04-12 + description: "
    \n\t\t\t\t\t\t
  • Improved iPhoto Library loading feedback\ + \ on Mac OS X.
  • \n\t\t\t\t\t\t
  • Fixed the directory selection dialog.\ + \ Bundles can be selected again on Mac OS X.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ \"Clear Ignore List\" crash in Windows.
  • \n\t\t
" + version: 1.4.1 +- date: 2008-02-20 + description: "
    \n\t\t\t\t\t\t
  • Added iPhoto Library support on Mac OS\ + \ X.
  • \n\t\t\t\t\t\t
  • Fixed occasional crashes when scanning corrupted\ + \ pictures.
  • \n\t\t
" + version: 1.4.0 +- date: 2008-02-20 + description: "
    \n\t\t\t\t\t\t
  • Added iPhoto Library support on Mac OS\ + \ X.
  • \n\t\t\t\t\t\t
  • Fixed occasional crashes when scanning corrupted\ + \ pictures.
  • \n\t\t
" + version: 1.4.0 +- date: 2008-01-12 + description: "
    \n\t\t\t\t\t\t
  • Improved scan, delete and move speed\ + \ in situations where there were a lot of duplicates.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ occasional crashes when moving a lot of files at once.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ an issue sometimes preventing the application from starting at all.
  • \n\t\ + \t
" + version: 1.3.4 +- date: 2007-12-03 + description: "
    \n\t\t\t\t\t\t
  • Improved the handling of low memory situations.
  • \n\ + \t\t\t\t\t\t
  • Improved the directory panel. The \"Remove\" button changes\ + \ to \"Put Back\" when an excluded directory is selected.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ the directory selection dialog. iPhoto '08 library files can now be selected.
  • \n\ + \t\t
" + version: 1.3.3 +- date: 2007-11-24 + description: "
    \n\t\t\t\t\t\t
  • Added the \"Remove empty folders\" option.
  • \n\ + \t\t\t\t\t\t
  • Fixed results load/save issues.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ occasional status bar inaccuracies when the results are filtered.
  • \n\t\t\ + \
" + version: 1.3.2 +- date: 2007-10-21 + description: "
    \n\t\t\t\t\t\t
  • Improved results loading speed.
  • \n\ + \t\t\t\t\t\t
  • Improved details panel's picture loading (made it asynchronous).
  • \n\ + \t\t\t\t\t\t
  • Fixed a bug where the stats line at the bottom would sometimes\ + \ go confused while having a filter active.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ a bug under Windows where some duplicate markings would be lost.
  • \n\t\t\ + \
" + version: 1.3.1 +- date: 2007-09-22 + description: "
    \n\t\t\t\t\t\t
  • Added post scan filtering.
  • \n\t\t\ + \t\t\t\t
  • Fixed issues with the rename feature under Windows
  • \n\t\ + \t\t\t\t\t
  • Fixed some user interface annoyances under Windows
  • \n\ + \t\t
" + version: 1.3.0 +- date: 2007-05-19 + description: "
    \n\t\t\t\t\t\t
  • Improved UI responsiveness (using threads)\ + \ under Mac OS X.
  • \n\t\t\t\t\t\t
  • Improved result load/save speed\ + \ and memory usage.
  • \n\t\t
" + version: 1.2.1 +- date: 2007-03-17 + description: "
    \n\t\t\t\t\t\t
  • Changed the picture decoding libraries\ + \ for both Mac OS X and Windows. The Mac OS X version uses the Core Graphics library\ + \ and the Windows version uses the .NET framework imaging capabilities. This results\ + \ in much faster scans. As a bonus, the Mac OS X version of dupeGuru PE now supports\ + \ RAW images.
  • \n\t\t
" + version: 1.2.0 +- date: 2007-02-11 + description: "
    \n\t\t\t\t\t\t
  • Added Re-orderable columns. In fact,\ + \ I re-added the feature which was lost in the C# conversion in 2.4.0 (Windows).
  • \n\ + \t\t\t\t\t\t
  • Fixed a bug with all the Delete/Move/Copy actions with\ + \ certain kinds of files.
  • \n\t\t
" + version: 1.1.6 +- date: 2007-01-11 + description: "
    \n\t\t\t\t\t\t
  • Fixed a bug with the Move action.
  • \n\ + \t\t
" + version: 1.1.5 +- date: 2007-01-09 + description: "
    \n\t\t\t\t\t\t
  • Fixed a \"ghosting\" bug. Dupes deleted\ + \ by dupeGuru would sometimes come back in subsequent scans (Windows).
  • \n\t\ + \t\t\t\t\t
  • Fixed bugs sometimes making dupeGuru crash when marking a\ + \ dupe (Windows).
  • \n\t\t\t\t\t\t
  • Fixed some minor visual glitches\ + \ (Windows).
  • \n\t\t
" + version: 1.1.4 +- date: 2006-12-23 + description: "
    \n\t\t\t\t\t\t
  • Improved the caching system. This makes\ + \ duplicate scans significantly faster.
  • \n\t\t\t\t\t\t
  • Improved\ + \ the rename file dialog to exclude the extension from the original selection\ + \ (so when you start typing your new filename, it doesn't overwrite it) (Windows).
  • \n\ + \t\t\t\t\t\t
  • Changed some menu key shortcuts that created conflicts\ + \ (Windows).
  • \n\t\t\t\t\t\t
  • Fixed a bug preventing files from \"\ + reference\" directories to be displayed in blue in the results (Windows).
  • \n\ + \t\t\t\t\t\t
  • Fixed a bug preventing some files to be sent to the recycle\ + \ bin (Windows).
  • \n\t\t\t\t\t\t
  • Fixed a bug with the \"Remove\"\ + \ button of the directories panel (Windows).
  • \n\t\t\t\t\t\t
  • Fixed\ + \ a bug in the packaging preventing certain Windows configurations to start dupeGuru\ + \ at all.
  • \n\t\t
" + version: 1.1.3 +- date: 2006-11-18 + description: "
    \n\t\t\t\t\t\t
  • Fixed a bug with directory states.
  • \n\ + \t\t
" + version: 1.1.2 +- date: 2006-11-17 + description: "
    \n\t\t\t\t\t\t
  • Fixed a bug causing the ignore list not\ + \ to be saved.
  • \n\t\t\t\t\t\t
  • Fixed a bug with selection under Power\ + \ Marker mode.
  • \n\t\t
" + version: 1.1.1 +- date: 2006-11-15 + description: "
    \n\t\t\t\t\t\t
  • Changed the Windows interface. It is\ + \ now .NET based.
  • \n\t\t\t\t\t\t
  • Added an auto-update feature to\ + \ the windows version.
  • \n\t\t\t\t\t\t
  • Changed the way power marking\ + \ works. It is now a mode instead of a separate window.
  • \n\t\t\t\t\t\t
  • Changed\ + \ the \"Size (MB)\" column for a \"Size (KB)\" column. The values are now \"ceiled\"\ + \ instead of rounded. Therefore, a size \"0\" is now really 0 bytes, not just\ + \ a value too small to be rounded up. It is also the case for delta values.
  • \n\ + \t\t\t\t\t\t
  • Fixed a bug sometimes making delete and move operations\ + \ stall.
  • \n\t\t
" + version: 1.1.0 +- date: 2006-10-12 + description: "
    \n\t\t\t\t\t\t
  • Added an auto-update feature in the Mac\ + \ OS X version (with Sparkle).
  • \n\t\t \t
  • Fixed a bug\ + \ sometimes causing inaccuracies of the Match %.
  • \n\t\t
" + version: 1.0.5 +- date: 2006-09-21 + description: "
    \n\t\t \t
  • Fixed a bug with the cache system.
  • \n\ + \t\t
" + version: 1.0.4 +- date: 2006-09-15 + description: "
    \n\t\t\t\t\t\t
  • Added the ability to search for scaled\ + \ duplicates.
  • \n\t\t\t\t\t\t
  • Added a cache system for faster scans.
  • \n\ + \t\t \t
  • Improved speed of the scanning engine.
  • \n\t\t\ + \
" + version: 1.0.3 +- date: 2006-09-11 + description: "
    \n\t\t \t
  • Improved speed of the scanning\ + \ engine.
  • \n\t\t\t\t\t\t
  • Improved the display of pictures in the\ + \ details panel (Windows).
  • \n\t\t
" + version: 1.0.2 +- date: 2006-09-08 + description: "
    \n\t\t \t
  • Initial release.
  • \n\t\t \ + \
" + version: 1.0.0 diff --git a/pe/qt/help/gen.py b/pe/qt/help/gen.py new file mode 100644 index 00000000..8ed33e4e --- /dev/null +++ b/pe/qt/help/gen.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python +# Unit Name: +# Created By: Virgil Dupras +# Created On: 2009-05-24 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import os + +from web import generate_help + +generate_help.main('.', 'dupeguru_pe_help', force_render=True) diff --git a/pe/qt/help/skeleton/hardcoded.css b/pe/qt/help/skeleton/hardcoded.css new file mode 100644 index 00000000..a3b17c5b --- /dev/null +++ b/pe/qt/help/skeleton/hardcoded.css @@ -0,0 +1,409 @@ +/***************************************************** + General settings +*****************************************************/ + +BODY +{ + background-color:white; +} + +BODY,A,P,UL,TABLE,TR,TD +{ + font-family:Tahoma,Arial,sans-serif; + font-size:10pt; + color: #4477AA;/*darker than 5588bb for the sake of the eyes*/ +} + +/***************************************************** + "A" settings +*****************************************************/ + +A +{ + color: #ae322b; + text-decoration:underline; + font-weight:bold; +} + +A.glossaryword {color:#A0A0A0;} + +A.noline +{ + text-decoration: none; +} + + +/***************************************************** + Menu and mainframe settings +*****************************************************/ + +.maincontainer +{ + display:block; + margin-left:7%; + margin-right:7%; + padding-left:5px; + padding-right:0px; + border-color:#CCCCCC; + border-style:solid; + border-width:2px; + border-right-width:0px; + border-bottom-width:0px; + border-top-color:#ae322b; + vertical-align:top; +} + +TD.menuframe +{ + width:30%; +} + +.menu +{ + margin:4px 4px 4px 4px; + margin-top: 16pt; + border-color:gray; + border-width:1px; + border-style:dotted; + padding-top:10pt; + padding-bottom:10pt; + padding-right:6pt; +} + +.submenu +{ + list-style-type: none; + margin-left:26pt; + margin-top:0pt; + margin-bottom:0pt; + padding-left:0pt; +} + +A.menuitem,A.menuitem_selected +{ + font-size:14pt; + font-family:Tahoma,Arial,sans-serif; + font-weight:normal; + padding-left:10pt; + color:#5588bb; + margin-right:2pt; + margin-left:4pt; + text-decoration:none; +} + +A.menuitem_selected +{ + font-weight:bold; +} + +A.submenuitem +{ + font-family:Tahoma,Arial,sans-serif; + font-weight:normal; + color:#5588bb; + text-decoration:none; +} + +.titleline +{ + border-width:3px; + border-style:solid; + border-left-width:0px; + border-right-width:0px; + border-top-width:0px; + border-color:#CCCCCC; + margin-left:28pt; + margin-right:2pt; + line-height:1px; + padding-top:0px; + margin-top:0px; + display:block; +} + +.titledescrip +{ + text-align:left; + display:block; + margin-left:26pt; + color:#ae322b; +} + +.mainlogo +{ + display:block; + margin-left:8%; + margin-top:4pt; + margin-bottom:4pt; +} + +/***************************************************** + IMG settings +*****************************************************/ + +IMG +{ + border-style:none; +} + +IMG.smallbutton +{ + margin-right: 20px; + float:none; +} + +IMG.floating +{ + float:left; + margin-right: 4pt; + margin-bottom: 4pt; +} + +IMG.lefticon +{ + vertical-align: middle; + padding-right: 2pt; +} + +IMG.righticon +{ + vertical-align: middle; + padding-left: 2pt; +} + +/***************************************************** + TABLE settings +*****************************************************/ + +TABLE +{ + border-style:none; +} + +TABLE.box +{ + width: 90%; + margin-left:5%; +} + +TABLE.centered +{ + margin-left: auto; + margin-right: auto; +} + +TABLE.hardcoded +{ + background-color: #225588; + margin-left: auto; + margin-right: auto; + width: 90%; +} + +TR { background-color: transparent; } + +TABLE.hardcoded TR { background-color: white } + +TABLE.hardcoded TR.header +{ + font-weight: bold; + color: black; + background-color: #C8D6E5; +} + +TABLE.hardcoded TR.header TD {color:black;} + +TABLE.hardcoded TD { padding-left: 2pt; } + +TD.minimelem { + padding-right:0px; + padding-left:0px; + text-align:center; +} + +TD.rightelem +{ + text-align:right; + /*padding-left:0pt;*/ + padding-right: 2pt; + width: 17%; +} + +/***************************************************** + P settings +*****************************************************/ + +p,.sub{text-align:justify;} +.centered{text-align:center;} +.sub +{ + padding-left: 16pt; + padding-right:16pt; +} + +.Note, .ContactInfo +{ + border-color: #ae322b; + border-width: 1pt; + border-style: dashed; + text-align:justify; + padding: 2pt 2pt 2pt 2pt; + margin-bottom:4pt; + margin-top:8pt; + list-style-position:inside; +} + +.ContactInfo +{ + width:60%; + margin-left:5%; +} + +.NewsItem +{ + border-color:#ae322b; + border-style: solid; + border-right:none; + border-top:none; + border-left:none; + border-bottom-width:1px; + text-align:justify; + padding-left:4pt; + padding-right:4pt; + padding-bottom:8pt; +} + +/***************************************************** + Lists settings +*****************************************************/ +UL.plain +{ + list-style-type: none; + padding-left:0px; + margin-left:0px; +} + +LI.plain +{ + list-style-type: none; +} + +LI.section +{ + padding-top: 6pt; +} + +UL.longtext LI +{ + border-color: #ae322b; + border-width:0px; + border-top-width:1px; + border-style:solid; + margin-top:12px; +} + +/* + with UL.longtext LI, there can be anything between + the UL and the LI, and it will still make the + lontext thing, I must break it with this hack +*/ +UL.longtext UL LI +{ + border-style:none; + margin-top:2px; +} + + +/***************************************************** + Titles settings +*****************************************************/ + +H1,H2,H3 +{ + font-family:"Courier New",monospace; + color:#5588bb; +} + +H1 +{ + font-size:18pt; + color: #ae322b; + border-color: #70A0CF; + border-width: 1pt; + border-style: solid; + margin-top: 16pt; + margin-left: 5%; + margin-right: 5%; + padding-top: 2pt; + padding-bottom:2pt; + text-align: center; +} + +H2 +{ + border-color: #ae322b; + border-bottom-width: 2px; + border-top-width: 0pt; + border-left-width: 2px; + border-right-width: 0pt; + border-bottom-color: #cccccc; + border-style: solid; + margin-top: 16pt; + margin-left: 0pt; + margin-right: 0pt; + padding-bottom:3pt; + padding-left:5pt; + text-align: left; + font-size:16pt; +} + +H3 +{ + display:block; + color:#ae322b; + border-color: #70A0CF; + border-bottom-width: 2px; + border-top-width: 0pt; + border-left-width: 0pt; + border-right-width: 0pt; + border-style: dashed; + margin-top: 12pt; + margin-left: 0pt; + margin-bottom: 4pt; + width:auto; + padding-bottom:3pt; + padding-right:2pt; + padding-left:2pt; + text-align: left; + font-weight:bold; +} + + +/***************************************************** + Misc. classes +*****************************************************/ +.longtext:first-letter {font-size: 150%} + +.price, .loweredprice, .specialprice {font-weight:bold;} + +.loweredprice {text-decoration:line-through} + +.specialprice {color:red} + +form +{ + margin:0px; +} + +.program_summary +{ + float:right; + margin: 32pt; + margin-top:0pt; + margin-bottom:0pt; +} + +.screenshot +{ + float:left; + margin: 8pt; +} \ No newline at end of file diff --git a/pe/qt/help/skeleton/images/hs_title.png b/pe/qt/help/skeleton/images/hs_title.png new file mode 100644 index 00000000..07bd89c6 Binary files /dev/null and b/pe/qt/help/skeleton/images/hs_title.png differ diff --git a/pe/qt/help/templates/base_dg.mako b/pe/qt/help/templates/base_dg.mako new file mode 100644 index 00000000..7767c49f --- /dev/null +++ b/pe/qt/help/templates/base_dg.mako @@ -0,0 +1,14 @@ +<%inherit file="/base_help.mako"/> +${next.body()} + +<%def name="menu()"><% +self.menuitem('intro.htm', 'Introduction', 'Introduction to dupeGuru') +self.menuitem('quick_start.htm', 'Quick Start', 'Quickly get into the action') +self.menuitem('directories.htm', 'Directories', 'Managing dupeGuru directories') +self.menuitem('preferences.htm', 'Preferences', 'Setting dupeGuru preferences') +self.menuitem('results.htm', 'Results', 'Time to delete these duplicates!') +self.menuitem('power_marker.htm', 'Power Marker', 'Take control of your duplicates') +self.menuitem('faq.htm', 'F.A.Q.', 'Frequently Asked Questions') +self.menuitem('versions.htm', 'Version History', 'Changes dupeGuru went through') +self.menuitem('credits.htm', 'Credits', 'People who contributed to dupeGuru') +%> \ No newline at end of file diff --git a/pe/qt/help/templates/credits.mako b/pe/qt/help/templates/credits.mako new file mode 100644 index 00000000..9de91bd2 --- /dev/null +++ b/pe/qt/help/templates/credits.mako @@ -0,0 +1,25 @@ +## -*- coding: utf-8 -*- +<%! + title = 'Credits' + selected_menu_item = 'Credits' +%> +<%inherit file="/base_dg.mako"/> +Below is the list of people who contributed, directly or indirectly to dupeGuru. + +${self.credit('Virgil Dupras', 'Developer', "That's me, Hardcoded Software founder", 'www.hardcoded.net', 'hsoft@hardcoded.net')} + +${self.credit(u'Jérôme Cantin', u'Icon designer', u"Icons in dupeGuru are from him")} + +${self.credit('Python', 'Programming language', "The bestest of the bests", 'www.python.org')} + +${self.credit('PyObjC', 'Python-to-Cocoa bridge', "Used for the Mac OS X version", 'pyobjc.sourceforge.net')} + +${self.credit('PyQt', 'Python-to-Qt bridge', "Used for the Windows version", 'www.riverbankcomputing.co.uk')} + +${self.credit('Qt', 'GUI Toolkit', "Used for the Windows version", 'www.qtsoftware.com')} + +${self.credit('Sparkle', 'Auto-update library', "Used for the Mac OS X version", 'andymatuschak.org/pages/sparkle')} + +${self.credit('Python Imaging Library', 'Picture analyzer', "Used for the Windows version", 'www.pythonware.com/products/pil/')} + +${self.credit('You', 'dupeGuru user', "What would I do without you?")} diff --git a/pe/qt/help/templates/directories.mako b/pe/qt/help/templates/directories.mako new file mode 100644 index 00000000..e75b47bd --- /dev/null +++ b/pe/qt/help/templates/directories.mako @@ -0,0 +1,24 @@ +<%! + title = 'Directories' + selected_menu_item = 'Directories' +%> +<%inherit file="/base_dg.mako"/> + +There is a panel in dupeGuru called **Directories**. You can open it by clicking on the **Directories** button. This directory contains the list of the directories that will be scanned when you click on **Start Scanning**. + +This panel is quite straightforward to use. If you want to add a directory, click on **Add**. If you added directories before, a popup menu with a list of recent directories you added will pop. You can click on one of them to add it directly to your list. If you click on the first item of the popup menu, **Add New Directory...**, you will be prompted for a directory to add. If you never added a directory, no menu will pop and you will directly be prompted for a new directory to add. + +To remove a directory, select the directory to remove and click on **Remove**. If a subdirectory is selected when you click remove, the selected directory will be set to **excluded** state (see below) instead of being removed. + +Directory states +----- + +Every directory can be in one of these 3 states: + +* **Normal:** Duplicates found in these directories can be deleted. +* **Reference:** Duplicates found in this directory **cannot** be deleted. Files in reference directories will be in a blue color in the results. +* **Excluded:** Files in this directory will not be included in the scan. + +The default state of a directory is, of course, **Normal**. You can use **Reference** state for a directory if you want to be sure that you won't delete any file from it. + +When you set the state of a directory, all subdirectories of this directory automatically inherit this state unless you explicitly set a subdirectory's state. diff --git a/pe/qt/help/templates/faq.mako b/pe/qt/help/templates/faq.mako new file mode 100644 index 00000000..1c4e998f --- /dev/null +++ b/pe/qt/help/templates/faq.mako @@ -0,0 +1,64 @@ +<%! + title = 'dupeGuru F.A.Q.' + selected_menu_item = 'F.A.Q.' +%> +<%inherit file="/base_dg.mako"/> + +<%text filter="md"> +### What is dupeGuru PE? + +dupeGuru Picture Edition (PE for short) is a tool to find duplicate pictures on your computer. Not only can it find exact matches, but it can also find duplicates among pictures of different kind (PNG, JPG, GIF etc..) and quality. + +### What makes it better than other duplicate scanners? + +The scanning engine is extremely flexible. You can tweak it to really get the kind of results you want. You can read more about dupeGuru tweaking option at the [Preferences page](preferences.htm). + +### How safe is it to use dupeGuru PE? + +Very safe. dupeGuru has been designed to make sure you don't delete files you didn't mean to delete. First, there is the reference directory system that lets you define directories where you absolutely **don't** want dupeGuru to let you delete files there, and then there is the group reference system that makes sure that you will **always** keep at least one member of the duplicate group. + +### What are the demo limitations of dupeGuru PE? + +In demo mode, you can only perform actions (delete/copy/move) on 10 duplicates per session. + +### The mark box of a file I want to delete is disabled. What must I do? + +You cannot mark the reference (The first file) of a duplicate group. However, what you can do is to promote a duplicate file to reference. Thus, if a file you want to mark is reference, select a duplicate file in the group that you want to promote to reference, and click on **Actions-->Make Selected Reference**. If the reference file is from a reference directory (filename written in blue letters), you cannot remove it from the reference position. + +### I have a directory from which I really don't want to delete files. + +If you want to be sure that dupeGuru will never delete file from a particular directory, just open the **Directories panel**, select that directory, and set its state to **Reference**. + +### What is this '(X discarded)' notice in the status bar? + +In some cases, some matches are not included in the final results for security reasons. Let me use an example. We have 3 file: A, B and C. We scan them using a low filter hardness. The scanner determines that A matches with B, A matches with C, but B does **not** match with C. Here, dupeGuru has kind of a problem. It cannot create a duplicate group with A, B and C in it because not all files in the group would match together. It could create 2 groups: one A-B group and then one A-C group, but it will not, for security reasons. Lets think about it: If B doesn't match with C, it probably means that either B, C or both are not actually duplicates. If there would be 2 groups (A-B and A-C), you would end up delete both B and C. And if one of them is not a duplicate, that is really not what you want to do, right? So what dupeGuru does in a case like this is to discard the A-C match (and adds a notice in the status bar). Thus, if you delete B and re-run a scan, you will have a A-C match in your next results. + +### I want to mark all files from a specific directory. What can I do? + +Enable the [Power Marker](power_marker.htm) mode and click on the Directory column to sort your duplicates by Directory. It will then be easy for you to select all duplicates from the same directory, and then press Space to mark all selected duplicates. + +### I want to remove all files that are more than 300 KB away from their reference file. What can I do? + +* Enable the [Power Marker](power_marker.htm) mode. +* Enable the **Delta Values** mode. +* Click on the "Size" column to sort the results by size. +* Select all duplicates below -300. +* Click on **Remove Selected from Results**. +* Select all duplicates over 300. +* Click on **Remove Selected from Results**. + +### I want to make my latest modified files reference files. What can I do? + +* Enable the [Power Marker](power_marker.htm) mode. +* Enable the **Delta Values** mode. +* Click on the "Modification" column to sort the results by modification date. +* Click on the "Modification" column again to reverse the sort order (see Power Marker page to know why). +* Select all duplicates over 0. +* Click on **Make Selected Reference**. + +### I want to mark all duplicates containing the word "copy". How do I do that? + +* **Windows**: Click on **Actions --> Apply Filter**, then type "copy", then click OK. +* **Mac OS X**: Type "copy" in the "Filter" field in the toolbar. +* Click on **Mark --> Mark All**. + \ No newline at end of file diff --git a/pe/qt/help/templates/intro.mako b/pe/qt/help/templates/intro.mako new file mode 100644 index 00000000..51d058c9 --- /dev/null +++ b/pe/qt/help/templates/intro.mako @@ -0,0 +1,13 @@ +<%! + title = 'Introduction to dupeGuru PE' + selected_menu_item = 'introduction' +%> +<%inherit file="/base_dg.mako"/> + +dupeGuru Picture Edition (PE for short) is a tool to find duplicate pictures on your computer. Not only can it find exact matches, but it can also find duplicates among pictures of different kind (PNG, JPG, GIF etc..) and quality. + +Although dupeGuru can easily be used without documentation, reading this file will help you to master it. If you are looking for guidance for your first duplicate scan, you can take a look at the [Quick Start](quick_start.htm) section. + +It is a good idea to keep dupeGuru PE updated. You can download the latest version on the [dupeGuru PE homepage](http://www.hardcoded.net/dupeguru_pe/). + +<%def name="meta()"> diff --git a/pe/qt/help/templates/power_marker.mako b/pe/qt/help/templates/power_marker.mako new file mode 100644 index 00000000..26078f3d --- /dev/null +++ b/pe/qt/help/templates/power_marker.mako @@ -0,0 +1,33 @@ +<%! + title = 'Power Marker' + selected_menu_item = 'Power Marker' +%> +<%inherit file="/base_dg.mako"/> + +You will probably not use the Power Marker feature very often, but if you get into a situation where you need it, you will be pretty happy that this feature exists. + +What is it? +----- + +When the Power Marker mode is enabled, the duplicates are shown without their respective reference file. You can select, mark and sort this list, just like in normal mode. + +So, what is it for? +----- + +The dupeGuru results, when in normal mode, are sorted according to duplicate groups' **reference file**. This means that if you want, for example, to mark all duplicates with the "exe" extension, you cannot just sort the results by "Kind" to have all exe duplicates together because a group can be composed of more than one kind of files. That is where Power Marker comes into play. To mark all your "exe" duplicates, you just have to: + +* Enable the Power marker mode. +* Add the "Kind" column with the "Columns" menu. +* Click on that "Kind" column to sort the list by kind. +* Locate the first duplicate with a "exe" kind. +* Select it. +* Scroll down the list to locate the last duplicate with a "exe" kind. +* Hold Shift and click on it. +* Press Space to mark all selected duplicates. + +Power Marker and delta values +----- + +The Power Marker unveil its true power when you use it with the **Delta Values** switch turned on. When you turn it on, relative values will be displayed instead of absolute ones. So if, for example, you want to remove from your results all duplicates that are more than 300 KB away from their reference, you could sort the Power Marker by Size, select all duplicates under -300 in the Size column, delete them, and then do the same for duplicates over 300 at the bottom of the list. + +You could also use it to change the reference priority of your duplicate list. When you make a fresh scan, if there are no reference directories, the reference file of every group is the biggest file. If you want to change that, for example, to the latest modification time, you can sort the Power Marker by modification time in **descending** order, select all duplicates with a modification time delta value higher than 0 and click on **Make Selected Reference**. The reason why you must make the sort order descending is because if 2 files among the same duplicate group are selected when you click on **Make Selected Reference**, only the first of the list will be made reference, the other will be ignored. And since you want the last modified file to be reference, having the sort order descending assures you that the first item of the list will be the last modified. diff --git a/pe/qt/help/templates/preferences.mako b/pe/qt/help/templates/preferences.mako new file mode 100644 index 00000000..0ef6a2ba --- /dev/null +++ b/pe/qt/help/templates/preferences.mako @@ -0,0 +1,23 @@ +<%! + title = 'Preferences' + selected_menu_item = 'Preferences' +%> +<%inherit file="/base_dg.mako"/> + +**Filter Hardness:** The higher is this setting, the "harder" is the filter (In other words, the less results you get). Most pictures of the same quality match at 100% even if the format is different (PNG and JPG for example.). However, if you want to make a PNG match with a lower quality JPG, you will have to set the filer hardness to lower than 100. The default, 95, is a sweet spot. + +**Match scaled pictures together:** If you check this box, pictures of different dimensions will be allowed in the same duplicate group. + +**Can mix file kind:** If you check this box, duplicate groups are allowed to have files with different extensions. If you don't check it, well, they aren't! + +**Use regular expressions when filtering:** If you check this box, the filtering feature will treat your filter query as a **regular expression**. Explaining them is beyond the scope of this document. A good place to start learning it is . + +**Remove empty folders after delete or move:** When this option is enabled, folders are deleted after a file is deleted or moved and the folder is empty. + +**Copy and Move:** Determines how the Copy and Move operations (in the Action menu) will behave. + +* **Right in destination:** All files will be sent directly in the selected destination, without trying to recreate the source path at all. +* **Recreate relative path:** The source file's path will be re-created in the destination directory up to the root selection in the Directories panel. For example, if you added "/Users/foobar/Picture" to your Directories panel and you move "/Users/foobar/Picture/2006/06/photo.jpg" to the destination "/Users/foobar/MyDestination", the final destination for the file will be "/Users/foobar/MyDestination/2006/06" ("/Users/foobar/Picture" has been trimmed from source's path in the final destination.). +* **Recreate absolute path:** The source file's path will be re-created in the destination directory in it's entirety. For example, if you move "/Users/foobar/Picture/2006/06/photo.jpg" to the destination "/Users/foobar/MyDestination", the final destination for the file will be "/Users/foobar/MyDestination/Users/foobar/Picture/2006/06". + +In all cases, dupeGuru PE nicely handles naming conflicts by prepending a number to the destination filename if the filename already exists in the destination. diff --git a/pe/qt/help/templates/quick_start.mako b/pe/qt/help/templates/quick_start.mako new file mode 100644 index 00000000..dde33c65 --- /dev/null +++ b/pe/qt/help/templates/quick_start.mako @@ -0,0 +1,18 @@ +<%! + title = 'Quick Start' + selected_menu_item = 'Quick Start' +%> +<%inherit file="/base_dg.mako"/> + +To get you quickly started with dupeGuru, let's just make a standard scan using default preferences. + +* Click on **Directories**. +* Click on **Add**. +* Choose a directory you want to scan for duplicates. +* Click on **Start Scanning**. +* Wait until the scan process is over. +* Look at every duplicate (The files that are indented) and verify that it is indeed a duplicate to the group's reference (The file above the duplicate that is not indented and have a disabled mark box). +* If a file is a false duplicate, select it and click on **Actions-->Remove Selected from Results**. +* Once you are sure that there is no false duplicate in your results, click on **Edit-->Mark All**, and then **Actions-->Send Marked to Recycle bin**. + +That is only a basic scan. There are a lot of tweaking you can do to get different results and several methods of examining and modifying your results. To know about them, just read the rest of this help file. diff --git a/pe/qt/help/templates/results.mako b/pe/qt/help/templates/results.mako new file mode 100644 index 00000000..53aa176f --- /dev/null +++ b/pe/qt/help/templates/results.mako @@ -0,0 +1,73 @@ +<%! + title = 'Results' + selected_menu_item = 'Results' +%> +<%inherit file="/base_dg.mako"/> + +When dupeGuru is finished scanning for duplicates, it will show its results in the form of duplicate group list. + +About duplicate groups +----- + +A duplicate group is a group of files that all match together. Every group has a **reference file** and one or more **duplicate files**. The reference file is the first file of the group. Its mark box is disabled. Below it, and indented, are the duplicate files. + +You can mark duplicate files, but you can never mark the reference file of a group. This is a security measure to prevent dupeGuru from deleting not only duplicate files, but their reference. You sure don't want that, do you? + +What determines which files are reference and which files are duplicates is first their directory state. A files from a reference directory will always be reference in a duplicate group. If all files are from a normal directory, the size determine which file will be the reference of a duplicate group. dupeGuru assumes that you always want to keep the biggest file, so the biggest files will take the reference position. + +You can change the reference file of a group manually. To do so, select the duplicate file you want to promote to reference, and click on **Actions-->Make Selected Reference**. + +Reviewing results +----- + +Although you can just click on **Edit-->Mark All** and then **Actions-->Send Marked to Recycle bin** to quickly delete all duplicate files in your results, it is always recommended to review all duplicates before deleting them. + +To help you reviewing the results, you can bring up the **Details panel**. This panel shows all the details of the currently selected file as well as its reference's details. This is very handy to quickly determine if a duplicate really is a duplicate. You can also double-click on a file to open it with its associated application. + +If you have more false duplicates than true duplicates (If your filter hardness is very low), the best way to proceed would be to review duplicates, mark true duplicates and then click on **Actions-->Send Marked to Recycle bin**. If you have more true duplicates than false duplicates, you can instead mark all files that are false duplicates, and use **Actions-->Remove Marked from Results**. + +Marking and Selecting +----- + +A **marked** duplicate is a duplicate with the little box next to it having a check-mark. A **selected** duplicate is a duplicate being highlighted. The multiple selection actions can be performed in dupeGuru in the standard way (Shift/Command/Control click). You can toggle all selected duplicates' mark state by pressing **space**. + +Delta Values +----- + +If you turn this switch on, some columns will display the value relative to the duplicate's reference instead of the absolute values. These delta values will also be displayed in a different color so you can spot them easily. For example, if a duplicate is 1.2 MB and its reference is 1.4 MB, the Size column will display -0.2 MB. This option is a killer feature when combined with the [Power Marker](power_marker.htm). + +Filtering +----- + +dupeGuru supports post-scan filtering. With it, you can narrow down your results so you can perform actions on a subset of it. For example, you could easily mark all duplicates with their filename containing "copy" from your results using the filter. + +**Windows:** To use the filtering feature, click on Actions --> Apply Filter, write down the filter you want to apply and click OK. To go back to unfiltered results, click on Actions --> Cancel Filter. + +**Mac OS X:** To use the filtering feature, type your filter in the "Filter" search field in the toolbar. To go back to unfiltered result, blank out the field, or click on the "X". + +In simple mode (the default mode), whatever you type as the filter is the string used to perform the actual filtering, with the exception of one wildcard: **\***. Thus, if you type "[*]" as your filter, it will match anything with [] brackets in it, whatever is in between those brackets. + +For more advanced filtering, you can turn "Use regular expressions when filtering" on. The filtering feature will then use **regular expressions**. A regular expression is a language for matching text. Explaining them is beyond the scope of this document. A good place to start learning it is . + +Matches are case insensitive in both simple and regexp mode. + +For the filter to match, your regular expression don't have to match the whole filename, it just have to contain a string matching the expression. + +You might notice that not all duplicates in the filtered results will match your filter. That is because as soon as one single duplicate in a group matches the filter, the whole group stays in the results so you can have a better view of the duplicate's context. However, non-matching duplicates are in "reference mode". Therefore, you can perform actions like Mark All and be sure to only mark filtered duplicates. + +Action Menu +----- + +* **Start Duplicate Scan:** Starts a new duplicate scan. +* **Clear Ignore List:** Remove all ignored matches you added. You have to start a new scan for the newly cleared ignore list to be effective. +* **Export Results to XHTML:** Take the current results, and create an XHTML file out of it. The columns that are visible when you click on this button will be the columns present in the XHTML file. The file will automatically be opened in your default browser. +* **Send Marked to Trash:** Send all marked duplicates to trash, obviously. +* **Move Marked to...:** Prompt you for a destination, and then move all marked files to that destination. Source file's path might be re-created in destination, depending on the "Copy and Move" preference. +* **Copy Marked to...:** Prompt you for a destination, and then copy all marked files to that destination. Source file's path might be re-created in destination, depending on the "Copy and Move" preference. +* **Remove Marked from Results:** Remove all marked duplicates from results. The actual files will not be touched and will stay where they are. +* **Remove Selected from Results:** Remove all selected duplicates from results. Note that all selected reference files will be ignored, only duplicates can be removed with this action. +* **Make Selected Reference:** Promote all selected duplicates to reference. If a duplicate is a part of a group having a reference file coming from a reference directory (in blue color), no action will be taken for this duplicate. If more than one duplicate among the same group are selected, only the first of each group will be promoted. +* **Add Selected to Ignore List:** This first removes all selected duplicates from results, and then add the match of that duplicate and the current reference in the ignore list. This match will not come up again in further scan. The duplicate itself might come back, but it will be matched with another reference file. You can clear the ignore list with the Clear Ignore List command. +* **Open Selected with Default Application:** Open the file with the application associated with selected file's type. +* **Reveal Selected in Finder:** Open the folder containing selected file. +* **Rename Selected:** Prompts you for a new name, and then rename the selected file. diff --git a/pe/qt/help/templates/versions.mako b/pe/qt/help/templates/versions.mako new file mode 100644 index 00000000..157c26ba --- /dev/null +++ b/pe/qt/help/templates/versions.mako @@ -0,0 +1,6 @@ +<%! + title = 'dupeGuru PE version history' + selected_menu_item = 'Version History' +%> +<%inherit file="/base_dg.mako"/> +${self.output_changelogs(changelog)} \ No newline at end of file diff --git a/pe/qt/installer.aip b/pe/qt/installer.aip new file mode 100644 index 00000000..d7f3ed6c --- /dev/null +++ b/pe/qt/installer.aip @@ -0,0 +1,249 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pe/qt/main_window.py b/pe/qt/main_window.py new file mode 100644 index 00000000..c1ba71bd --- /dev/null +++ b/pe/qt/main_window.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# Unit Name: main_window +# Created By: Virgil Dupras +# Created On: 2009-05-23 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import SIGNAL +from PyQt4.QtGui import QMessageBox, QAction + +from base.main_window import MainWindow as MainWindowBase + +class MainWindow(MainWindowBase): + def _setupUi(self): + MainWindowBase._setupUi(self) + self.actionClearPictureCache = QAction("Clear Picture Cache", self) + self.menuFile.insertAction(self.actionClearIgnoreList, self.actionClearPictureCache) + self.connect(self.actionClearPictureCache, SIGNAL("triggered()"), self.clearPictureCacheTriggered) + + def clearPictureCacheTriggered(self): + title = "Clear Picture Cache" + msg = "Do you really want to remove all your cached picture analysis?" + if self._confirm(title, msg, QMessageBox.No): + self.app.scanner.match_factory.cached_blocks.clear() + QMessageBox.information(self, title, "Picture cache cleared.") + \ No newline at end of file diff --git a/pe/qt/modules/block/block.pyx b/pe/qt/modules/block/block.pyx new file mode 100644 index 00000000..777ff723 --- /dev/null +++ b/pe/qt/modules/block/block.pyx @@ -0,0 +1,39 @@ +cdef object getblock(object image): + cdef int width, height, pixel_count, red, green, blue, i, offset + cdef char *s + cdef unsigned char r, g, b + width = image.width() + height = image.height() + if width: + pixel_count = width * height + red = green = blue = 0 + tmp = image.bits().asstring(image.numBytes()) + s = tmp + for i in range(pixel_count): + offset = i * 3 + r = s[offset] + g = s[offset + 1] + b = s[offset + 2] + red += r + green += g + blue += b + return (red // pixel_count, green // pixel_count, blue // pixel_count) + else: + return (0, 0, 0) + +def getblocks(image, int block_count_per_side): + cdef int width, height, block_width, block_height, ih, iw, top, left + width = image.width() + height = image.height() + if not width: + return [] + block_width = max(width // block_count_per_side, 1) + block_height = max(height // block_count_per_side, 1) + result = [] + for ih in range(block_count_per_side): + top = min(ih * block_height, height - block_height) + for iw in range(block_count_per_side): + left = min(iw * block_width, width - block_width) + crop = image.copy(left, top, block_width, block_height) + result.append(getblock(crop)) + return result diff --git a/pe/qt/modules/block/setup.py b/pe/qt/modules/block/setup.py new file mode 100644 index 00000000..e37aee94 --- /dev/null +++ b/pe/qt/modules/block/setup.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +from distutils.core import setup +from distutils.extension import Extension +from Cython.Distutils import build_ext + +setup( + cmdclass = {'build_ext': build_ext}, + ext_modules = [Extension("_block", ["block.pyx"])] +) \ No newline at end of file diff --git a/pe/qt/preferences.py b/pe/qt/preferences.py new file mode 100644 index 00000000..4dd748fd --- /dev/null +++ b/pe/qt/preferences.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# Unit Name: preferences +# Created By: Virgil Dupras +# Created On: 2009-05-17 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import QSettings, QVariant + +from base.preferences import Preferences as PreferencesBase + +class Preferences(PreferencesBase): + # (width, is_visible) + COLUMNS_DEFAULT_ATTRS = [ + (200, True), # name + (180, True), # path + (60, True), # size + (40, False), # kind + (100, True), # dimensions + (120, False), # creation + (120, False), # modification + (60, True), # match % + (80, False), # dupe count + ] + + def _load_specific(self, settings, get): + self.match_scaled = get('MatchScaled', self.match_scaled) + + def _reset_specific(self): + self.filter_hardness = 95 + self.match_scaled = False + + def _save_specific(self, settings, set_): + set_('MatchScaled', self.match_scaled) + diff --git a/pe/qt/preferences_dialog.py b/pe/qt/preferences_dialog.py new file mode 100644 index 00000000..12505f95 --- /dev/null +++ b/pe/qt/preferences_dialog.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# Unit Name: preferences_dialog +# Created By: Virgil Dupras +# Created On: 2009-04-29 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import SIGNAL, Qt +from PyQt4.QtGui import QDialog, QDialogButtonBox + +from preferences_dialog_ui import Ui_PreferencesDialog +import preferences + +class PreferencesDialog(QDialog, Ui_PreferencesDialog): + def __init__(self, parent, app): + flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint + QDialog.__init__(self, parent, flags) + self.app = app + self._setupUi() + + self.connect(self.buttonBox, SIGNAL('clicked(QAbstractButton*)'), self.buttonClicked) + + def _setupUi(self): + self.setupUi(self) + + def load(self, prefs=None): + if prefs is None: + prefs = self.app.prefs + self.filterHardnessSlider.setValue(prefs.filter_hardness) + self.filterHardnessLabel.setNum(prefs.filter_hardness) + setchecked = lambda cb, b: cb.setCheckState(Qt.Checked if b else Qt.Unchecked) + setchecked(self.matchScaledBox, prefs.match_scaled) + setchecked(self.mixFileKindBox, prefs.mix_file_kind) + setchecked(self.useRegexpBox, prefs.use_regexp) + setchecked(self.removeEmptyFoldersBox, prefs.remove_empty_folders) + self.copyMoveDestinationComboBox.setCurrentIndex(prefs.destination_type) + + def save(self): + prefs = self.app.prefs + prefs.filter_hardness = self.filterHardnessSlider.value() + ischecked = lambda cb: cb.checkState() == Qt.Checked + prefs.match_scaled = ischecked(self.matchScaledBox) + prefs.mix_file_kind = ischecked(self.mixFileKindBox) + prefs.use_regexp = ischecked(self.useRegexpBox) + prefs.remove_empty_folders = ischecked(self.removeEmptyFoldersBox) + prefs.destination_type = self.copyMoveDestinationComboBox.currentIndex() + + def resetToDefaults(self): + self.load(preferences.Preferences()) + + #--- Events + def buttonClicked(self, button): + role = self.buttonBox.buttonRole(button) + if role == QDialogButtonBox.ResetRole: + self.resetToDefaults() + diff --git a/pe/qt/preferences_dialog.ui b/pe/qt/preferences_dialog.ui new file mode 100644 index 00000000..f91b24cb --- /dev/null +++ b/pe/qt/preferences_dialog.ui @@ -0,0 +1,257 @@ + + + PreferencesDialog + + + + 0 + 0 + 366 + 249 + + + + Preferences + + + false + + + true + + + + + + + + + + + 0 + 0 + + + + Filter Hardness: + + + + + + + 0 + + + + + 12 + + + + + + 0 + 0 + + + + 1 + + + 100 + + + true + + + Qt::Horizontal + + + + + + + + 21 + 0 + + + + 100 + + + + + + + + + 0 + + + + + More Results + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Less Results + + + + + + + + + + + + + Match scaled pictures together + + + + + + + Can mix file kind + + + + + + + Use regular expressions when filtering + + + + + + + Remove empty folders on delete or move + + + + + + + + + + 0 + 0 + + + + Copy and Move: + + + + + + + + 0 + 0 + + + + + Right in destination + + + + + Recreate relative path + + + + + Recreate absolute path + + + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults + + + + + + + + + filterHardnessSlider + valueChanged(int) + filterHardnessLabel + setNum(int) + + + 182 + 26 + + + 271 + 26 + + + + + buttonBox + accepted() + PreferencesDialog + accept() + + + 182 + 228 + + + 182 + 124 + + + + + buttonBox + rejected() + PreferencesDialog + reject() + + + 182 + 228 + + + 182 + 124 + + + + + diff --git a/pe/qt/profile.py b/pe/qt/profile.py new file mode 100644 index 00000000..e285fafe --- /dev/null +++ b/pe/qt/profile.py @@ -0,0 +1,20 @@ +import sys +import cProfile +import pstats + +from PyQt4.QtCore import QCoreApplication +from PyQt4.QtGui import QApplication + +if sys.platform == 'win32': + from app_win import DupeGuru +else: + from app import DupeGuru + +if __name__ == "__main__": + app = QApplication(sys.argv) + QCoreApplication.setOrganizationName('Hardcoded Software') + QCoreApplication.setApplicationName('dupeGuru Picture Edition') + dgapp = DupeGuru() + cProfile.run('app.exec_()', '/tmp/prof') + p = pstats.Stats('/tmp/prof') + p.sort_stats('time').print_stats() \ No newline at end of file diff --git a/pe/qt/start.py b/pe/qt/start.py new file mode 100644 index 00000000..6de46e8e --- /dev/null +++ b/pe/qt/start.py @@ -0,0 +1,20 @@ +import sys + +from PyQt4.QtCore import QCoreApplication +from PyQt4.QtGui import QApplication, QIcon, QPixmap + +import base.dg_rc + +if sys.platform == 'win32': + from app_win import DupeGuru +else: + from app import DupeGuru + +if __name__ == "__main__": + app = QApplication(sys.argv) + app.setWindowIcon(QIcon(QPixmap(":/logo_pe"))) + QCoreApplication.setOrganizationName('Hardcoded Software') + QCoreApplication.setApplicationName(DupeGuru.NAME) + QCoreApplication.setApplicationVersion(DupeGuru.VERSION) + dgapp = DupeGuru() + sys.exit(app.exec_()) \ No newline at end of file diff --git a/pe/qt/verinfo b/pe/qt/verinfo new file mode 100644 index 00000000..d70ee2a0 --- /dev/null +++ b/pe/qt/verinfo @@ -0,0 +1,28 @@ +VSVersionInfo( + ffi=FixedFileInfo( + filevers=($versioncomma), + prodvers=($versioncomma), + mask=0x17, + flags=0x0, + OS=0x4, + fileType=0x1, + subtype=0x0, + date=(0, 0) + ), + kids=[ + StringFileInfo( + [ + StringTable( + '040904b0', + [StringStruct('CompanyName', 'Hardcoded Software'), + StringStruct('FileDescription', 'dupeGuru Picture Edition'), + StringStruct('FileVersion', '$version'), + StringStruct('InternalName', 'dupeGuru PE.exe'), + StringStruct('LegalCopyright', '(c) Hardcoded Software. All rights reserved.'), + StringStruct('OriginalFilename', 'dupeGuru PE.exe'), + StringStruct('ProductName', 'dupeGuru Picture Edition'), + StringStruct('ProductVersion', '$versioncomma')]) + ]), + VarFileInfo([VarStruct('Translation', [1033])]) + ] +) diff --git a/py/__init__.py b/py/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/py/__init__.py @@ -0,0 +1 @@ + diff --git a/py/app.py b/py/app.py new file mode 100644 index 00000000..0e03603d --- /dev/null +++ b/py/app.py @@ -0,0 +1,229 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.app +Created By: Virgil Dupras +Created On: 2006/11/11 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:02:48 +0200 (Thu, 28 May 2009) $ + $Revision: 4388 $ +Copyright 2006 Hardcoded Software (http://www.hardcoded.net) +""" +import os +import os.path as op +import logging + +from hsfs import IT_ATTRS, IT_EXTRA +from hsutil import job, io, files +from hsutil.path import Path +from hsutil.reg import RegistrableApplication, RegistrationRequired +from hsutil.misc import flatten, first +from hsutil.str import escape + +import directories +import results +import scanner + +JOB_SCAN = 'job_scan' +JOB_LOAD = 'job_load' +JOB_MOVE = 'job_move' +JOB_COPY = 'job_copy' +JOB_DELETE = 'job_delete' + +class NoScannableFileError(Exception): + pass + +class AllFilesAreRefError(Exception): + pass + +class DupeGuru(RegistrableApplication): + def __init__(self, data_module, appdata, appid): + RegistrableApplication.__init__(self, appid) + self.appdata = appdata + if not op.exists(self.appdata): + os.makedirs(self.appdata) + self.data = data_module + self.directories = directories.Directories() + self.results = results.Results(data_module) + self.scanner = scanner.Scanner() + self.action_count = 0 + self.last_op_error_count = 0 + self.options = { + 'escape_filter_regexp': True, + 'clean_empty_dirs': False, + } + + 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): + def op(dupe): + j.add_progress() + return self._do_delete_dupe(dupe) + + j.start_job(self.results.mark_count) + self.last_op_error_count = self.results.perform_on_marked(op, True) + + def _do_delete_dupe(self, dupe): + if not io.exists(dupe.path): + dupe.parent = None + return True + self._recycle_dupe(dupe) + self.clean_empty_dirs(dupe.path[:-1]) + if not io.exists(dupe.path): + dupe.parent = None + return True + logging.warning(u"Could not send {0} to trash.".format(unicode(dupe.path))) + return False + + def _do_load(self, j): + self.directories.LoadFromFile(op.join(self.appdata, 'last_directories.xml')) + j = j.start_subjob([1, 9]) + self.results.load_from_xml(op.join(self.appdata, 'last_results.xml'), self._get_file, j) + files = flatten(g[:] for g in self.results.groups) + for file in j.iter_with_progress(files, 'Reading metadata %d/%d'): + file._read_all_info(sections=[IT_ATTRS, IT_EXTRA]) + + def _get_file(self, str_path): + p = Path(str_path) + for d in self.directories: + if p not in d.path: + continue + result = d.find_path(p[d.path:]) + if result is not None: + return result + + @staticmethod + def _recycle_dupe(dupe): + raise NotImplementedError() + + def _start_job(self, jobid, func): + # func(j) + raise NotImplementedError() + + def AddDirectory(self, d): + try: + self.directories.add_path(Path(d)) + return 0 + except directories.AlreadyThereError: + return 1 + except directories.InvalidPathError: + return 2 + + def AddToIgnoreList(self, dupe): + g = self.results.get_group_of_duplicate(dupe) + for other in g: + if other is not dupe: + self.scanner.ignore_list.Ignore(unicode(other.path), unicode(dupe.path)) + + def ApplyFilter(self, filter): + self.results.apply_filter(None) + if self.options['escape_filter_regexp']: + filter = escape(filter, '()[]\\.|+?^') + filter = escape(filter, '*', '.') + self.results.apply_filter(filter) + + def clean_empty_dirs(self, path): + if self.options['clean_empty_dirs']: + while files.delete_if_empty(path, ['.DS_Store']): + path = path[:-1] + + def CopyOrMove(self, dupe, copy, destination, dest_type): + """ + copy: True = Copy False = Move + destination: string. + dest_type: 0 = right in destination. + 1 = relative re-creation. + 2 = absolute re-creation. + """ + source_path = dupe.path + location_path = dupe.root.path + dest_path = Path(destination) + if dest_type == 2: + dest_path = dest_path + source_path[1:-1] #Remove drive letter and filename + elif dest_type == 1: + dest_path = dest_path + source_path[location_path:-1] + if not io.exists(dest_path): + io.makedirs(dest_path) + try: + if copy: + files.copy(source_path, dest_path) + else: + files.move(source_path, dest_path) + self.clean_empty_dirs(source_path[:-1]) + except (IOError, OSError) as e: + operation = 'Copy' if copy else 'Move' + logging.warning('%s operation failed on %s. Error: %s' % (operation, unicode(dupe.path), unicode(e))) + return False + return True + + def copy_or_move_marked(self, copy, destination, recreate_path): + def do(j): + def op(dupe): + j.add_progress() + return self.CopyOrMove(dupe, copy, destination, recreate_path) + + j.start_job(self.results.mark_count) + self.last_op_error_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): + self._demo_check() + self._start_job(JOB_DELETE, self._do_delete) + + def load(self): + self._start_job(JOB_LOAD, self._do_load) + self.LoadIgnoreList() + + def LoadIgnoreList(self): + p = op.join(self.appdata, 'ignore_list.xml') + self.scanner.ignore_list.load_from_xml(p) + + def make_reference(self, duplicates): + changed_groups = set() + for dupe in duplicates: + g = self.results.get_group_of_duplicate(dupe) + if g not in changed_groups: + self.results.make_ref(dupe) + changed_groups.add(g) + + def Save(self): + self.directories.SaveToFile(op.join(self.appdata, 'last_directories.xml')) + self.results.save_to_xml(op.join(self.appdata, 'last_results.xml')) + + def SaveIgnoreList(self): + p = op.join(self.appdata, 'ignore_list.xml') + self.scanner.ignore_list.save_to_xml(p) + + def start_scanning(self): + def do(j): + j.set_progress(0, 'Collecting files to scan') + files = list(self.directories.get_files()) + logging.info('Scanning %d files' % len(files)) + self.results.groups = self.scanner.GetDupeGroups(files, j) + + files = self.directories.get_files() + first_file = first(files) + if first_file is None: + raise NoScannableFileError() + if first_file.is_ref and all(f.is_ref for f in files): + raise AllFilesAreRefError() + self.results.groups = [] + self._start_job(JOB_SCAN, do) + + #--- Properties + @property + def stat_line(self): + result = self.results.stat_line + if self.scanner.discarded_file_count: + result = '%s (%d discarded)' % (result, self.scanner.discarded_file_count) + return result + diff --git a/py/app_cocoa.py b/py/app_cocoa.py new file mode 100644 index 00000000..4974d700 --- /dev/null +++ b/py/app_cocoa.py @@ -0,0 +1,304 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.app_cocoa +Created By: Virgil Dupras +Created On: 2006/11/11 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:33:32 +0200 (Thu, 28 May 2009) $ + $Revision: 4392 $ +Copyright 2006 Hardcoded Software (http://www.hardcoded.net) +""" +from AppKit import * +import logging +import os.path as op + +import hsfs as fs +from hsfs.phys.bundle import Bundle +from hsutil.cocoa import install_exception_hook +from hsutil.str import get_file_ext +from hsutil import io, cocoa, job +from hsutil.reg import RegistrationRequired + +import export, app, data + +JOBID2TITLE = { + app.JOB_SCAN: "Scanning for duplicates", + app.JOB_LOAD: "Loading", + app.JOB_MOVE: "Moving", + app.JOB_COPY: "Copying", + app.JOB_DELETE: "Sending to Trash", +} + +class DGDirectory(fs.phys.Directory): + def _create_sub_dir(self,name,with_parent = True): + ext = get_file_ext(name) + if ext == 'app': + if with_parent: + parent = self + else: + parent = None + return Bundle(parent,name) + else: + return super(DGDirectory,self)._create_sub_dir(name,with_parent) + + +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): + 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() + if data_module is None: + data_module = data + appdata = op.expanduser(op.join('~', '.hsoftdata', appdata_subdir)) + app.DupeGuru.__init__(self, data_module, appdata, appid) + self.progress = cocoa.ThreadedJobPerformer() + self.directories.dirclass = DGDirectory + self.display_delta_values = False + self.selected_dupes = [] + self.RefreshDetailsTable(None,None) + + #--- Override + @staticmethod + def _recycle_dupe(dupe): + if not io.exists(dupe.path): + dupe.parent = None + return True + directory = unicode(dupe.parent.path) + filename = dupe.name + result, tag = NSWorkspace.sharedWorkspace().performFileOperation_source_destination_files_tag_( + NSWorkspaceRecycleOperation, directory, '', [filename]) + if not io.exists(dupe.path): + dupe.parent = None + return True + logging.warning('Could not send %s to trash. tag: %d' % (unicode(dupe.path), tag)) + return False + + def _start_job(self, jobid, func): + try: + j = self.progress.create_job() + self.progress.run_threaded(func, args=(j, )) + except job.JobInProgressError: + NSNotificationCenter.defaultCenter().postNotificationName_object_('JobInProgress', self) + else: + ud = {'desc': JOBID2TITLE[jobid], 'jobid':jobid} + 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) + + def GetDirectory(self,node_path,curr_dir=None): + if not node_path: + return curr_dir + if curr_dir is not None: + l = curr_dir.dirs + else: + l = self.directories + d = l[node_path[0]] + return self.GetDirectory(node_path[1:],d) + + def RefreshDetailsTable(self,dupe,group): + l1 = self.data.GetDisplayInfo(dupe,group,False) + if group is not None: + l2 = self.data.GetDisplayInfo(group.ref,group,False) + else: + l2 = l1 #To have a list of empty '---' values + names = [c['display'] for c in self.data.COLUMNS] + self.details_table = zip(names,l1,l2) + + #---Public + def AddSelectedToIgnoreList(self): + for dupe in self.selected_dupes: + self.AddToIgnoreList(dupe) + + copy_or_move_marked = demo_method(app.DupeGuru.copy_or_move_marked) + delete_marked = demo_method(app.DupeGuru.delete_marked) + + def ExportToXHTML(self,column_ids,xslt_path,css_path): + columns = [] + for index,column in enumerate(self.data.COLUMNS): + display = column['display'] + enabled = str(index) in column_ids + columns.append((display,enabled)) + xml_path = op.join(self.appdata,'results_export.xml') + self.results.save_to_xml(xml_path,self.data.GetDisplayInfo) + return export.export_to_xhtml(xml_path,xslt_path,css_path,columns) + + def MakeSelectedReference(self): + self.make_reference(self.selected_dupes) + + def OpenSelected(self): + if self.selected_dupes: + path = unicode(self.selected_dupes[0].path) + NSWorkspace.sharedWorkspace().openFile_(path) + + def PurgeIgnoreList(self): + self.scanner.ignore_list.Filter(lambda f,s:op.exists(f) and op.exists(s)) + + def RefreshDetailsWithSelected(self): + if self.selected_dupes: + self.RefreshDetailsTable( + self.selected_dupes[0], + self.results.get_group_of_duplicate(self.selected_dupes[0]) + ) + else: + self.RefreshDetailsTable(None,None) + + def RemoveDirectory(self,index): + try: + del self.directories[index] + except IndexError: + pass + + def RemoveSelected(self): + self.results.remove_duplicates(self.selected_dupes) + + def RenameSelected(self,newname): + try: + d = self.selected_dupes[0] + d = d.move(d.parent,newname) + return True + except (IndexError,fs.FSError),e: + logging.warning("dupeGuru Warning: %s" % str(e)) + return False + + def RevealSelected(self): + if self.selected_dupes: + path = unicode(self.selected_dupes[0].path) + NSWorkspace.sharedWorkspace().selectFile_inFileViewerRootedAtPath_(path,'') + + def start_scanning(self): + self.RefreshDetailsTable(None, None) + try: + app.DupeGuru.start_scanning(self) + return 0 + except app.NoScannableFileError: + return 3 + except app.AllFilesAreRefError: + return 1 + + 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.selected_dupes = [dupe for dupe in selected if dupe is not None] + + def SelectPowerMarkerNodePaths(self,node_paths): + rows = [p[0] for p in node_paths] + self.selected_dupes = [ + self.results.dupes[row] for row in rows if row in xrange(len(self.results.dupes)) + ] + + def SetDirectoryState(self,node_path,state): + d = self.GetDirectory(node_path) + self.directories.SetState(d.path,state) + + def sort_dupes(self,key,asc): + self.results.sort_dupes(key,asc,self.display_delta_values) + + def sort_groups(self,key,asc): + self.results.sort_groups(key,asc) + + def ToggleSelectedMarkState(self): + for dupe in self.selected_dupes: + self.results.mark_toggle(dupe) + + #---Data + def GetOutlineViewMaxLevel(self, tag): + if tag == 0: + return 2 + elif tag == 1: + return 0 + elif tag == 2: + return 1 + + def GetOutlineViewChildCounts(self, tag, node_path): + if self.progress._job_running: + return [] + if tag == 0: #Normal results + assert not node_path # no other value is possible + return [len(g.dupes) for g in self.results.groups] + elif tag == 1: #Directories + dirs = self.GetDirectory(node_path).dirs if node_path else self.directories + return [d.dircount for d in dirs] + else: #Power Marker + assert not node_path # no other value is possible + return [0 for d in self.results.dupes] + + def GetOutlineViewValues(self, tag, node_path): + if self.progress._job_running: + return + if not node_path: + return + if tag in (0,2): #Normal results / Power Marker + if tag == 0: + g, d = self.GetObjects(node_path) + if d is None: + d = g.ref + else: + d = self.results.dupes[node_path[0]] + g = self.results.get_group_of_duplicate(d) + result = self.data.GetDisplayInfo(d, g, self.display_delta_values) + return result + elif tag == 1: #Directories + d = self.GetDirectory(node_path) + return [ + d.name, + self.directories.GetState(d.path) + ] + + def GetOutlineViewMarked(self, tag, node_path): + # 0=unmarked 1=marked 2=unmarkable + if self.progress._job_running: + return + if not node_path: + return 2 + if tag == 1: #Directories + return 2 + if tag == 0: #Normal results + g, d = self.GetObjects(node_path) + else: #Power Marker + d = self.results.dupes[node_path[0]] + if (d is None) or (not self.results.is_markable(d)): + return 2 + elif self.results.is_marked(d): + return 1 + else: + return 0 + + def GetTableViewCount(self, tag): + if self.progress._job_running: + return 0 + return len(self.details_table) + + def GetTableViewMarkedIndexes(self,tag): + return [] + + def GetTableViewValues(self,tag,row): + return self.details_table[row] + + diff --git a/py/app_cocoa_test.py b/py/app_cocoa_test.py new file mode 100644 index 00000000..ad8b937a --- /dev/null +++ b/py/app_cocoa_test.py @@ -0,0 +1,320 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.tests.app_cocoa +Created By: Virgil Dupras +Created On: 2006/11/11 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-29 17:51:41 +0200 (Fri, 29 May 2009) $ + $Revision: 4409 $ +Copyright 2006 Hardcoded Software (http://www.hardcoded.net) +""" +import tempfile +import shutil +import logging + +from hsutil.path import Path +from hsutil.testcase import TestCase +from hsutil.decorators import log_calls +import hsfs.phys +import os.path as op + +from . import engine, data +try: + from .app_cocoa import DupeGuru as DupeGuruBase, DGDirectory +except ImportError: + from nose.plugins.skip import SkipTest + raise SkipTest("These tests can only be run on OS X") +from .results_test import GetTestGroups + +class DupeGuru(DupeGuruBase): + def __init__(self): + DupeGuruBase.__init__(self, data, '/tmp', appid=4) + + def _start_job(self, jobid, func): + func(nulljob) + + +def r2np(rows): + #Transforms a list of rows [1,2,3] into a list of node paths [[1],[2],[3]] + return [[i] for i in rows] + +class TCDupeGuru(TestCase): + def setUp(self): + self.app = DupeGuru() + self.objects,self.matches,self.groups = GetTestGroups() + self.app.results.groups = self.groups + + def test_GetObjects(self): + app = self.app + objects = self.objects + groups = self.groups + g,d = app.GetObjects([0]) + self.assert_(g is groups[0]) + self.assert_(d is None) + g,d = app.GetObjects([0,0]) + self.assert_(g is groups[0]) + self.assert_(d is objects[1]) + g,d = app.GetObjects([1,0]) + self.assert_(g is groups[1]) + self.assert_(d is objects[4]) + + def test_GetObjects_after_sort(self): + app = self.app + objects = self.objects + groups = self.groups[:] #To keep the old order in memory + app.sort_groups(0,False) #0 = Filename + #Now, the group order is supposed to be reversed + g,d = app.GetObjects([0,0]) + self.assert_(g is groups[1]) + 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_selectResultNodePaths(self): + app = self.app + objects = self.objects + app.SelectResultNodePaths([[0,0],[0,1]]) + self.assertEqual(2,len(app.selected_dupes)) + self.assert_(app.selected_dupes[0] is objects[1]) + self.assert_(app.selected_dupes[1] is objects[2]) + + def test_selectResultNodePaths_with_ref(self): + app = self.app + objects = self.objects + app.SelectResultNodePaths([[0,0],[0,1],[1]]) + self.assertEqual(3,len(app.selected_dupes)) + self.assert_(app.selected_dupes[0] is objects[1]) + self.assert_(app.selected_dupes[1] is objects[2]) + self.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): + app = self.app + objects = self.objects + groups = self.groups[:] #To keep the old order in memory + app.sort_groups(0,False) #0 = Filename + #Now, the group order is supposed to be reversed + app.SelectResultNodePaths([[0,0],[1],[1,0]]) + self.assertEqual(3,len(app.selected_dupes)) + self.assert_(app.selected_dupes[0] is objects[4]) + self.assert_(app.selected_dupes[1] is groups[0].ref) + self.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_selectPowerMarkerRows(self): + app = self.app + objects = self.objects + app.SelectPowerMarkerNodePaths(r2np([0,1,2])) + self.assertEqual(3,len(app.selected_dupes)) + self.assert_(app.selected_dupes[0] is objects[1]) + self.assert_(app.selected_dupes[1] is objects[2]) + self.assert_(app.selected_dupes[2] is objects[4]) + + def test_selectPowerMarkerRows_empty(self): + self.app.SelectPowerMarkerNodePaths([]) + self.assertEqual(0,len(self.app.selected_dupes)) + + def test_selectPowerMarkerRows_after_sort(self): + app = self.app + objects = self.objects + app.sort_dupes(0,False) #0 = Filename + app.SelectPowerMarkerNodePaths(r2np([0,1,2])) + self.assertEqual(3,len(app.selected_dupes)) + self.assert_(app.selected_dupes[0] is objects[4]) + self.assert_(app.selected_dupes[1] is objects[2]) + self.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): + app = self.app + objects = self.objects + app.ToggleSelectedMarkState() + self.assertEqual(0,app.results.mark_count) + app.SelectPowerMarkerNodePaths(r2np([0,2])) + app.ToggleSelectedMarkState() + self.assertEqual(2,app.results.mark_count) + self.assert_(not app.results.is_marked(objects[0])) + self.assert_(app.results.is_marked(objects[1])) + self.assert_(not app.results.is_marked(objects[2])) + self.assert_(not app.results.is_marked(objects[3])) + self.assert_(app.results.is_marked(objects[4])) + + def test_refreshDetailsWithSelected(self): + def mock_refresh(dupe,group): + self.called = True + if self.app.selected_dupes: + self.assert_(dupe is self.app.selected_dupes[0]) + self.assert_(group is self.app.results.get_group_of_duplicate(dupe)) + else: + self.assert_(dupe is None) + self.assert_(group is None) + + self.app.RefreshDetailsTable = mock_refresh + self.called = False + self.app.SelectPowerMarkerNodePaths(r2np([0,2])) + self.app.RefreshDetailsWithSelected() + self.assert_(self.called) + self.called = False + self.app.SelectPowerMarkerNodePaths([]) + self.app.RefreshDetailsWithSelected() + self.assert_(self.called) + + def test_makeSelectedReference(self): + app = self.app + objects = self.objects + groups = self.groups + app.SelectPowerMarkerNodePaths(r2np([0,2])) + app.MakeSelectedReference() + self.assert_(groups[0].ref is objects[1]) + self.assert_(groups[1].ref is objects[4]) + + def test_makeSelectedReference_by_selecting_two_dupes_in_the_same_group(self): + app = self.app + objects = self.objects + groups = self.groups + app.SelectPowerMarkerNodePaths(r2np([0,1,2])) + #Only 0 and 2 must go ref, not 1 because it is a part of the same group + app.MakeSelectedReference() + self.assert_(groups[0].ref is objects[1]) + self.assert_(groups[1].ref is objects[4]) + + def test_removeSelected(self): + app = self.app + app.SelectPowerMarkerNodePaths(r2np([0,2])) + app.RemoveSelected() + self.assertEqual(1,len(app.results.dupes)) + app.RemoveSelected() + self.assertEqual(1,len(app.results.dupes)) + app.SelectPowerMarkerNodePaths(r2np([0,2])) + app.RemoveSelected() + self.assertEqual(0,len(app.results.dupes)) + + def test_addDirectory_simple(self): + app = self.app + self.assertEqual(0,app.AddDirectory(self.datadirpath())) + self.assertEqual(1,len(app.directories)) + + def test_addDirectory_already_there(self): + app = self.app + self.assertEqual(0,app.AddDirectory(self.datadirpath())) + self.assertEqual(1,app.AddDirectory(self.datadirpath())) + + def test_addDirectory_does_not_exist(self): + app = self.app + self.assertEqual(2,app.AddDirectory('/does_not_exist')) + + def test_ignore(self): + app = self.app + app.SelectPowerMarkerNodePaths(r2np([2])) #The dupe of the second, 2 sized group + app.AddSelectedToIgnoreList() + self.assertEqual(1,len(app.scanner.ignore_list)) + app.SelectPowerMarkerNodePaths(r2np([0])) #first dupe of the 3 dupes group + app.AddSelectedToIgnoreList() + #BOTH the ref and the other dupe should have been added + self.assertEqual(3,len(app.scanner.ignore_list)) + + def test_purgeIgnoreList(self): + app = self.app + p1 = self.filepath('zerofile') + p2 = self.filepath('zerofill') + dne = '/does_not_exist' + app.scanner.ignore_list.Ignore(dne,p1) + app.scanner.ignore_list.Ignore(p2,dne) + app.scanner.ignore_list.Ignore(p1,p2) + app.PurgeIgnoreList() + self.assertEqual(1,len(app.scanner.ignore_list)) + self.assert_(app.scanner.ignore_list.AreIgnored(p1,p2)) + self.assert_(not app.scanner.ignore_list.AreIgnored(dne,p1)) + + def test_only_unicode_is_added_to_ignore_list(self): + def FakeIgnore(first,second): + if not isinstance(first,unicode): + self.fail() + if not isinstance(second,unicode): + self.fail() + + app = self.app + app.scanner.ignore_list.Ignore = FakeIgnore + app.SelectPowerMarkerNodePaths(r2np([2])) #The dupe of the second, 2 sized group + app.AddSelectedToIgnoreList() + + def test_dirclass(self): + self.assert_(self.app.directories.dirclass is DGDirectory) + + +class TCDupeGuru_renameSelected(TestCase): + def setUp(self): + p = Path(tempfile.mkdtemp()) + fp = open(str(p + 'foo bar 1'),mode='w') + fp.close() + fp = open(str(p + 'foo bar 2'),mode='w') + fp.close() + fp = open(str(p + 'foo bar 3'),mode='w') + fp.close() + refdir = hsfs.phys.Directory(None,str(p)) + matches = engine.MatchFactory().getmatches(refdir.files) + groups = engine.get_groups(matches) + g = groups[0] + g.prioritize(lambda x:x.name) + app = DupeGuru() + app.results.groups = groups + self.app = app + self.groups = groups + self.p = p + self.refdir = refdir + + def tearDown(self): + shutil.rmtree(str(self.p)) + + def test_simple(self): + app = self.app + refdir = self.refdir + g = self.groups[0] + app.SelectPowerMarkerNodePaths(r2np([0])) + self.assert_(app.RenameSelected('renamed')) + self.assert_('renamed' in refdir) + self.assert_('foo bar 2' not in refdir) + self.assert_(g.dupes[0] is refdir['renamed']) + self.assert_(g.dupes[0] in refdir) + + def test_none_selected(self): + app = self.app + refdir = self.refdir + g = self.groups[0] + app.SelectPowerMarkerNodePaths([]) + self.mock(logging, 'warning', log_calls(lambda msg: None)) + self.assert_(not app.RenameSelected('renamed')) + msg = logging.warning.calls[0]['msg'] + self.assertEqual('dupeGuru Warning: list index out of range', msg) + self.assert_('renamed' not in refdir) + self.assert_('foo bar 2' in refdir) + self.assert_(g.dupes[0] is refdir['foo bar 2']) + + def test_name_already_exists(self): + app = self.app + refdir = self.refdir + g = self.groups[0] + app.SelectPowerMarkerNodePaths(r2np([0])) + self.mock(logging, 'warning', log_calls(lambda msg: None)) + self.assert_(not app.RenameSelected('foo bar 1')) + msg = logging.warning.calls[0]['msg'] + self.assert_(msg.startswith('dupeGuru Warning: \'foo bar 2\' already exists in')) + self.assert_('foo bar 1' in refdir) + self.assert_('foo bar 2' in refdir) + self.assert_(g.dupes[0] is refdir['foo bar 2']) + diff --git a/py/app_me_cocoa.py b/py/app_me_cocoa.py new file mode 100644 index 00000000..51a61767 --- /dev/null +++ b/py/app_me_cocoa.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.app_me_cocoa +Created By: Virgil Dupras +Created On: 2006/11/16 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:33:32 +0200 (Thu, 28 May 2009) $ + $Revision: 4392 $ +Copyright 2006 Hardcoded Software (http://www.hardcoded.net) +""" +import os.path as op +import logging +from appscript import app, k, CommandError +import time + +from hsutil.cocoa import as_fetch +import hsfs.phys.music + +import app_cocoa, data_me, scanner + +JOB_REMOVE_DEAD_TRACKS = 'jobRemoveDeadTracks' +JOB_SCAN_DEAD_TRACKS = 'jobScanDeadTracks' + +app_cocoa.JOBID2TITLE.update({ + JOB_REMOVE_DEAD_TRACKS: "Removing dead tracks from your iTunes Library", + JOB_SCAN_DEAD_TRACKS: "Scanning the iTunes Library", +}) + +class DupeGuruME(app_cocoa.DupeGuru): + def __init__(self): + app_cocoa.DupeGuru.__init__(self, data_me, 'dupeguru_me', appid=1) + self.scanner = scanner.ScannerME() + self.directories.dirclass = hsfs.phys.music.Directory + self.dead_tracks = [] + + def remove_dead_tracks(self): + def do(j): + a = app('iTunes') + for index, track in enumerate(j.iter_with_progress(self.dead_tracks)): + if index % 100 == 0: + time.sleep(.1) + try: + track.delete() + except CommandError as e: + logging.warning('Error while trying to remove a track from iTunes: %s' % unicode(e)) + + self._start_job(JOB_REMOVE_DEAD_TRACKS, do) + + def scan_dead_tracks(self): + def do(j): + a = app('iTunes') + try: + [source] = [s for s in a.sources() if s.kind() == k.library] + [library] = source.library_playlists() + except ValueError: + logging.warning('Some unexpected iTunes configuration encountered') + return + self.dead_tracks = [] + tracks = as_fetch(library.file_tracks, k.file_track) + for index, track in enumerate(j.iter_with_progress(tracks)): + if index % 100 == 0: + time.sleep(.1) + if track.location() == k.missing_value: + self.dead_tracks.append(track) + logging.info('Found %d dead tracks' % len(self.dead_tracks)) + + self._start_job(JOB_SCAN_DEAD_TRACKS, do) + diff --git a/py/app_pe_cocoa.py b/py/app_pe_cocoa.py new file mode 100644 index 00000000..5969d1c3 --- /dev/null +++ b/py/app_pe_cocoa.py @@ -0,0 +1,212 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.app_pe_cocoa +Created By: Virgil Dupras +Created On: 2006/11/13 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:33:32 +0200 (Thu, 28 May 2009) $ + $Revision: 4392 $ +Copyright 2006 Hardcoded Software (http://www.hardcoded.net) +""" +import os +import os.path as op +import logging +import plistlib + +import objc +from Foundation import * +from AppKit import * +from appscript import app, k + +from hsutil import job, io +import hsfs as fs +from hsfs import phys +from hsutil import files +from hsutil.str import get_file_ext +from hsutil.path import Path +from hsutil.cocoa import as_fetch + +import app_cocoa, data_pe, directories, picture.matchbase +from picture.cache import string_to_colors, Cache + +mainBundle = NSBundle.mainBundle() +PictureBlocks = mainBundle.classNamed_('PictureBlocks') +assert PictureBlocks is not None + +class Photo(phys.File): + cls_info_map = { + 'size': fs.IT_ATTRS, + 'ctime': fs.IT_ATTRS, + 'mtime': fs.IT_ATTRS, + 'md5': fs.IT_MD5, + 'md5partial': fs.IT_MD5, + 'dimensions': fs.IT_EXTRA, + } + + def _initialize_info(self,section): + super(Photo, self)._initialize_info(section) + if section == fs.IT_EXTRA: + self._info.update({ + 'dimensions': (0,0), + }) + + def _read_info(self,section): + super(Photo, self)._read_info(section) + if section == fs.IT_EXTRA: + size = PictureBlocks.getImageSize_(unicode(self.path)) + self._info['dimensions'] = (size.width, size.height) + + def get_blocks(self, block_count_per_side): + try: + blocks = PictureBlocks.getBlocksFromImagePath_blockCount_scanArea_(unicode(self.path), block_count_per_side, 0) + except Exception, e: + raise IOError('The reading of "%s" failed with "%s"' % (unicode(self.path), unicode(e))) + if not blocks: + raise IOError('The picture %s could not be read' % unicode(self.path)) + return string_to_colors(blocks) + + +class IPhoto(Photo): + def __init__(self, parent, whole_path): + super(IPhoto, self).__init__(parent, whole_path[-1]) + self.whole_path = whole_path + + def _build_path(self): + return self.whole_path + + @property + def display_path(self): + return super(IPhoto, self)._build_path() + + +class Directory(phys.Directory): + cls_file_class = Photo + cls_supported_exts = ('png', 'jpg', 'jpeg', 'gif', 'psd', 'bmp', 'tiff', 'nef', 'cr2') + + def _fetch_subitems(self): + subdirs, subfiles = super(Directory,self)._fetch_subitems() + return subdirs, [name for name in subfiles if get_file_ext(name) in self.cls_supported_exts] + + +class IPhotoLibrary(fs.Directory): + def __init__(self, plistpath): + self.plistpath = plistpath + self.refpath = plistpath[:-1] + # the AlbumData.xml file lives right in the library path + super(IPhotoLibrary, self).__init__(None, 'iPhoto Library') + + def _update_photo(self, photo_data): + if photo_data['MediaType'] != 'Image': + return + photo_path = Path(photo_data['ImagePath']) + subpath = photo_path[len(self.refpath):-1] + subdir = self + for element in subpath: + try: + subdir = subdir[element] + except KeyError: + subdir = fs.Directory(subdir, element) + IPhoto(subdir, photo_path) + + def update(self): + self.clear() + s = open(unicode(self.plistpath)).read() + # There was a case where a guy had 0x10 chars in his plist, causing expat errors on loading + s = s.replace('\x10', '') + plist = plistlib.readPlistFromString(s) + for photo_data in plist['Master Image List'].values(): + self._update_photo(photo_data) + + def force_update(self): # Don't update + pass + + +class DupeGuruPE(app_cocoa.DupeGuru): + def __init__(self): + app_cocoa.DupeGuru.__init__(self, data_pe, 'dupeguru_pe', appid=5) + self.scanner.match_factory = picture.matchbase.AsyncMatchFactory() + self.directories.dirclass = Directory + self.directories.special_dirclasses[Path('iPhoto Library')] = lambda _, __: self._create_iphoto_library() + p = op.join(self.appdata, 'cached_pictures.db') + self.scanner.match_factory.cached_blocks = Cache(p) + + def _create_iphoto_library(self): + ud = NSUserDefaults.standardUserDefaults() + prefs = ud.persistentDomainForName_('com.apple.iApps') + plisturl = NSURL.URLWithString_(prefs['iPhotoRecentDatabases'][0]) + plistpath = Path(plisturl.path()) + return IPhotoLibrary(plistpath) + + def _do_delete(self, j): + def op(dupe): + j.add_progress() + return self._do_delete_dupe(dupe) + + marked = [dupe for dupe in self.results.dupes if self.results.is_marked(dupe)] + self.path2iphoto = {} + if any(isinstance(dupe, IPhoto) for dupe in marked): + a = app('iPhoto') + a.select(a.photo_library_album()) + photos = as_fetch(a.photo_library_album().photos, k.item) + for photo in photos: + self.path2iphoto[photo.image_path()] = photo + self.last_op_error_count = self.results.perform_on_marked(op, True) + del self.path2iphoto + + def _do_delete_dupe(self, dupe): + if isinstance(dupe, IPhoto): + photo = self.path2iphoto[unicode(dupe.path)] + app('iPhoto').remove(photo) + return True + else: + return app_cocoa.DupeGuru._do_delete_dupe(self, dupe) + + def _do_load(self, j): + self.directories.LoadFromFile(op.join(self.appdata, 'last_directories.xml')) + for d in self.directories: + if isinstance(d, IPhotoLibrary): + d.update() + self.results.load_from_xml(op.join(self.appdata, 'last_results.xml'), self._get_file, j) + + def _get_file(self, str_path): + p = Path(str_path) + for d in self.directories: + result = None + if p in d.path: + result = d.find_path(p[d.path:]) + if isinstance(d, IPhotoLibrary) and p in d.refpath: + result = d.find_path(p[d.refpath:]) + if result is not None: + return result + + def AddDirectory(self, d): + try: + added = self.directories.add_path(Path(d)) + if d == 'iPhoto Library': + added.update() + return 0 + except directories.AlreadyThereError: + return 1 + + def CopyOrMove(self, dupe, copy, destination, dest_type): + if isinstance(dupe, IPhoto): + copy = True + return app_cocoa.DupeGuru.CopyOrMove(self, dupe, copy, destination, dest_type) + + def start_scanning(self): + for directory in self.directories: + if isinstance(directory, IPhotoLibrary): + self.directories.SetState(directory.refpath, directories.STATE_EXCLUDED) + return app_cocoa.DupeGuru.start_scanning(self) + + def selected_dupe_path(self): + if not self.selected_dupes: + return None + return self.selected_dupes[0].path + + def selected_dupe_ref_path(self): + if not self.selected_dupes: + return None + ref = self.results.get_group_of_duplicate(self.selected_dupes[0]).ref + return ref.path + diff --git a/py/app_se_cocoa.py b/py/app_se_cocoa.py new file mode 100644 index 00000000..3d8c62b2 --- /dev/null +++ b/py/app_se_cocoa.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +# Unit Name: app_se_cocoa +# Created By: Virgil Dupras +# Created On: 2009-05-24 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import app_cocoa, data + +class DupeGuru(app_cocoa.DupeGuru): + def __init__(self): + app_cocoa.DupeGuru.__init__(self, data, 'dupeguru', appid=4) + diff --git a/py/app_test.py b/py/app_test.py new file mode 100644 index 00000000..af47067f --- /dev/null +++ b/py/app_test.py @@ -0,0 +1,137 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.tests.app +Created By: Virgil Dupras +Created On: 2007-06-23 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:02:48 +0200 (Thu, 28 May 2009) $ + $Revision: 4388 $ +Copyright 2007 Hardcoded Software (http://www.hardcoded.net) +""" +import unittest +import os + +from hsutil.testcase import TestCase +from hsutil import io +from hsutil.path import Path +from hsutil.decorators import log_calls +import hsfs as fs +import hsfs.phys +import hsutil.files +from hsutil.job import nulljob + +from . import data, app +from .app import DupeGuru as DupeGuruBase + +class DupeGuru(DupeGuruBase): + def __init__(self): + DupeGuruBase.__init__(self, data, '/tmp', appid=4) + + def _start_job(self, jobid, func): + func(nulljob) + + +class TCDupeGuru(TestCase): + cls_tested_module = app + def test_ApplyFilter_calls_results_apply_filter(self): + app = DupeGuru() + self.mock(app.results, 'apply_filter', log_calls(app.results.apply_filter)) + app.ApplyFilter('foo') + self.assertEqual(2, len(app.results.apply_filter.calls)) + call = app.results.apply_filter.calls[0] + self.assert_(call['filter_str'] is None) + call = app.results.apply_filter.calls[1] + self.assertEqual('foo', call['filter_str']) + + def test_ApplyFilter_escapes_regexp(self): + app = DupeGuru() + self.mock(app.results, 'apply_filter', log_calls(app.results.apply_filter)) + app.ApplyFilter('()[]\\.|+?^abc') + call = app.results.apply_filter.calls[1] + self.assertEqual('\\(\\)\\[\\]\\\\\\.\\|\\+\\?\\^abc', call['filter_str']) + app.ApplyFilter('(*)') # In "simple mode", we want the * to behave as a wilcard + call = app.results.apply_filter.calls[3] + self.assertEqual('\(.*\)', call['filter_str']) + app.options['escape_filter_regexp'] = False + app.ApplyFilter('(abc)') + call = app.results.apply_filter.calls[5] + self.assertEqual('(abc)', call['filter_str']) + + def test_CopyOrMove(self): + # The goal here is just to have a test for a previous blowup I had. I know my test coverage + # for this unit is pathetic. What's done is done. My approach now is to add tests for + # every change I want to make. The blowup was caused by a missing import. + dupe_parent = fs.Directory(None, 'foo') + dupe = fs.File(dupe_parent, 'bar') + dupe.copy = log_calls(lambda dest, newname: None) + self.mock(hsutil.files, 'copy', log_calls(lambda source_path, dest_path: None)) + self.mock(os, 'makedirs', lambda path: None) # We don't want the test to create that fake directory + self.mock(fs.phys, 'Directory', fs.Directory) # We don't want an error because makedirs didn't work + app = DupeGuru() + app.CopyOrMove(dupe, True, 'some_destination', 0) + self.assertEqual(1, len(hsutil.files.copy.calls)) + call = hsutil.files.copy.calls[0] + self.assertEqual('some_destination', call['dest_path']) + self.assertEqual(dupe.path, call['source_path']) + + def test_CopyOrMove_clean_empty_dirs(self): + tmppath = Path(self.tmpdir()) + sourcepath = tmppath + 'source' + io.mkdir(sourcepath) + io.open(sourcepath + 'myfile', 'w') + tmpdir = hsfs.phys.Directory(None, unicode(tmppath)) + myfile = tmpdir['source']['myfile'] + app = DupeGuru() + self.mock(app, 'clean_empty_dirs', log_calls(lambda path: None)) + app.CopyOrMove(myfile, False, tmppath + 'dest', 0) + calls = app.clean_empty_dirs.calls + self.assertEqual(1, len(calls)) + self.assertEqual(sourcepath, calls[0]['path']) + + def test_Scan_with_objects_evaluating_to_false(self): + # At some point, any() was used in a wrong way that made Scan() wrongly return 1 + app = DupeGuru() + f1, f2 = [fs.File(None, 'foo') for i in range(2)] + f1.is_ref, f2.is_ref = (False, False) + assert not (bool(f1) and bool(f2)) + app.directories.get_files = lambda: [f1, f2] + app.directories._dirs.append('this is just so Scan() doesnt return 3') + app.start_scanning() # no exception + + +class TCDupeGuru_clean_empty_dirs(TestCase): + cls_tested_module = app + def setUp(self): + self.mock(hsutil.files, 'delete_if_empty', log_calls(lambda path, files_to_delete=[]: None)) + self.app = DupeGuru() + + def test_option_off(self): + self.app.clean_empty_dirs(Path('/foo/bar')) + self.assertEqual(0, len(hsutil.files.delete_if_empty.calls)) + + def test_option_on(self): + self.app.options['clean_empty_dirs'] = True + self.app.clean_empty_dirs(Path('/foo/bar')) + calls = hsutil.files.delete_if_empty.calls + self.assertEqual(1, len(calls)) + self.assertEqual(Path('/foo/bar'), calls[0]['path']) + self.assertEqual(['.DS_Store'], calls[0]['files_to_delete']) + + def test_recurse_up(self): + # delete_if_empty must be recursively called up in the path until it returns False + @log_calls + def mock_delete_if_empty(path, files_to_delete=[]): + return len(path) > 1 + + self.mock(hsutil.files, 'delete_if_empty', mock_delete_if_empty) + self.app.options['clean_empty_dirs'] = True + self.app.clean_empty_dirs(Path('not-empty/empty/empty')) + calls = hsutil.files.delete_if_empty.calls + self.assertEqual(3, len(calls)) + self.assertEqual(Path('not-empty/empty/empty'), calls[0]['path']) + self.assertEqual(Path('not-empty/empty'), calls[1]['path']) + self.assertEqual(Path('not-empty'), calls[2]['path']) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/py/data.py b/py/data.py new file mode 100644 index 00000000..568a3400 --- /dev/null +++ b/py/data.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.data +Created By: Virgil Dupras +Created On: 2006/03/15 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" + +from hsutil.str import format_time, FT_DECIMAL, format_size + +import time + +def format_path(p): + return unicode(p[:-1]) + +def format_timestamp(t, delta): + if delta: + return format_time(t, FT_DECIMAL) + else: + if t > 0: + return time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(t)) + else: + return '---' + +def format_words(w): + def do_format(w): + if isinstance(w, list): + return '(%s)' % ', '.join(do_format(item) for item in w) + else: + return w.replace('\n', ' ') + + return ', '.join(do_format(item) for item in w) + +def format_perc(p): + return "%0.0f" % p + +def format_dupe_count(c): + return str(c) if c else '---' + +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'}, +] + +def GetDisplayInfo(dupe, group, delta=False): + if (dupe is None) or (group is None): + return ['---'] * len(COLUMNS) + 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), + 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/py/data_me.py b/py/data_me.py new file mode 100644 index 00000000..70d3ae66 --- /dev/null +++ b/py/data_me.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.data +Created By: Virgil Dupras +Created On: 2006/03/15 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" + +from hsutil.str import format_time, FT_MINUTES, format_size +from .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 (MB)'}, + {'attr':'duration','display':'Time'}, + {'attr':'bitrate','display':'Bitrate'}, + {'attr':'samplerate','display':'Sample Rate'}, + {'attr':'extension','display':'Kind'}, + {'attr':'ctime','display':'Creation'}, + {'attr':'mtime','display':'Modification'}, + {'attr':'title','display':'Title'}, + {'attr':'artist','display':'Artist'}, + {'attr':'album','display':'Album'}, + {'attr':'genre','display':'Genre'}, + {'attr':'year','display':'Year'}, + {'attr':'track','display':'Track Number'}, + {'attr':'comment','display':'Comment'}, + {'attr':'percentage','display':'Match %'}, + {'attr':'words','display':'Words Used'}, + {'attr':'dupe_count','display':'Dupe Count'}, +] + +def GetDisplayInfo(dupe, group, delta=False): + if (dupe is None) or (group is None): + return ['---'] * len(COLUMNS) + size = dupe.size + duration = dupe.duration + bitrate = dupe.bitrate + samplerate = dupe.samplerate + 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 + duration -= r.duration + bitrate -= r.bitrate + samplerate -= r.samplerate + 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, 2, 2, False), + format_time(duration, FT_MINUTES), + str(bitrate), + str(samplerate), + dupe.extension, + format_timestamp(ctime,delta and m), + format_timestamp(mtime,delta and m), + dupe.title, + dupe.artist, + dupe.album, + dupe.genre, + dupe.year, + str(dupe.track), + dupe.comment, + format_perc(percentage), + format_words(dupe.words), + format_dupe_count(dupe_count) + ] + +def GetDupeSortKey(dupe, get_group, key, delta): + if key == 16: + m = get_group().get_match_of(dupe) + return m.percentage + if key == 18: + return 0 + r = cmp_value(getattr(dupe, COLUMNS[key]['attr'])) + if delta and (key in (2, 3, 4, 7, 8)): + r -= cmp_value(getattr(get_group().ref, COLUMNS[key]['attr'])) + return r + +def GetGroupSortKey(group, key): + if key == 16: + return group.percentage + if key == 18: + return len(group) + return cmp_value(getattr(group.ref, COLUMNS[key]['attr'])) diff --git a/py/data_pe.py b/py/data_pe.py new file mode 100644 index 00000000..94bdd99d --- /dev/null +++ b/py/data_pe.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.data +Created By: Virgil Dupras +Created On: 2006/03/15 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +from hsutil.str import format_size +from .data import format_path, format_timestamp, format_perc, format_dupe_count, cmp_value + +def format_dimensions(dimensions): + return '%d x %d' % (dimensions[0], dimensions[1]) + +COLUMNS = [ + {'attr':'name','display':'Filename'}, + {'attr':'path','display':'Directory'}, + {'attr':'size','display':'Size (KB)'}, + {'attr':'extension','display':'Kind'}, + {'attr':'dimensions','display':'Dimensions'}, + {'attr':'ctime','display':'Creation'}, + {'attr':'mtime','display':'Modification'}, + {'attr':'percentage','display':'Match %'}, + {'attr':'dupe_count','display':'Dupe Count'}, +] + +def GetDisplayInfo(dupe,group,delta=False): + if (dupe is None) or (group is None): + return ['---'] * len(COLUMNS) + 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) + dupe_path = getattr(dupe, 'display_path', dupe.path) + return [ + dupe.name, + format_path(dupe_path), + format_size(size, 0, 1, False), + dupe.extension, + format_dimensions(dupe.dimensions), + format_timestamp(ctime, delta and m), + format_timestamp(mtime, delta and m), + format_perc(percentage), + format_dupe_count(dupe_count) + ] + +def GetDupeSortKey(dupe, get_group, key, delta): + if key == 7: + 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, 5, 6)): + r -= cmp_value(getattr(get_group().ref, COLUMNS[key]['attr'])) + return r + +def GetGroupSortKey(group, key): + if key == 7: + return group.percentage + if key == 8: + return len(group) + return cmp_value(getattr(group.ref, COLUMNS[key]['attr'])) + diff --git a/py/directories.py b/py/directories.py new file mode 100644 index 00000000..3d73b5c5 --- /dev/null +++ b/py/directories.py @@ -0,0 +1,161 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.directories +Created By: Virgil Dupras +Created On: 2006/02/27 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:02:48 +0200 (Thu, 28 May 2009) $ + $Revision: 4388 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import xml.dom.minidom + +from hsfs import phys +import hsfs as fs +from hsutil.files import FileOrPath +from hsutil.path import Path + +(STATE_NORMAL, +STATE_REFERENCE, +STATE_EXCLUDED) = range(3) + +class AlreadyThereError(Exception): + """The path being added is already in the directory list""" + +class InvalidPathError(Exception): + """The path being added is invalid""" + +class Directories(object): + #---Override + def __init__(self): + self._dirs = [] + self.states = {} + self.dirclass = phys.Directory + self.special_dirclasses = {} + + def __contains__(self,path): + for d in self._dirs: + if path in d.path: + return True + return False + + def __delitem__(self,key): + self._dirs.__delitem__(key) + + def __getitem__(self,key): + return self._dirs.__getitem__(key) + + def __len__(self): + return len(self._dirs) + + #---Private + def _get_files(self, from_dir, state=STATE_NORMAL): + state = self.states.get(from_dir.path, state) + result = [] + for subdir in from_dir.dirs: + for file in self._get_files(subdir, state): + yield file + if state != STATE_EXCLUDED: + for file in from_dir.files: + file.is_ref = state == STATE_REFERENCE + yield file + + #---Public + def add_path(self, path): + """Adds 'path' to self, if not already there. + + Raises AlreadyThereError if 'path' is already in self. If path is a directory containing + some of the directories already present in self, 'path' will be added, but all directories + under it will be removed. Can also raise InvalidPathError if 'path' does not exist. + """ + if path in self: + raise AlreadyThereError + self._dirs = [d for d in self._dirs if d.path not in path] + try: + dirclass = self.special_dirclasses.get(path, self.dirclass) + d = dirclass(None, unicode(path)) + d[:] #If an InvalidPath exception has to be raised, it will be raised here + self._dirs.append(d) + return d + except fs.InvalidPath: + raise InvalidPathError + + def get_files(self): + """Returns a list of all files that are not excluded. + + Returned files also have their 'is_ref' attr set. + """ + for d in self._dirs: + d.force_update() + try: + for file in self._get_files(d): + yield file + except fs.InvalidPath: + pass + + def GetState(self, path): + """Returns the state of 'path' (One of the STATE_* const.) + + Raises LookupError if 'path' is not in self. + """ + if path not in self: + raise LookupError("The path '%s' is not in the directory list." % str(path)) + try: + return self.states[path] + except KeyError: + if path[-1].startswith('.'): # hidden + return STATE_EXCLUDED + parent = path[:-1] + if parent in self: + return self.GetState(parent) + else: + return STATE_NORMAL + + def LoadFromFile(self,infile): + try: + doc = xml.dom.minidom.parse(infile) + except: + return + root_dir_nodes = doc.getElementsByTagName('root_directory') + for rdn in root_dir_nodes: + if not rdn.getAttributeNode('path'): + continue + path = rdn.getAttributeNode('path').nodeValue + try: + self.add_path(Path(path)) + except (AlreadyThereError,InvalidPathError): + pass + state_nodes = doc.getElementsByTagName('state') + for sn in state_nodes: + if not (sn.getAttributeNode('path') and sn.getAttributeNode('value')): + continue + path = sn.getAttributeNode('path').nodeValue + state = sn.getAttributeNode('value').nodeValue + self.SetState(Path(path), int(state)) + + def Remove(self,directory): + self._dirs.remove(directory) + + def SaveToFile(self,outfile): + with FileOrPath(outfile, 'wb') as fp: + doc = xml.dom.minidom.Document() + root = doc.appendChild(doc.createElement('directories')) + for root_dir in self: + root_dir_node = root.appendChild(doc.createElement('root_directory')) + root_dir_node.setAttribute('path', unicode(root_dir.path).encode('utf-8')) + for path,state in self.states.iteritems(): + state_node = root.appendChild(doc.createElement('state')) + state_node.setAttribute('path', unicode(path).encode('utf-8')) + state_node.setAttribute('value', str(state)) + doc.writexml(fp,'\t','\t','\n',encoding='utf-8') + + def SetState(self,path,state): + try: + if self.GetState(path) == state: + return + self.states[path] = state + if (self.GetState(path[:-1]) == state) and (not path[-1].startswith('.')): + del self.states[path] + except LookupError: + pass + diff --git a/py/directories_test.py b/py/directories_test.py new file mode 100644 index 00000000..7d34c343 --- /dev/null +++ b/py/directories_test.py @@ -0,0 +1,280 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.tests.directories +Created By: Virgil Dupras +Created On: 2006/02/27 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-29 08:51:14 +0200 (Fri, 29 May 2009) $ + $Revision: 4398 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import unittest +import os.path as op +import os +import time +import shutil + +from hsutil import job, io +from hsutil.path import Path +from hsutil.testcase import TestCase +import hsfs.phys +from hsfs.phys import phys_test + +from directories import * + +testpath = Path(TestCase.datadirpath()) + +class TCDirectories(TestCase): + def test_empty(self): + d = Directories() + self.assertEqual(0,len(d)) + self.assert_('foobar' not in d) + + def test_add_path(self): + d = Directories() + p = testpath + 'utils' + added = d.add_path(p) + self.assertEqual(1,len(d)) + self.assert_(p in d) + self.assert_((p + 'foobar') in d) + self.assert_(p[:-1] not in d) + self.assertEqual(p,added.path) + self.assert_(d[0] is added) + p = self.tmppath() + d.add_path(p) + self.assertEqual(2,len(d)) + self.assert_(p in d) + + def test_AddPath_when_path_is_already_there(self): + d = Directories() + p = testpath + 'utils' + d.add_path(p) + self.assertRaises(AlreadyThereError, d.add_path, p) + self.assertRaises(AlreadyThereError, d.add_path, p + 'foobar') + self.assertEqual(1, len(d)) + + def test_AddPath_containing_paths_already_there(self): + d = Directories() + d.add_path(testpath + 'utils') + self.assertEqual(1, len(d)) + added = d.add_path(testpath) + self.assertEqual(1, len(d)) + self.assert_(added is d[0]) + + def test_AddPath_non_latin(self): + p = Path(self.tmpdir()) + to_add = p + u'unicode\u201a' + os.mkdir(unicode(to_add)) + d = Directories() + try: + d.add_path(to_add) + except UnicodeDecodeError: + self.fail() + + def test_del(self): + d = Directories() + d.add_path(testpath + 'utils') + try: + del d[1] + self.fail() + except IndexError: + pass + d.add_path(self.tmppath()) + del d[1] + self.assertEqual(1, len(d)) + + def test_states(self): + d = Directories() + p = testpath + 'utils' + d.add_path(p) + self.assertEqual(STATE_NORMAL,d.GetState(p)) + d.SetState(p,STATE_REFERENCE) + self.assertEqual(STATE_REFERENCE,d.GetState(p)) + self.assertEqual(STATE_REFERENCE,d.GetState(p + 'dir1')) + self.assertEqual(1,len(d.states)) + self.assertEqual(p,d.states.keys()[0]) + self.assertEqual(STATE_REFERENCE,d.states[p]) + + def test_GetState_with_path_not_there(self): + d = Directories() + d.add_path(testpath + 'utils') + self.assertRaises(LookupError,d.GetState,testpath) + + def test_states_remain_when_larger_directory_eat_smaller_ones(self): + d = Directories() + p = testpath + 'utils' + d.add_path(p) + d.SetState(p,STATE_EXCLUDED) + d.add_path(testpath) + d.SetState(testpath,STATE_REFERENCE) + self.assertEqual(STATE_EXCLUDED,d.GetState(p)) + self.assertEqual(STATE_EXCLUDED,d.GetState(p + 'dir1')) + self.assertEqual(STATE_REFERENCE,d.GetState(testpath)) + + def test_SetState_keep_state_dict_size_to_minimum(self): + d = Directories() + p = Path(phys_test.create_fake_fs(self.tmpdir())) + d.add_path(p) + d.SetState(p,STATE_REFERENCE) + d.SetState(p + 'dir1',STATE_REFERENCE) + self.assertEqual(1,len(d.states)) + self.assertEqual(STATE_REFERENCE,d.GetState(p + 'dir1')) + d.SetState(p + 'dir1',STATE_NORMAL) + self.assertEqual(2,len(d.states)) + self.assertEqual(STATE_NORMAL,d.GetState(p + 'dir1')) + d.SetState(p + 'dir1',STATE_REFERENCE) + self.assertEqual(1,len(d.states)) + self.assertEqual(STATE_REFERENCE,d.GetState(p + 'dir1')) + + def test_get_files(self): + d = Directories() + p = Path(phys_test.create_fake_fs(self.tmpdir())) + d.add_path(p) + d.SetState(p + 'dir1',STATE_REFERENCE) + d.SetState(p + 'dir2',STATE_EXCLUDED) + files = d.get_files() + self.assertEqual(5, len(list(files))) + for f in files: + if f.parent.path == p + 'dir1': + self.assert_(f.is_ref) + else: + self.assert_(not f.is_ref) + + def test_get_files_with_inherited_exclusion(self): + d = Directories() + p = testpath + 'utils' + d.add_path(p) + d.SetState(p,STATE_EXCLUDED) + self.assertEqual([], list(d.get_files())) + + def test_save_and_load(self): + d1 = Directories() + d2 = Directories() + p1 = self.tmppath() + p2 = self.tmppath() + d1.add_path(p1) + d1.add_path(p2) + d1.SetState(p1, STATE_REFERENCE) + d1.SetState(p1 + 'dir1',STATE_EXCLUDED) + tmpxml = op.join(self.tmpdir(), 'directories_testunit.xml') + d1.SaveToFile(tmpxml) + d2.LoadFromFile(tmpxml) + self.assertEqual(2, len(d2)) + self.assertEqual(STATE_REFERENCE,d2.GetState(p1)) + self.assertEqual(STATE_EXCLUDED,d2.GetState(p1 + 'dir1')) + + def test_invalid_path(self): + d = Directories() + p = Path('does_not_exist') + self.assertRaises(InvalidPathError, d.add_path, p) + self.assertEqual(0, len(d)) + + def test_SetState_on_invalid_path(self): + d = Directories() + try: + d.SetState(Path('foobar',),STATE_NORMAL) + except LookupError: + self.fail() + + def test_default_dirclass(self): + self.assert_(Directories().dirclass is hsfs.phys.Directory) + + def test_dirclass(self): + class MySpecialDirclass(hsfs.phys.Directory): pass + d = Directories() + d.dirclass = MySpecialDirclass + d.add_path(testpath) + self.assert_(isinstance(d[0], MySpecialDirclass)) + + def test_LoadFromFile_with_invalid_path(self): + #This test simulates a load from file resulting in a + #InvalidPath raise. Other directories must be loaded. + d1 = Directories() + d1.add_path(testpath + 'utils') + #Will raise InvalidPath upon loading + d1.add_path(self.tmppath()).name = 'does_not_exist' + tmpxml = op.join(self.tmpdir(), 'directories_testunit.xml') + d1.SaveToFile(tmpxml) + d2 = Directories() + d2.LoadFromFile(tmpxml) + self.assertEqual(1, len(d2)) + + def test_LoadFromFile_with_same_paths(self): + #This test simulates a load from file resulting in a + #AlreadyExists raise. Other directories must be loaded. + d1 = Directories() + p1 = self.tmppath() + p2 = self.tmppath() + d1.add_path(p1) + d1.add_path(p2) + #Will raise AlreadyExists upon loading + d1.add_path(self.tmppath()).name = unicode(p1) + tmpxml = op.join(self.tmpdir(), 'directories_testunit.xml') + d1.SaveToFile(tmpxml) + d2 = Directories() + d2.LoadFromFile(tmpxml) + self.assertEqual(2, len(d2)) + + def test_Remove(self): + d = Directories() + d1 = d.add_path(self.tmppath()) + d2 = d.add_path(self.tmppath()) + d.Remove(d1) + self.assertEqual(1, len(d)) + self.assert_(d[0] is d2) + + def test_unicode_save(self): + d = Directories() + p1 = self.tmppath() + u'hello\xe9' + io.mkdir(p1) + io.mkdir(p1 + u'foo\xe9') + d.add_path(p1) + d.SetState(d[0][0].path, STATE_EXCLUDED) + tmpxml = op.join(self.tmpdir(), 'directories_testunit.xml') + try: + d.SaveToFile(tmpxml) + except UnicodeDecodeError: + self.fail() + + def test_get_files_refreshes_its_directories(self): + d = Directories() + p = Path(phys_test.create_fake_fs(self.tmpdir())) + d.add_path(p) + files = d.get_files() + self.assertEqual(6, len(list(files))) + time.sleep(1) + os.remove(str(p + ('dir1','file1.test'))) + files = d.get_files() + self.assertEqual(5, len(list(files))) + + def test_get_files_does_not_choke_on_non_existing_directories(self): + d = Directories() + p = Path(self.tmpdir()) + d.add_path(p) + io.rmtree(p) + self.assertEqual([], list(d.get_files())) + + def test_GetState_returns_excluded_by_default_for_hidden_directories(self): + d = Directories() + p = Path(self.tmpdir()) + hidden_dir_path = p + '.foo' + io.mkdir(p + '.foo') + d.add_path(p) + self.assertEqual(d.GetState(hidden_dir_path), STATE_EXCLUDED) + # But it can be overriden + d.SetState(hidden_dir_path, STATE_NORMAL) + self.assertEqual(d.GetState(hidden_dir_path), STATE_NORMAL) + + def test_special_dirclasses(self): + # if a path is in special_dirclasses, use this class instead + class MySpecialDirclass(hsfs.phys.Directory): pass + d = Directories() + p1 = self.tmppath() + p2 = self.tmppath() + d.special_dirclasses[p1] = MySpecialDirclass + self.assert_(isinstance(d.add_path(p2), hsfs.phys.Directory)) + self.assert_(isinstance(d.add_path(p1), MySpecialDirclass)) + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/py/engine.py b/py/engine.py new file mode 100644 index 00000000..a826902d --- /dev/null +++ b/py/engine.py @@ -0,0 +1,360 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.engine +Created By: Virgil Dupras +Created On: 2006/01/29 +Last modified by:$Author: virgil $ +Last modified on:$Date: $ + $Revision: $ +Copyright 2007 Hardcoded Software (http://www.hardcoded.net) +""" +from __future__ import division +import difflib +import logging +import string +from collections import defaultdict, namedtuple +from unicodedata import normalize + +from hsutil.str import multi_replace +from hsutil import job + +(WEIGHT_WORDS, +MATCH_SIMILAR_WORDS, +NO_FIELD_ORDER) = range(3) + +JOB_REFRESH_RATE = 100 + +def getwords(s): + if isinstance(s, unicode): + s = normalize('NFD', s) + s = multi_replace(s, "-_&+():;\\[]{}.,<>/?~!@#$*", ' ').lower() + s = ''.join(c for c in s if c in string.ascii_letters + string.digits + string.whitespace) + return filter(None, s.split(' ')) # filter() is to remove empty elements + +def getfields(s): + fields = [getwords(field) for field in s.split(' - ')] + return filter(None, fields) + +def unpack_fields(fields): + result = [] + for field in fields: + if isinstance(field, list): + result += field + else: + result.append(field) + return result + +def compare(first, second, flags=()): + """Returns the % of words that match between first and second + + The result is a int in the range 0..100. + First and second can be either a string or a list. + """ + if not (first and second): + return 0 + if any(isinstance(element, list) for element in first): + return compare_fields(first, second, flags) + second = second[:] #We must use a copy of second because we remove items from it + match_similar = MATCH_SIMILAR_WORDS in flags + weight_words = WEIGHT_WORDS in flags + joined = first + second + total_count = (sum(len(word) for word in joined) if weight_words else len(joined)) + match_count = 0 + in_order = True + for word in first: + if match_similar and (word not in second): + similar = difflib.get_close_matches(word, second, 1, 0.8) + if similar: + word = similar[0] + if word in second: + if second[0] != word: + in_order = False + second.remove(word) + match_count += (len(word) if weight_words else 1) + result = round(((match_count * 2) / total_count) * 100) + if (result == 100) and (not in_order): + result = 99 # We cannot consider a match exact unless the ordering is the same + return result + +def compare_fields(first, second, flags=()): + """Returns the score for the lowest matching fields. + + first and second must be lists of lists of string. + """ + if len(first) != len(second): + return 0 + if NO_FIELD_ORDER in flags: + results = [] + #We don't want to remove field directly in the list. We must work on a copy. + second = second[:] + for field1 in first: + max = 0 + matched_field = None + for field2 in second: + r = compare(field1, field2, flags) + if r > max: + max = r + matched_field = field2 + results.append(max) + if matched_field: + second.remove(matched_field) + else: + results = [compare(word1, word2, flags) for word1, word2 in zip(first, second)] + return min(results) if results else 0 + +def build_word_dict(objects, j=job.nulljob): + """Returns a dict of objects mapped by their words. + + objects must have a 'words' attribute being a list of strings or a list of lists of strings. + + The result will be a dict with words as keys, lists of objects as values. + """ + result = defaultdict(set) + for object in j.iter_with_progress(objects, 'Prepared %d/%d files', JOB_REFRESH_RATE): + for word in unpack_fields(object.words): + result[word].add(object) + return result + +def merge_similar_words(word_dict): + """Take all keys in word_dict that are similar, and merge them together. + """ + keys = word_dict.keys() + keys.sort(key=len)# we want the shortest word to stay + while keys: + key = keys.pop(0) + similars = difflib.get_close_matches(key, keys, 100, 0.8) + if not similars: + continue + objects = word_dict[key] + for similar in similars: + objects |= word_dict[similar] + del word_dict[similar] + keys.remove(similar) + +def reduce_common_words(word_dict, threshold): + """Remove all objects from word_dict values where the object count >= threshold + + The exception to this removal are the objects where all the words of the object are common. + Because if we remove them, we will miss some duplicates! + """ + uncommon_words = set(word for word, objects in word_dict.items() if len(objects) < threshold) + for word, objects in word_dict.items(): + if len(objects) < threshold: + continue + reduced = set() + for o in objects: + if not any(w in uncommon_words for w in unpack_fields(o.words)): + reduced.add(o) + if reduced: + word_dict[word] = reduced + else: + del word_dict[word] + +Match = namedtuple('Match', 'first second percentage') +def get_match(first, second, flags=()): + #it is assumed here that first and second both have a "words" attribute + percentage = compare(first.words, second.words, flags) + return Match(first, second, percentage) + +class MatchFactory(object): + common_word_threshold = 50 + match_similar_words = False + min_match_percentage = 0 + weight_words = False + no_field_order = False + limit = 5000000 + + def getmatches(self, objects, j=job.nulljob): + j = j.start_subjob(2) + sj = j.start_subjob(2) + for o in objects: + if not hasattr(o, 'words'): + o.words = getwords(o.name) + word_dict = build_word_dict(objects, sj) + reduce_common_words(word_dict, self.common_word_threshold) + if self.match_similar_words: + merge_similar_words(word_dict) + match_flags = [] + if self.weight_words: + match_flags.append(WEIGHT_WORDS) + if self.match_similar_words: + match_flags.append(MATCH_SIMILAR_WORDS) + if self.no_field_order: + match_flags.append(NO_FIELD_ORDER) + j.start_job(len(word_dict), '0 matches found') + compared = defaultdict(set) + result = [] + try: + # This whole 'popping' thing is there to avoid taking too much memory at the same time. + while word_dict: + items = word_dict.popitem()[1] + while items: + ref = items.pop() + compared_already = compared[ref] + to_compare = items - compared_already + compared_already |= to_compare + for other in to_compare: + m = get_match(ref, other, match_flags) + if m.percentage >= self.min_match_percentage: + result.append(m) + if len(result) >= self.limit: + return result + j.add_progress(desc='%d matches found' % len(result)) + except MemoryError: + # This is the place where the memory usage is at its peak during the scan. + # Just continue the process with an incomplete list of matches. + del compared # This should give us enough room to call logging. + logging.warning('Memory Overflow. Matches: %d. Word dict: %d' % (len(result), len(word_dict))) + return result + return result + + +class Group(object): + #---Override + def __init__(self): + self._clear() + + def __contains__(self, item): + return item in self.unordered + + def __getitem__(self, key): + return self.ordered.__getitem__(key) + + def __iter__(self): + return iter(self.ordered) + + def __len__(self): + return len(self.ordered) + + #---Private + def _clear(self): + self._percentage = None + self._matches_for_ref = None + self.matches = set() + self.candidates = defaultdict(set) + self.ordered = [] + self.unordered = set() + + def _get_matches_for_ref(self): + if self._matches_for_ref is None: + ref = self.ref + self._matches_for_ref = [match for match in self.matches if ref in match] + return self._matches_for_ref + + #---Public + def add_match(self, match): + def add_candidate(item, match): + matches = self.candidates[item] + matches.add(match) + if self.unordered <= matches: + self.ordered.append(item) + self.unordered.add(item) + + if match in self.matches: + return + self.matches.add(match) + first, second, _ = match + if first not in self.unordered: + add_candidate(first, second) + if second not in self.unordered: + add_candidate(second, first) + self._percentage = None + self._matches_for_ref = None + + def clean_matches(self): + self.matches = set(m for m in self.matches if (m.first in self.unordered) and (m.second in self.unordered)) + self.candidates = defaultdict(set) + + def get_match_of(self, item): + if item is self.ref: + return + for m in self._get_matches_for_ref(): + if item in m: + return m + + def prioritize(self, key_func, tie_breaker=None): + # tie_breaker(ref, dupe) --> True if dupe should be ref + self.ordered.sort(key=key_func) + if tie_breaker is None: + return + ref = self.ref + key_value = key_func(ref) + for dupe in self.dupes: + if key_func(dupe) != key_value: + break + if tie_breaker(ref, dupe): + ref = dupe + if ref is not self.ref: + self.switch_ref(ref) + + def remove_dupe(self, item, clean_matches=True): + try: + self.ordered.remove(item) + self.unordered.remove(item) + self._percentage = None + self._matches_for_ref = None + if (len(self) > 1) and any(not getattr(item, 'is_ref', False) for item in self): + if clean_matches: + self.matches = set(m for m in self.matches if item not in m) + else: + self._clear() + except ValueError: + pass + + def switch_ref(self, with_dupe): + try: + self.ordered.remove(with_dupe) + self.ordered.insert(0, with_dupe) + self._percentage = None + self._matches_for_ref = None + except ValueError: + pass + + dupes = property(lambda self: self[1:]) + + @property + def percentage(self): + if self._percentage is None: + if self.dupes: + matches = self._get_matches_for_ref() + self._percentage = sum(match.percentage for match in matches) // len(matches) + else: + self._percentage = 0 + return self._percentage + + @property + def ref(self): + if self: + return self[0] + + +def get_groups(matches, j=job.nulljob): + matches.sort(key=lambda match: -match.percentage) + dupe2group = {} + groups = [] + for match in j.iter_with_progress(matches, 'Grouped %d/%d matches', JOB_REFRESH_RATE): + first, second, _ = match + first_group = dupe2group.get(first) + second_group = dupe2group.get(second) + if first_group: + if second_group: + if first_group is second_group: + target_group = first_group + else: + continue + else: + target_group = first_group + dupe2group[second] = target_group + else: + if second_group: + target_group = second_group + dupe2group[first] = target_group + else: + target_group = Group() + groups.append(target_group) + dupe2group[first] = target_group + dupe2group[second] = target_group + target_group.add_match(match) + for group in groups: + group.clean_matches() + return groups diff --git a/py/engine_test.py b/py/engine_test.py new file mode 100644 index 00000000..8e9706d9 --- /dev/null +++ b/py/engine_test.py @@ -0,0 +1,822 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.engine_test +Created By: Virgil Dupras +Created On: 2006/01/29 +Last modified by:$Author: virgil $ +Last modified on:$Date: $ + $Revision: $ +Copyright 2004-2008 Hardcoded Software (http://www.hardcoded.net) +""" +import unittest +import sys + +from hsutil import job +from hsutil.decorators import log_calls +from hsutil.testcase import TestCase + +from . import engine +from .engine import * + +class NamedObject(object): + def __init__(self, name="foobar", with_words=False): + self.name = name + if with_words: + self.words = getwords(name) + + +def get_match_triangle(): + o1 = NamedObject(with_words=True) + o2 = NamedObject(with_words=True) + o3 = NamedObject(with_words=True) + m1 = get_match(o1,o2) + m2 = get_match(o1,o3) + m3 = get_match(o2,o3) + return [m1, m2, m3] + +def get_test_group(): + m1, m2, m3 = get_match_triangle() + result = Group() + result.add_match(m1) + result.add_match(m2) + result.add_match(m3) + return result + +class TCgetwords(TestCase): + def test_spaces(self): + self.assertEqual(['a', 'b', 'c', 'd'], getwords("a b c d")) + self.assertEqual(['a', 'b', 'c', 'd'], getwords(" a b c d ")) + + def test_splitter_chars(self): + self.assertEqual( + [chr(i) for i in xrange(ord('a'),ord('z')+1)], + getwords("a-b_c&d+e(f)g;h\\i[j]k{l}m:n.o,pr/s?t~u!v@w#x$y*z") + ) + + def test_joiner_chars(self): + self.assertEqual(["aec"], getwords(u"a'e\u0301c")) + + def test_empty(self): + self.assertEqual([], getwords('')) + + def test_returns_lowercase(self): + self.assertEqual(['foo', 'bar'], getwords('FOO BAR')) + + def test_decompose_unicode(self): + self.assertEqual(getwords(u'foo\xe9bar'), ['fooebar']) + + +class TCgetfields(TestCase): + def test_simple(self): + self.assertEqual([['a', 'b'], ['c', 'd', 'e']], getfields('a b - c d e')) + + def test_empty(self): + self.assertEqual([], getfields('')) + + def test_cleans_empty_fields(self): + expected = [['a', 'bc', 'def']] + actual = getfields(' - a bc def') + self.assertEqual(expected, actual) + expected = [['bc', 'def']] + + +class TCunpack_fields(TestCase): + def test_with_fields(self): + expected = ['a', 'b', 'c', 'd', 'e', 'f'] + actual = unpack_fields([['a'], ['b', 'c'], ['d', 'e', 'f']]) + self.assertEqual(expected, actual) + + def test_without_fields(self): + expected = ['a', 'b', 'c', 'd', 'e', 'f'] + actual = unpack_fields(['a', 'b', 'c', 'd', 'e', 'f']) + self.assertEqual(expected, actual) + + def test_empty(self): + self.assertEqual([], unpack_fields([])) + + +class TCWordCompare(TestCase): + def test_list(self): + self.assertEqual(100, compare(['a', 'b', 'c', 'd'],['a', 'b', 'c', 'd'])) + self.assertEqual(86, compare(['a', 'b', 'c', 'd'],['a', 'b', 'c'])) + + def test_unordered(self): + #Sometimes, users don't want fuzzy matching too much When they set the slider + #to 100, they don't expect a filename with the same words, but not the same order, to match. + #Thus, we want to return 99 in that case. + self.assertEqual(99, compare(['a', 'b', 'c', 'd'], ['d', 'b', 'c', 'a'])) + + def test_word_occurs_twice(self): + #if a word occurs twice in first, but once in second, we want the word to be only counted once + self.assertEqual(89, compare(['a', 'b', 'c', 'd', 'a'], ['d', 'b', 'c', 'a'])) + + def test_uses_copy_of_lists(self): + first = ['foo', 'bar'] + second = ['bar', 'bleh'] + compare(first, second) + self.assertEqual(['foo', 'bar'], first) + self.assertEqual(['bar', 'bleh'], second) + + def test_word_weight(self): + self.assertEqual(int((6.0 / 13.0) * 100), compare(['foo', 'bar'], ['bar', 'bleh'], (WEIGHT_WORDS, ))) + + def test_similar_words(self): + self.assertEqual(100, compare(['the', 'white', 'stripes'],['the', 'whites', 'stripe'], (MATCH_SIMILAR_WORDS, ))) + + def test_empty(self): + self.assertEqual(0, compare([], [])) + + def test_with_fields(self): + self.assertEqual(67, compare([['a', 'b'], ['c', 'd', 'e']], [['a', 'b'], ['c', 'd', 'f']])) + + def test_propagate_flags_with_fields(self): + def mock_compare(first, second, flags): + self.assertEqual((0, 1, 2, 3, 5), flags) + + self.mock(engine, 'compare_fields', mock_compare) + compare([['a']], [['a']], (0, 1, 2, 3, 5)) + + +class TCWordCompareWithFields(TestCase): + def test_simple(self): + self.assertEqual(67, compare_fields([['a', 'b'], ['c', 'd', 'e']], [['a', 'b'], ['c', 'd', 'f']])) + + def test_empty(self): + self.assertEqual(0, compare_fields([], [])) + + def test_different_length(self): + self.assertEqual(0, compare_fields([['a'], ['b']], [['a'], ['b'], ['c']])) + + def test_propagates_flags(self): + def mock_compare(first, second, flags): + self.assertEqual((0, 1, 2, 3, 5), flags) + + self.mock(engine, 'compare_fields', mock_compare) + compare_fields([['a']], [['a']],(0, 1, 2, 3, 5)) + + def test_order(self): + first = [['a', 'b'], ['c', 'd', 'e']] + second = [['c', 'd', 'f'], ['a', 'b']] + self.assertEqual(0, compare_fields(first, second)) + + def test_no_order(self): + first = [['a','b'],['c','d','e']] + second = [['c','d','f'],['a','b']] + self.assertEqual(67, compare_fields(first, second, (NO_FIELD_ORDER, ))) + first = [['a','b'],['a','b']] #a field can only be matched once. + second = [['c','d','f'],['a','b']] + self.assertEqual(0, compare_fields(first, second, (NO_FIELD_ORDER, ))) + first = [['a','b'],['a','b','c']] + second = [['c','d','f'],['a','b']] + self.assertEqual(33, compare_fields(first, second, (NO_FIELD_ORDER, ))) + + def test_compare_fields_without_order_doesnt_alter_fields(self): + #The NO_ORDER comp type altered the fields! + first = [['a','b'],['c','d','e']] + second = [['c','d','f'],['a','b']] + self.assertEqual(67, compare_fields(first, second, (NO_FIELD_ORDER, ))) + self.assertEqual([['a','b'],['c','d','e']],first) + self.assertEqual([['c','d','f'],['a','b']],second) + + +class TCbuild_word_dict(TestCase): + def test_with_standard_words(self): + l = [NamedObject('foo bar',True)] + l.append(NamedObject('bar baz',True)) + l.append(NamedObject('baz bleh foo',True)) + d = build_word_dict(l) + self.assertEqual(4,len(d)) + self.assertEqual(2,len(d['foo'])) + self.assert_(l[0] in d['foo']) + self.assert_(l[2] in d['foo']) + self.assertEqual(2,len(d['bar'])) + self.assert_(l[0] in d['bar']) + self.assert_(l[1] in d['bar']) + self.assertEqual(2,len(d['baz'])) + self.assert_(l[1] in d['baz']) + self.assert_(l[2] in d['baz']) + self.assertEqual(1,len(d['bleh'])) + self.assert_(l[2] in d['bleh']) + + def test_unpack_fields(self): + o = NamedObject('') + o.words = [['foo','bar'],['baz']] + d = build_word_dict([o]) + self.assertEqual(3,len(d)) + self.assertEqual(1,len(d['foo'])) + + def test_words_are_unaltered(self): + o = NamedObject('') + o.words = [['foo','bar'],['baz']] + d = build_word_dict([o]) + self.assertEqual([['foo','bar'],['baz']],o.words) + + def test_object_instances_can_only_be_once_in_words_object_list(self): + o = NamedObject('foo foo',True) + d = build_word_dict([o]) + self.assertEqual(1,len(d['foo'])) + + def test_job(self): + def do_progress(p,d=''): + self.log.append(p) + return True + + j = job.Job(1,do_progress) + self.log = [] + s = "foo bar" + build_word_dict([NamedObject(s, True), NamedObject(s, True), NamedObject(s, True)], j) + self.assertEqual(0,self.log[0]) + self.assertEqual(33,self.log[1]) + self.assertEqual(66,self.log[2]) + self.assertEqual(100,self.log[3]) + + +class TCmerge_similar_words(TestCase): + def test_some_similar_words(self): + d = { + 'foobar':set([1]), + 'foobar1':set([2]), + 'foobar2':set([3]), + } + merge_similar_words(d) + self.assertEqual(1,len(d)) + self.assertEqual(3,len(d['foobar'])) + + + +class TCreduce_common_words(TestCase): + def test_typical(self): + d = { + 'foo': set([NamedObject('foo bar',True) for i in range(50)]), + 'bar': set([NamedObject('foo bar',True) for i in range(49)]) + } + reduce_common_words(d, 50) + self.assert_('foo' not in d) + self.assertEqual(49,len(d['bar'])) + + def test_dont_remove_objects_with_only_common_words(self): + d = { + 'common': set([NamedObject("common uncommon",True) for i in range(50)] + [NamedObject("common",True)]), + 'uncommon': set([NamedObject("common uncommon",True)]) + } + reduce_common_words(d, 50) + self.assertEqual(1,len(d['common'])) + self.assertEqual(1,len(d['uncommon'])) + + def test_values_still_are_set_instances(self): + d = { + 'common': set([NamedObject("common uncommon",True) for i in range(50)] + [NamedObject("common",True)]), + 'uncommon': set([NamedObject("common uncommon",True)]) + } + reduce_common_words(d, 50) + self.assert_(isinstance(d['common'],set)) + self.assert_(isinstance(d['uncommon'],set)) + + def test_dont_raise_KeyError_when_a_word_has_been_removed(self): + #If a word has been removed by the reduce, an object in a subsequent common word that + #contains the word that has been removed would cause a KeyError. + d = { + 'foo': set([NamedObject('foo bar baz',True) for i in range(50)]), + 'bar': set([NamedObject('foo bar baz',True) for i in range(50)]), + 'baz': set([NamedObject('foo bar baz',True) for i in range(49)]) + } + try: + reduce_common_words(d, 50) + except KeyError: + self.fail() + + def test_unpack_fields(self): + #object.words may be fields. + def create_it(): + o = NamedObject('') + o.words = [['foo','bar'],['baz']] + return o + + d = { + 'foo': set([create_it() for i in range(50)]) + } + try: + reduce_common_words(d, 50) + except TypeError: + self.fail("must support fields.") + + def test_consider_a_reduced_common_word_common_even_after_reduction(self): + #There was a bug in the code that causeda word that has already been reduced not to + #be counted as a common word for subsequent words. For example, if 'foo' is processed + #as a common word, keeping a "foo bar" file in it, and the 'bar' is processed, "foo bar" + #would not stay in 'bar' because 'foo' is not a common word anymore. + only_common = NamedObject('foo bar',True) + d = { + 'foo': set([NamedObject('foo bar baz',True) for i in range(49)] + [only_common]), + 'bar': set([NamedObject('foo bar baz',True) for i in range(49)] + [only_common]), + 'baz': set([NamedObject('foo bar baz',True) for i in range(49)]) + } + reduce_common_words(d, 50) + self.assertEqual(1,len(d['foo'])) + self.assertEqual(1,len(d['bar'])) + self.assertEqual(49,len(d['baz'])) + + +class TCget_match(TestCase): + def test_simple(self): + o1 = NamedObject("foo bar",True) + o2 = NamedObject("bar bleh",True) + m = get_match(o1,o2) + self.assertEqual(50,m.percentage) + self.assertEqual(['foo','bar'],m.first.words) + self.assertEqual(['bar','bleh'],m.second.words) + self.assert_(m.first is o1) + self.assert_(m.second is o2) + + def test_in(self): + o1 = NamedObject("foo",True) + o2 = NamedObject("bar",True) + m = get_match(o1,o2) + self.assert_(o1 in m) + self.assert_(o2 in m) + self.assert_(object() not in m) + + def test_word_weight(self): + self.assertEqual(int((6.0 / 13.0) * 100),get_match(NamedObject("foo bar",True),NamedObject("bar bleh",True),(WEIGHT_WORDS,)).percentage) + + +class TCMatchFactory(TestCase): + def test_empty(self): + self.assertEqual([],MatchFactory().getmatches([])) + + def test_defaults(self): + mf = MatchFactory() + self.assertEqual(50,mf.common_word_threshold) + self.assertEqual(False,mf.weight_words) + self.assertEqual(False,mf.match_similar_words) + self.assertEqual(False,mf.no_field_order) + self.assertEqual(0,mf.min_match_percentage) + + def test_simple(self): + l = [NamedObject("foo bar"),NamedObject("bar bleh"),NamedObject("a b c foo")] + r = MatchFactory().getmatches(l) + self.assertEqual(2,len(r)) + seek = [m for m in r if m.percentage == 50] #"foo bar" and "bar bleh" + m = seek[0] + self.assertEqual(['foo','bar'],m.first.words) + self.assertEqual(['bar','bleh'],m.second.words) + seek = [m for m in r if m.percentage == 33] #"foo bar" and "a b c foo" + m = seek[0] + self.assertEqual(['foo','bar'],m.first.words) + self.assertEqual(['a','b','c','foo'],m.second.words) + + def test_null_and_unrelated_objects(self): + l = [NamedObject("foo bar"),NamedObject("bar bleh"),NamedObject(""),NamedObject("unrelated object")] + r = MatchFactory().getmatches(l) + self.assertEqual(1,len(r)) + m = r[0] + self.assertEqual(50,m.percentage) + self.assertEqual(['foo','bar'],m.first.words) + self.assertEqual(['bar','bleh'],m.second.words) + + def test_twice_the_same_word(self): + l = [NamedObject("foo foo bar"),NamedObject("bar bleh")] + r = MatchFactory().getmatches(l) + self.assertEqual(1,len(r)) + + def test_twice_the_same_word_when_preworded(self): + l = [NamedObject("foo foo bar",True),NamedObject("bar bleh",True)] + r = MatchFactory().getmatches(l) + self.assertEqual(1,len(r)) + + def test_two_words_match(self): + l = [NamedObject("foo bar"),NamedObject("foo bar bleh")] + r = MatchFactory().getmatches(l) + self.assertEqual(1,len(r)) + + def test_match_files_with_only_common_words(self): + #If a word occurs more than 50 times, it is excluded from the matching process + #The problem with the common_word_threshold is that the files containing only common + #words will never be matched together. We *should* match them. + mf = MatchFactory() + mf.common_word_threshold = 50 + l = [NamedObject("foo") for i in range(50)] + r = mf.getmatches(l) + self.assertEqual(1225,len(r)) + + def test_use_words_already_there_if_there(self): + o1 = NamedObject('foo') + o2 = NamedObject('bar') + o2.words = ['foo'] + self.assertEqual(1,len(MatchFactory().getmatches([o1,o2]))) + + def test_job(self): + def do_progress(p,d=''): + self.log.append(p) + return True + + j = job.Job(1,do_progress) + self.log = [] + s = "foo bar" + MatchFactory().getmatches([NamedObject(s),NamedObject(s),NamedObject(s)],j) + self.assert_(len(self.log) > 2) + self.assertEqual(0,self.log[0]) + self.assertEqual(100,self.log[-1]) + + def test_weight_words(self): + mf = MatchFactory() + mf.weight_words = True + l = [NamedObject("foo bar"),NamedObject("bar bleh")] + m = mf.getmatches(l)[0] + self.assertEqual(int((6.0 / 13.0) * 100),m.percentage) + + def test_similar_word(self): + mf = MatchFactory() + mf.match_similar_words = True + l = [NamedObject("foobar"),NamedObject("foobars")] + self.assertEqual(1,len(mf.getmatches(l))) + self.assertEqual(100,mf.getmatches(l)[0].percentage) + l = [NamedObject("foobar"),NamedObject("foo")] + self.assertEqual(0,len(mf.getmatches(l))) #too far + l = [NamedObject("bizkit"),NamedObject("bizket")] + self.assertEqual(1,len(mf.getmatches(l))) + l = [NamedObject("foobar"),NamedObject("foosbar")] + self.assertEqual(1,len(mf.getmatches(l))) + + def test_single_object_with_similar_words(self): + mf = MatchFactory() + mf.match_similar_words = True + l = [NamedObject("foo foos")] + self.assertEqual(0,len(mf.getmatches(l))) + + def test_double_words_get_counted_only_once(self): + mf = MatchFactory() + l = [NamedObject("foo bar foo bleh"),NamedObject("foo bar bleh bar")] + m = mf.getmatches(l)[0] + self.assertEqual(75,m.percentage) + + def test_with_fields(self): + mf = MatchFactory() + o1 = NamedObject("foo bar - foo bleh") + o2 = NamedObject("foo bar - bleh bar") + o1.words = getfields(o1.name) + o2.words = getfields(o2.name) + m = mf.getmatches([o1, o2])[0] + self.assertEqual(50, m.percentage) + + def test_with_fields_no_order(self): + mf = MatchFactory() + mf.no_field_order = True + o1 = NamedObject("foo bar - foo bleh") + o2 = NamedObject("bleh bang - foo bar") + o1.words = getfields(o1.name) + o2.words = getfields(o2.name) + m = mf.getmatches([o1, o2])[0] + self.assertEqual(50 ,m.percentage) + + def test_only_match_similar_when_the_option_is_set(self): + mf = MatchFactory() + mf.match_similar_words = False + l = [NamedObject("foobar"),NamedObject("foobars")] + self.assertEqual(0,len(mf.getmatches(l))) + + def test_dont_recurse_do_match(self): + # with nosetests, the stack is increased. The number has to be high enough not to be failing falsely + sys.setrecursionlimit(100) + mf = MatchFactory() + files = [NamedObject('foo bar') for i in range(101)] + try: + mf.getmatches(files) + except RuntimeError: + self.fail() + finally: + sys.setrecursionlimit(1000) + + def test_min_match_percentage(self): + l = [NamedObject("foo bar"),NamedObject("bar bleh"),NamedObject("a b c foo")] + mf = MatchFactory() + mf.min_match_percentage = 50 + r = mf.getmatches(l) + self.assertEqual(1,len(r)) #Only "foo bar" / "bar bleh" should match + + def test_limit(self): + l = [NamedObject(),NamedObject(),NamedObject()] + mf = MatchFactory() + mf.limit = 2 + r = mf.getmatches(l) + self.assertEqual(2,len(r)) + + def test_MemoryError(self): + @log_calls + def mocked_match(first, second, flags): + if len(mocked_match.calls) > 42: + raise MemoryError() + return Match(first, second, 0) + + objects = [NamedObject() for i in range(10)] # results in 45 matches + self.mock(engine, 'get_match', mocked_match) + mf = MatchFactory() + try: + r = mf.getmatches(objects) + except MemoryError: + self.fail('MemorryError must be handled') + self.assertEqual(42, len(r)) + + +class TCGroup(TestCase): + def test_empy(self): + g = Group() + self.assertEqual(None,g.ref) + self.assertEqual([],g.dupes) + self.assertEqual(0,len(g.matches)) + + def test_add_match(self): + g = Group() + m = get_match(NamedObject("foo",True),NamedObject("bar",True)) + g.add_match(m) + self.assert_(g.ref is m.first) + self.assertEqual([m.second],g.dupes) + self.assertEqual(1,len(g.matches)) + self.assert_(m in g.matches) + + def test_multiple_add_match(self): + g = Group() + o1 = NamedObject("a",True) + o2 = NamedObject("b",True) + o3 = NamedObject("c",True) + o4 = NamedObject("d",True) + g.add_match(get_match(o1,o2)) + self.assert_(g.ref is o1) + self.assertEqual([o2],g.dupes) + self.assertEqual(1,len(g.matches)) + g.add_match(get_match(o1,o3)) + self.assertEqual([o2],g.dupes) + self.assertEqual(2,len(g.matches)) + g.add_match(get_match(o2,o3)) + self.assertEqual([o2,o3],g.dupes) + self.assertEqual(3,len(g.matches)) + g.add_match(get_match(o1,o4)) + self.assertEqual([o2,o3],g.dupes) + self.assertEqual(4,len(g.matches)) + g.add_match(get_match(o2,o4)) + self.assertEqual([o2,o3],g.dupes) + self.assertEqual(5,len(g.matches)) + g.add_match(get_match(o3,o4)) + self.assertEqual([o2,o3,o4],g.dupes) + self.assertEqual(6,len(g.matches)) + + def test_len(self): + g = Group() + self.assertEqual(0,len(g)) + g.add_match(get_match(NamedObject("foo",True),NamedObject("bar",True))) + self.assertEqual(2,len(g)) + + def test_add_same_match_twice(self): + g = Group() + m = get_match(NamedObject("foo",True),NamedObject("foo",True)) + g.add_match(m) + self.assertEqual(2,len(g)) + self.assertEqual(1,len(g.matches)) + g.add_match(m) + self.assertEqual(2,len(g)) + self.assertEqual(1,len(g.matches)) + + def test_in(self): + g = Group() + o1 = NamedObject("foo",True) + o2 = NamedObject("bar",True) + self.assert_(o1 not in g) + g.add_match(get_match(o1,o2)) + self.assert_(o1 in g) + self.assert_(o2 in g) + + def test_remove(self): + g = Group() + o1 = NamedObject("foo",True) + o2 = NamedObject("bar",True) + o3 = NamedObject("bleh",True) + g.add_match(get_match(o1,o2)) + g.add_match(get_match(o1,o3)) + g.add_match(get_match(o2,o3)) + self.assertEqual(3,len(g.matches)) + self.assertEqual(3,len(g)) + g.remove_dupe(o3) + self.assertEqual(1,len(g.matches)) + self.assertEqual(2,len(g)) + g.remove_dupe(o1) + self.assertEqual(0,len(g.matches)) + self.assertEqual(0,len(g)) + + def test_remove_with_ref_dupes(self): + g = Group() + o1 = NamedObject("foo",True) + o2 = NamedObject("bar",True) + o3 = NamedObject("bleh",True) + g.add_match(get_match(o1,o2)) + g.add_match(get_match(o1,o3)) + g.add_match(get_match(o2,o3)) + o1.is_ref = True + o2.is_ref = True + g.remove_dupe(o3) + self.assertEqual(0,len(g)) + + def test_switch_ref(self): + o1 = NamedObject(with_words=True) + o2 = NamedObject(with_words=True) + g = Group() + g.add_match(get_match(o1,o2)) + self.assert_(o1 is g.ref) + g.switch_ref(o2) + self.assert_(o2 is g.ref) + self.assertEqual([o1],g.dupes) + g.switch_ref(o2) + self.assert_(o2 is g.ref) + g.switch_ref(NamedObject('',True)) + self.assert_(o2 is g.ref) + + def test_get_match_of(self): + g = Group() + for m in get_match_triangle(): + g.add_match(m) + o = g.dupes[0] + m = g.get_match_of(o) + self.assert_(g.ref in m) + self.assert_(o in m) + self.assert_(g.get_match_of(NamedObject('',True)) is None) + self.assert_(g.get_match_of(g.ref) is None) + + def test_percentage(self): + #percentage should return the avg percentage in relation to the ref + m1,m2,m3 = get_match_triangle() + m1 = Match(m1[0], m1[1], 100) + m2 = Match(m2[0], m2[1], 50) + m3 = Match(m3[0], m3[1], 33) + g = Group() + g.add_match(m1) + g.add_match(m2) + g.add_match(m3) + self.assertEqual(75,g.percentage) + g.switch_ref(g.dupes[0]) + self.assertEqual(66,g.percentage) + g.remove_dupe(g.dupes[0]) + self.assertEqual(33,g.percentage) + g.add_match(m1) + g.add_match(m2) + self.assertEqual(66,g.percentage) + + def test_percentage_on_empty_group(self): + g = Group() + self.assertEqual(0,g.percentage) + + def test_prioritize(self): + m1,m2,m3 = get_match_triangle() + o1 = m1.first + o2 = m1.second + o3 = m2.second + o1.name = 'c' + o2.name = 'b' + o3.name = 'a' + g = Group() + g.add_match(m1) + g.add_match(m2) + g.add_match(m3) + self.assert_(o1 is g.ref) + g.prioritize(lambda x:x.name) + self.assert_(o3 is g.ref) + + def test_prioritize_with_tie_breaker(self): + # if the ref has the same key as one or more of the dupe, run the tie_breaker func among them + g = get_test_group() + o1, o2, o3 = g.ordered + tie_breaker = lambda ref, dupe: dupe is o3 + g.prioritize(lambda x:0, tie_breaker) + self.assertTrue(g.ref is o3) + + def test_prioritize_with_tie_breaker_runs_on_all_dupes(self): + # Even if a dupe is chosen to switch with ref with a tie breaker, we still run the tie breaker + # with other dupes and the newly chosen ref + g = get_test_group() + o1, o2, o3 = g.ordered + o1.foo = 1 + o2.foo = 2 + o3.foo = 3 + tie_breaker = lambda ref, dupe: dupe.foo > ref.foo + g.prioritize(lambda x:0, tie_breaker) + self.assertTrue(g.ref is o3) + + def test_prioritize_with_tie_breaker_runs_only_on_tie_dupes(self): + # The tie breaker only runs on dupes that had the same value for the key_func + g = get_test_group() + o1, o2, o3 = g.ordered + o1.foo = 2 + o2.foo = 2 + o3.foo = 1 + o1.bar = 1 + o2.bar = 2 + o3.bar = 3 + key_func = lambda x: -x.foo + tie_breaker = lambda ref, dupe: dupe.bar > ref.bar + g.prioritize(key_func, tie_breaker) + self.assertTrue(g.ref is o2) + + def test_list_like(self): + g = Group() + o1,o2 = (NamedObject("foo",True),NamedObject("bar",True)) + g.add_match(get_match(o1,o2)) + self.assert_(g[0] is o1) + self.assert_(g[1] is o2) + + def test_clean_matches(self): + g = Group() + o1,o2,o3 = (NamedObject("foo",True),NamedObject("bar",True),NamedObject("baz",True)) + g.add_match(get_match(o1,o2)) + g.add_match(get_match(o1,o3)) + g.clean_matches() + self.assertEqual(1,len(g.matches)) + self.assertEqual(0,len(g.candidates)) + + +class TCget_groups(TestCase): + def test_empty(self): + r = get_groups([]) + self.assertEqual([],r) + + def test_simple(self): + l = [NamedObject("foo bar"),NamedObject("bar bleh")] + matches = MatchFactory().getmatches(l) + m = matches[0] + r = get_groups(matches) + self.assertEqual(1,len(r)) + g = r[0] + self.assert_(g.ref is m.first) + self.assertEqual([m.second],g.dupes) + + def test_group_with_multiple_matches(self): + #This results in 3 matches + l = [NamedObject("foo"),NamedObject("foo"),NamedObject("foo")] + matches = MatchFactory().getmatches(l) + r = get_groups(matches) + self.assertEqual(1,len(r)) + g = r[0] + self.assertEqual(3,len(g)) + + def test_must_choose_a_group(self): + l = [NamedObject("a b"),NamedObject("a b"),NamedObject("b c"),NamedObject("c d"),NamedObject("c d")] + #There will be 2 groups here: group "a b" and group "c d" + #"b c" can go either of them, but not both. + matches = MatchFactory().getmatches(l) + r = get_groups(matches) + self.assertEqual(2,len(r)) + self.assertEqual(5,len(r[0])+len(r[1])) + + def test_should_all_go_in_the_same_group(self): + l = [NamedObject("a b"),NamedObject("a b"),NamedObject("a b"),NamedObject("a b")] + #There will be 2 groups here: group "a b" and group "c d" + #"b c" can fit in both, but it must be in only one of them + matches = MatchFactory().getmatches(l) + r = get_groups(matches) + self.assertEqual(1,len(r)) + + def test_give_priority_to_matches_with_higher_percentage(self): + o1 = NamedObject(with_words=True) + o2 = NamedObject(with_words=True) + o3 = NamedObject(with_words=True) + m1 = Match(o1, o2, 1) + m2 = Match(o2, o3, 2) + r = get_groups([m1,m2]) + self.assertEqual(1,len(r)) + g = r[0] + self.assertEqual(2,len(g)) + self.assert_(o1 not in g) + self.assert_(o2 in g) + self.assert_(o3 in g) + + def test_four_sized_group(self): + l = [NamedObject("foobar") for i in xrange(4)] + m = MatchFactory().getmatches(l) + r = get_groups(m) + self.assertEqual(1,len(r)) + self.assertEqual(4,len(r[0])) + + def test_referenced_by_ref2(self): + o1 = NamedObject(with_words=True) + o2 = NamedObject(with_words=True) + o3 = NamedObject(with_words=True) + m1 = get_match(o1,o2) + m2 = get_match(o3,o1) + m3 = get_match(o3,o2) + r = get_groups([m1,m2,m3]) + self.assertEqual(3,len(r[0])) + + def test_job(self): + def do_progress(p,d=''): + self.log.append(p) + return True + + self.log = [] + j = job.Job(1,do_progress) + m1,m2,m3 = get_match_triangle() + #101%: To make sure it is processed first so the job test works correctly + m4 = Match(NamedObject('a',True), NamedObject('a',True), 101) + get_groups([m1,m2,m3,m4],j) + self.assertEqual(0,self.log[0]) + self.assertEqual(100,self.log[-1]) + + +if __name__ == "__main__": + unittest.main() diff --git a/py/export.py b/py/export.py new file mode 100644 index 00000000..c6293a5d --- /dev/null +++ b/py/export.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.export +Created By: Virgil Dupras +Created On: 2006/09/16 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +from xml.dom import minidom +import tempfile +import os.path as op +import os +from StringIO import StringIO + +from hsutil.files import FileOrPath + +def output_column_xml(outfile, columns): + """Creates a xml file outfile with the supplied columns. + + outfile can be a filename or a file object. + columns is a list of 2 sized tuples (display,enabled) + """ + doc = minidom.Document() + root = doc.appendChild(doc.createElement('columns')) + for display,enabled in columns: + col_node = root.appendChild(doc.createElement('column')) + col_node.setAttribute('display', display) + col_node.setAttribute('enabled', {True:'y',False:'n'}[enabled]) + with FileOrPath(outfile, 'wb') as fp: + doc.writexml(fp, '\t','\t','\n', encoding='utf-8') + +def merge_css_into_xhtml(xhtml, css): + with FileOrPath(xhtml, 'r+') as xhtml: + with FileOrPath(css) as css: + try: + doc = minidom.parse(xhtml) + except Exception: + return False + head = doc.getElementsByTagName('head')[0] + links = head.getElementsByTagName('link') + for link in links: + if link.getAttribute('rel') == 'stylesheet': + head.removeChild(link) + style = head.appendChild(doc.createElement('style')) + style.setAttribute('type','text/css') + style.appendChild(doc.createTextNode(css.read())) + xhtml.truncate(0) + doc.writexml(xhtml, '\t','\t','\n', encoding='utf-8') + xhtml.seek(0) + return True + +def export_to_xhtml(xml, xslt, css, columns, cmd='xsltproc --path "%(folder)s" "%(xslt)s" "%(xml)s"'): + folder = op.split(xml)[0] + output_column_xml(op.join(folder,'columns.xml'),columns) + html = StringIO() + cmd = cmd % {'folder': folder, 'xslt': xslt, 'xml': xml} + html.write(os.popen(cmd).read()) + html.seek(0) + merge_css_into_xhtml(html,css) + html.seek(0) + html_path = op.join(folder,'export.htm') + html_file = open(html_path,'w') + html_file.write(html.read().encode('utf-8')) + html_file.close() + return html_path diff --git a/py/export_test.py b/py/export_test.py new file mode 100644 index 00000000..5c4a6d87 --- /dev/null +++ b/py/export_test.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.tests.export +Created By: Virgil Dupras +Created On: 2006/09/16 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import unittest +from xml.dom import minidom +from StringIO import StringIO + +from hsutil.testcase import TestCase + +from .export import * +from . import export + +class TCoutput_columns_xml(TestCase): + def test_empty_columns(self): + f = StringIO() + output_column_xml(f,[]) + f.seek(0) + doc = minidom.parse(f) + root = doc.documentElement + self.assertEqual('columns',root.nodeName) + self.assertEqual(0,len(root.childNodes)) + + def test_some_columns(self): + f = StringIO() + output_column_xml(f,[('foo',True),('bar',False),('baz',True)]) + f.seek(0) + doc = minidom.parse(f) + columns = doc.getElementsByTagName('column') + self.assertEqual(3,len(columns)) + c1,c2,c3 = columns + self.assertEqual('foo',c1.getAttribute('display')) + self.assertEqual('bar',c2.getAttribute('display')) + self.assertEqual('baz',c3.getAttribute('display')) + self.assertEqual('y',c1.getAttribute('enabled')) + self.assertEqual('n',c2.getAttribute('enabled')) + self.assertEqual('y',c3.getAttribute('enabled')) + + +class TCmerge_css_into_xhtml(TestCase): + def test_main(self): + css = StringIO() + css.write('foobar') + css.seek(0) + xhtml = StringIO() + xhtml.write(""" + + + + + dupeGuru - Duplicate file scanner + + + + + + """) + xhtml.seek(0) + self.assert_(merge_css_into_xhtml(xhtml,css)) + xhtml.seek(0) + doc = minidom.parse(xhtml) + head = doc.getElementsByTagName('head')[0] + #A style node should have been added in head. + styles = head.getElementsByTagName('style') + self.assertEqual(1,len(styles)) + style = styles[0] + self.assertEqual('text/css',style.getAttribute('type')) + self.assertEqual('foobar',style.firstChild.nodeValue.strip()) + #all should be removed + self.assertEqual(1,len(head.getElementsByTagName('link'))) + + def test_empty(self): + self.assert_(not merge_css_into_xhtml(StringIO(),StringIO())) + + def test_malformed(self): + xhtml = StringIO() + xhtml.write(""" + + """) + xhtml.seek(0) + self.assert_(not merge_css_into_xhtml(xhtml,StringIO())) + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/py/gen.py b/py/gen.py new file mode 100644 index 00000000..0a842372 --- /dev/null +++ b/py/gen.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# Unit Name: gen +# Created By: Virgil Dupras +# Created On: 2009-05-26 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import os +import os.path as op + +def move(src, dst): + if not op.exists(src): + return + if op.exists(dst): + os.remove(dst) + print 'Moving %s --> %s' % (src, dst) + os.rename(src, dst) + + +os.chdir(op.join('modules', 'block')) +os.system('python setup.py build_ext --inplace') +os.chdir(op.join('..', 'cache')) +os.system('python setup.py build_ext --inplace') +os.chdir(op.join('..', '..')) +move(op.join('modules', 'block', '_block.so'), op.join('picture', '_block.so')) +move(op.join('modules', 'block', '_block.pyd'), op.join('picture', '_block.pyd')) +move(op.join('modules', 'cache', '_cache.so'), op.join('picture', '_cache.so')) +move(op.join('modules', 'cache', '_cache.pyd'), op.join('picture', '_cache.pyd')) diff --git a/py/ignore.py b/py/ignore.py new file mode 100644 index 00000000..97060786 --- /dev/null +++ b/py/ignore.py @@ -0,0 +1,117 @@ +#!/usr/bin/env python +""" +Unit Name: ignore +Created By: Virgil Dupras +Created On: 2006/05/02 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +from hsutil.files import FileOrPath + +import xml.dom.minidom + +class IgnoreList(object): + """An ignore list implementation that is iterable, filterable and exportable to XML. + + Call Ignore to add an ignore list entry, and AreIgnore to check if 2 items are in the list. + When iterated, 2 sized tuples will be returned, the tuples containing 2 items ignored together. + """ + #---Override + def __init__(self): + self._ignored = {} + self._count = 0 + + def __iter__(self): + for first,seconds in self._ignored.iteritems(): + for second in seconds: + yield (first,second) + + def __len__(self): + return self._count + + #---Public + def AreIgnored(self,first,second): + def do_check(first,second): + try: + matches = self._ignored[first] + return second in matches + except KeyError: + return False + + return do_check(first,second) or do_check(second,first) + + def Clear(self): + self._ignored = {} + self._count = 0 + + def Filter(self,func): + """Applies a filter on all ignored items, and remove all matches where func(first,second) + doesn't return True. + """ + filtered = IgnoreList() + for first,second in self: + if func(first,second): + filtered.Ignore(first,second) + self._ignored = filtered._ignored + self._count = filtered._count + + def Ignore(self,first,second): + if self.AreIgnored(first,second): + return + try: + matches = self._ignored[first] + matches.add(second) + except KeyError: + try: + matches = self._ignored[second] + matches.add(first) + except KeyError: + matches = set() + matches.add(second) + self._ignored[first] = matches + self._count += 1 + + def load_from_xml(self,infile): + """Loads the ignore list from a XML created with save_to_xml. + + infile can be a file object or a filename. + """ + try: + doc = xml.dom.minidom.parse(infile) + except Exception: + return + file_nodes = doc.getElementsByTagName('file') + for fn in file_nodes: + if not fn.getAttributeNode('path'): + continue + file_path = fn.getAttributeNode('path').nodeValue + subfile_nodes = fn.getElementsByTagName('file') + for sfn in subfile_nodes: + if not sfn.getAttributeNode('path'): + continue + subfile_path = sfn.getAttributeNode('path').nodeValue + self.Ignore(file_path,subfile_path) + + def save_to_xml(self,outfile): + """Create a XML file that can be used by load_from_xml. + + outfile can be a file object or a filename. + """ + doc = xml.dom.minidom.Document() + root = doc.appendChild(doc.createElement('ignore_list')) + for file,subfiles in self._ignored.items(): + file_node = root.appendChild(doc.createElement('file')) + if isinstance(file,unicode): + file = file.encode('utf-8') + file_node.setAttribute('path',file) + for subfile in subfiles: + subfile_node = file_node.appendChild(doc.createElement('file')) + if isinstance(subfile,unicode): + subfile = subfile.encode('utf-8') + subfile_node.setAttribute('path',subfile) + with FileOrPath(outfile, 'wb') as fp: + doc.writexml(fp,'\t','\t','\n',encoding='utf-8') + + diff --git a/py/ignore_test.py b/py/ignore_test.py new file mode 100644 index 00000000..8ff91f52 --- /dev/null +++ b/py/ignore_test.py @@ -0,0 +1,158 @@ +#!/usr/bin/env python +""" +Unit Name: ignore +Created By: Virgil Dupras +Created On: 2006/05/02 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import unittest +import cStringIO +import xml.dom.minidom + +from .ignore import * + +class TCIgnoreList(unittest.TestCase): + def test_empty(self): + il = IgnoreList() + self.assertEqual(0,len(il)) + self.assert_(not il.AreIgnored('foo','bar')) + + def test_simple(self): + il = IgnoreList() + il.Ignore('foo','bar') + self.assert_(il.AreIgnored('foo','bar')) + self.assert_(il.AreIgnored('bar','foo')) + self.assert_(not il.AreIgnored('foo','bleh')) + self.assert_(not il.AreIgnored('bleh','bar')) + self.assertEqual(1,len(il)) + + def test_multiple(self): + il = IgnoreList() + il.Ignore('foo','bar') + il.Ignore('foo','bleh') + il.Ignore('bleh','bar') + il.Ignore('aybabtu','bleh') + self.assert_(il.AreIgnored('foo','bar')) + self.assert_(il.AreIgnored('bar','foo')) + self.assert_(il.AreIgnored('foo','bleh')) + self.assert_(il.AreIgnored('bleh','bar')) + self.assert_(not il.AreIgnored('aybabtu','bar')) + self.assertEqual(4,len(il)) + + def test_clear(self): + il = IgnoreList() + il.Ignore('foo','bar') + il.Clear() + self.assert_(not il.AreIgnored('foo','bar')) + self.assert_(not il.AreIgnored('bar','foo')) + self.assertEqual(0,len(il)) + + def test_add_same_twice(self): + il = IgnoreList() + il.Ignore('foo','bar') + il.Ignore('bar','foo') + self.assertEqual(1,len(il)) + + def test_save_to_xml(self): + il = IgnoreList() + il.Ignore('foo','bar') + il.Ignore('foo','bleh') + il.Ignore('bleh','bar') + f = cStringIO.StringIO() + il.save_to_xml(f) + f.seek(0) + doc = xml.dom.minidom.parse(f) + root = doc.documentElement + self.assertEqual('ignore_list',root.nodeName) + children = [c for c in root.childNodes if c.localName] + self.assertEqual(2,len(children)) + self.assertEqual(2,len([c for c in children if c.nodeName == 'file'])) + f1,f2 = children + subchildren = [c for c in f1.childNodes if c.localName == 'file'] +\ + [c for c in f2.childNodes if c.localName == 'file'] + self.assertEqual(3,len(subchildren)) + + def test_SaveThenLoad(self): + il = IgnoreList() + il.Ignore('foo','bar') + il.Ignore('foo','bleh') + il.Ignore('bleh','bar') + il.Ignore(u'\u00e9','bar') + f = cStringIO.StringIO() + il.save_to_xml(f) + f.seek(0) + il = IgnoreList() + il.load_from_xml(f) + self.assertEqual(4,len(il)) + self.assert_(il.AreIgnored(u'\u00e9','bar')) + + def test_LoadXML_with_empty_file_tags(self): + f = cStringIO.StringIO() + f.write('') + f.seek(0) + il = IgnoreList() + il.load_from_xml(f) + self.assertEqual(0,len(il)) + + def test_AreIgnore_works_when_a_child_is_a_key_somewhere_else(self): + il = IgnoreList() + il.Ignore('foo','bar') + il.Ignore('bar','baz') + self.assert_(il.AreIgnored('bar','foo')) + + + def test_no_dupes_when_a_child_is_a_key_somewhere_else(self): + il = IgnoreList() + il.Ignore('foo','bar') + il.Ignore('bar','baz') + il.Ignore('bar','foo') + self.assertEqual(2,len(il)) + + def test_iterate(self): + #It must be possible to iterate through ignore list + il = IgnoreList() + expected = [('foo','bar'),('bar','baz'),('foo','baz')] + for i in expected: + il.Ignore(i[0],i[1]) + for i in il: + expected.remove(i) #No exception should be raised + self.assert_(not expected) #expected should be empty + + def test_filter(self): + il = IgnoreList() + il.Ignore('foo','bar') + il.Ignore('bar','baz') + il.Ignore('foo','baz') + il.Filter(lambda f,s: f == 'bar') + self.assertEqual(1,len(il)) + self.assert_(not il.AreIgnored('foo','bar')) + self.assert_(il.AreIgnored('bar','baz')) + + def test_save_with_non_ascii_non_unicode_items(self): + il = IgnoreList() + il.Ignore('\xac','\xbf') + f = cStringIO.StringIO() + try: + il.save_to_xml(f) + except Exception,e: + self.fail(str(e)) + + def test_len(self): + il = IgnoreList() + self.assertEqual(0,len(il)) + il.Ignore('foo','bar') + self.assertEqual(1,len(il)) + + def test_nonzero(self): + il = IgnoreList() + self.assert_(not il) + il.Ignore('foo','bar') + self.assert_(il) + + +if __name__ == "__main__": + unittest.main() + diff --git a/py/modules/block/block.pyx b/py/modules/block/block.pyx new file mode 100644 index 00000000..db4c7500 --- /dev/null +++ b/py/modules/block/block.pyx @@ -0,0 +1,93 @@ +# Created By: Virgil Dupras +# Created On: 2009-04-23 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +cdef extern from "stdlib.h": + int abs(int n) # required so that abs() is applied on ints, not python objects + +class NoBlocksError(Exception): + """avgdiff/maxdiff has been called with empty lists""" + +class DifferentBlockCountError(Exception): + """avgdiff/maxdiff has been called with 2 block lists of different size.""" + + +cdef object getblock(object image): + """Returns a 3 sized tuple containing the mean color of 'image'. + + image: a PIL image or crop. + """ + cdef int pixel_count, red, green, blue, r, g, b + if image.size[0]: + pixel_count = image.size[0] * image.size[1] + red = green = blue = 0 + for r, g, b in image.getdata(): + red += r + green += g + blue += b + return (red // pixel_count, green // pixel_count, blue // pixel_count) + else: + return (0, 0, 0) + +def getblocks2(image, int block_count_per_side): + """Returns a list of blocks (3 sized tuples). + + image: A PIL image to base the blocks on. + block_count_per_side: This integer determine the number of blocks the function will return. + If it is 10, for example, 100 blocks will be returns (10 width, 10 height). The blocks will not + necessarely cover square areas. The area covered by each block will be proportional to the image + itself. + """ + if not image.size[0]: + return [] + cdef int width, height, block_width, block_height, ih, iw, top, bottom, left, right + width, height = image.size + block_width = max(width // block_count_per_side, 1) + block_height = max(height // block_count_per_side, 1) + result = [] + for ih in range(block_count_per_side): + top = min(ih * block_height, height - block_height) + bottom = top + block_height + for iw in range(block_count_per_side): + left = min(iw * block_width, width - block_width) + right = left + block_width + box = (left, top, right, bottom) + crop = image.crop(box) + result.append(getblock(crop)) + return result + +cdef int diff(first, second): + """Returns the difference between the first block and the second. + + It returns an absolute sum of the 3 differences (RGB). + """ + cdef int r1, g1, b1, r2, g2, b2 + r1, g1, b1 = first + r2, g2, b2 = second + return abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2) + +def avgdiff(first, second, int limit, int min_iterations): + """Returns the average diff between first blocks and seconds. + + If the result surpasses limit, limit + 1 is returned, except if less than min_iterations + iterations have been made in the blocks. + """ + cdef int count, sum, i, iteration_count + count = len(first) + if count != len(second): + raise DifferentBlockCountError() + if not count: + raise NoBlocksError() + sum = 0 + for i in range(count): + iteration_count = i + 1 + item1 = first[i] + item2 = second[i] + sum += diff(item1, item2) + if sum > limit * iteration_count and iteration_count >= min_iterations: + return limit + 1 + result = sum // count + if (not result) and sum: + result = 1 + return result \ No newline at end of file diff --git a/py/modules/block/setup.py b/py/modules/block/setup.py new file mode 100644 index 00000000..9d8f4cb5 --- /dev/null +++ b/py/modules/block/setup.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +# Created By: Virgil Dupras +# Created On: 2009-04-23 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from distutils.core import setup +from distutils.extension import Extension +from Cython.Distutils import build_ext + +setup( + cmdclass = {'build_ext': build_ext}, + ext_modules = [Extension("_block", ["block.pyx"])] +) \ No newline at end of file diff --git a/py/modules/cache/cache.pyx b/py/modules/cache/cache.pyx new file mode 100644 index 00000000..7bd2407d --- /dev/null +++ b/py/modules/cache/cache.pyx @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# Created By: Virgil Dupras +# Created On: 2009-04-23 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +# ok, this is hacky and stuff, but I don't know C well enough to play with char buffers, copy +# them around and stuff +cdef int xchar_to_int(char c): + if 48 <= c <= 57: # 0-9 + return c - 48 + elif 65 <= c <= 70: # A-F + return c - 55 + elif 97 <= c <= 102: # a-f + return c - 87 + +def string_to_colors(s): + """Transform the string 's' in a list of 3 sized tuples. + """ + result = [] + cdef int i, char_count, r, g, b + cdef char* cs + char_count = len(s) + char_count = (char_count // 6) * 6 + cs = s + for i in range(0, char_count, 6): + r = xchar_to_int(cs[i]) << 4 + r += xchar_to_int(cs[i+1]) + g = xchar_to_int(cs[i+2]) << 4 + g += xchar_to_int(cs[i+3]) + b = xchar_to_int(cs[i+4]) << 4 + b += xchar_to_int(cs[i+5]) + result.append((r, g, b)) + return result diff --git a/py/modules/cache/setup.py b/py/modules/cache/setup.py new file mode 100644 index 00000000..2b6cd31b --- /dev/null +++ b/py/modules/cache/setup.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +# Created By: Virgil Dupras +# Created On: 2009-04-23 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from distutils.core import setup +from distutils.extension import Extension +from Cython.Distutils import build_ext + +setup( + cmdclass = {'build_ext': build_ext}, + ext_modules = [Extension("_cache", ["cache.pyx"])] +) \ No newline at end of file diff --git a/py/picture/__init__.py b/py/picture/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/py/picture/block.py b/py/picture/block.py new file mode 100644 index 00000000..70015a50 --- /dev/null +++ b/py/picture/block.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python +""" +Unit Name: hs.picture.block +Created By: Virgil Dupras +Created On: 2006/09/01 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-26 18:12:39 +0200 (Tue, 26 May 2009) $ + $Revision: 4365 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +from _block import NoBlocksError, DifferentBlockCountError, avgdiff, getblocks2 + +# Converted to Cython +# def getblock(image): +# """Returns a 3 sized tuple containing the mean color of 'image'. +# +# image: a PIL image or crop. +# """ +# if image.size[0]: +# pixel_count = image.size[0] * image.size[1] +# red = green = blue = 0 +# for r,g,b in image.getdata(): +# red += r +# green += g +# blue += b +# return (red // pixel_count, green // pixel_count, blue // pixel_count) +# else: +# return (0,0,0) + +# This is not used anymore +# def getblocks(image,blocksize): +# """Returns a list of blocks (3 sized tuples). +# +# image: A PIL image to base the blocks on. +# blocksize: The size of the blocks to be create. This is a single integer, defining +# both width and height (blocks are square). +# """ +# if min(image.size) < blocksize: +# return () +# result = [] +# for i in xrange(image.size[1] // blocksize): +# for j in xrange(image.size[0] // blocksize): +# box = (blocksize * j, blocksize * i, blocksize * (j + 1), blocksize * (i + 1)) +# crop = image.crop(box) +# result.append(getblock(crop)) +# return result + +# Converted to Cython +# def getblocks2(image,block_count_per_side): +# """Returns a list of blocks (3 sized tuples). +# +# image: A PIL image to base the blocks on. +# block_count_per_side: This integer determine the number of blocks the function will return. +# If it is 10, for example, 100 blocks will be returns (10 width, 10 height). The blocks will not +# necessarely cover square areas. The area covered by each block will be proportional to the image +# itself. +# """ +# if not image.size[0]: +# return [] +# width,height = image.size +# block_width = max(width // block_count_per_side,1) +# block_height = max(height // block_count_per_side,1) +# result = [] +# for ih in range(block_count_per_side): +# top = min(ih * block_height, height - block_height) +# bottom = top + block_height +# for iw in range(block_count_per_side): +# left = min(iw * block_width, width - block_width) +# right = left + block_width +# box = (left,top,right,bottom) +# crop = image.crop(box) +# result.append(getblock(crop)) +# return result + +# Converted to Cython +# def diff(first, second): +# """Returns the difference between the first block and the second. +# +# It returns an absolute sum of the 3 differences (RGB). +# """ +# r1, g1, b1 = first +# r2, g2, b2 = second +# return abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2) + +# Converted to Cython +# def avgdiff(first, second, limit=768, min_iterations=1): +# """Returns the average diff between first blocks and seconds. +# +# If the result surpasses limit, limit + 1 is returned, except if less than min_iterations +# iterations have been made in the blocks. +# """ +# if len(first) != len(second): +# raise DifferentBlockCountError +# if not first: +# raise NoBlocksError +# count = len(first) +# sum = 0 +# zipped = izip(xrange(1, count + 1), first, second) +# for i, first, second in zipped: +# sum += diff(first, second) +# if sum > limit * i and i >= min_iterations: +# return limit + 1 +# result = sum // count +# if (not result) and sum: +# result = 1 +# return result + +# This is not used anymore +# def maxdiff(first,second,limit=768): +# """Returns the max diff between first blocks and seconds. +# +# If the result surpasses limit, the first max being over limit is returned. +# """ +# if len(first) != len(second): +# raise DifferentBlockCountError +# if not first: +# raise NoBlocksError +# result = 0 +# zipped = zip(first,second) +# for first,second in zipped: +# result = max(result,diff(first,second)) +# if result > limit: +# return result +# return result diff --git a/py/picture/block_test.py b/py/picture/block_test.py new file mode 100644 index 00000000..a06cf617 --- /dev/null +++ b/py/picture/block_test.py @@ -0,0 +1,313 @@ +#!/usr/bin/env python +""" +Unit Name: tests.picture.block +Created By: Virgil Dupras +Created On: 2006/09/01 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +# The commented out tests are tests for function that have been converted to pure C for speed +import unittest + +from .block import * + +def my_avgdiff(first, second, limit=768, min_iter=3): # this is so I don't have to re-write every call + return avgdiff(first, second, limit, min_iter) + +BLACK = (0,0,0) +RED = (0xff,0,0) +GREEN = (0,0xff,0) +BLUE = (0,0,0xff) + +class FakeImage(object): + def __init__(self, size, data): + self.size = size + self.data = data + + def getdata(self): + return self.data + + def crop(self, box): + pixels = [] + for i in range(box[1], box[3]): + for j in range(box[0], box[2]): + pixel = self.data[i * self.size[0] + j] + pixels.append(pixel) + return FakeImage((box[2] - box[0], box[3] - box[1]), pixels) + +def empty(): + return FakeImage((0,0), []) + +def single_pixel(): #one red pixel + return FakeImage((1, 1), [(0xff,0,0)]) + +def four_pixels(): + pixels = [RED,(0,0x80,0xff),(0x80,0,0),(0,0x40,0x80)] + return FakeImage((2, 2), pixels) + +class TCgetblock(unittest.TestCase): + def test_single_pixel(self): + im = single_pixel() + [b] = getblocks2(im, 1) + self.assertEqual(RED,b) + + def test_no_pixel(self): + im = empty() + self.assertEqual([], getblocks2(im, 1)) + + def test_four_pixels(self): + im = four_pixels() + [b] = getblocks2(im, 1) + meanred = (0xff + 0x80) // 4 + meangreen = (0x80 + 0x40) // 4 + meanblue = (0xff + 0x80) // 4 + self.assertEqual((meanred,meangreen,meanblue),b) + + +# class TCdiff(unittest.TestCase): +# def test_diff(self): +# b1 = (10, 20, 30) +# b2 = (1, 2, 3) +# self.assertEqual(9 + 18 + 27,diff(b1,b2)) +# +# def test_diff_negative(self): +# b1 = (10, 20, 30) +# b2 = (1, 2, 3) +# self.assertEqual(9 + 18 + 27,diff(b2,b1)) +# +# def test_diff_mixed_positive_and_negative(self): +# b1 = (1, 5, 10) +# b2 = (10, 1, 15) +# self.assertEqual(9 + 4 + 5,diff(b1,b2)) +# + +# class TCgetblocks(unittest.TestCase): +# def test_empty_image(self): +# im = empty() +# blocks = getblocks(im,1) +# self.assertEqual(0,len(blocks)) +# +# def test_one_block_image(self): +# im = four_pixels() +# blocks = getblocks2(im, 1) +# self.assertEqual(1,len(blocks)) +# block = blocks[0] +# meanred = (0xff + 0x80) // 4 +# meangreen = (0x80 + 0x40) // 4 +# meanblue = (0xff + 0x80) // 4 +# self.assertEqual((meanred,meangreen,meanblue),block) +# +# def test_not_enough_height_to_fit_a_block(self): +# im = FakeImage((2,1), [BLACK, BLACK]) +# blocks = getblocks(im,2) +# self.assertEqual(0,len(blocks)) +# +# def xtest_dont_include_leftovers(self): +# # this test is disabled because getblocks is not used and getblock in cdeffed +# pixels = [ +# RED,(0,0x80,0xff),BLACK, +# (0x80,0,0),(0,0x40,0x80),BLACK, +# BLACK,BLACK,BLACK +# ] +# im = FakeImage((3,3), pixels) +# blocks = getblocks(im,2) +# block = blocks[0] +# #Because the block is smaller than the image, only blocksize must be considered. +# meanred = (0xff + 0x80) // 4 +# meangreen = (0x80 + 0x40) // 4 +# meanblue = (0xff + 0x80) // 4 +# self.assertEqual((meanred,meangreen,meanblue),block) +# +# def xtest_two_blocks(self): +# # this test is disabled because getblocks is not used and getblock in cdeffed +# pixels = [BLACK for i in xrange(4 * 2)] +# pixels[0] = RED +# pixels[1] = (0,0x80,0xff) +# pixels[4] = (0x80,0,0) +# pixels[5] = (0,0x40,0x80) +# im = FakeImage((4, 2), pixels) +# blocks = getblocks(im,2) +# self.assertEqual(2,len(blocks)) +# block = blocks[0] +# #Because the block is smaller than the image, only blocksize must be considered. +# meanred = (0xff + 0x80) // 4 +# meangreen = (0x80 + 0x40) // 4 +# meanblue = (0xff + 0x80) // 4 +# self.assertEqual((meanred,meangreen,meanblue),block) +# self.assertEqual(BLACK,blocks[1]) +# +# def test_four_blocks(self): +# pixels = [BLACK for i in xrange(4 * 4)] +# pixels[0] = RED +# pixels[1] = (0,0x80,0xff) +# pixels[4] = (0x80,0,0) +# pixels[5] = (0,0x40,0x80) +# im = FakeImage((4, 4), pixels) +# blocks = getblocks2(im, 2) +# self.assertEqual(4,len(blocks)) +# block = blocks[0] +# #Because the block is smaller than the image, only blocksize must be considered. +# meanred = (0xff + 0x80) // 4 +# meangreen = (0x80 + 0x40) // 4 +# meanblue = (0xff + 0x80) // 4 +# self.assertEqual((meanred,meangreen,meanblue),block) +# self.assertEqual(BLACK,blocks[1]) +# self.assertEqual(BLACK,blocks[2]) +# self.assertEqual(BLACK,blocks[3]) +# + +class TCgetblocks2(unittest.TestCase): + def test_empty_image(self): + im = empty() + blocks = getblocks2(im,1) + self.assertEqual(0,len(blocks)) + + def test_one_block_image(self): + im = four_pixels() + blocks = getblocks2(im,1) + self.assertEqual(1,len(blocks)) + block = blocks[0] + meanred = (0xff + 0x80) // 4 + meangreen = (0x80 + 0x40) // 4 + meanblue = (0xff + 0x80) // 4 + self.assertEqual((meanred,meangreen,meanblue),block) + + def test_four_blocks_all_black(self): + im = FakeImage((2, 2), [BLACK, BLACK, BLACK, BLACK]) + blocks = getblocks2(im,2) + self.assertEqual(4,len(blocks)) + for block in blocks: + self.assertEqual(BLACK,block) + + def test_two_pixels_image_horizontal(self): + pixels = [RED,BLUE] + im = FakeImage((2, 1), pixels) + blocks = getblocks2(im,2) + self.assertEqual(4,len(blocks)) + self.assertEqual(RED,blocks[0]) + self.assertEqual(BLUE,blocks[1]) + self.assertEqual(RED,blocks[2]) + self.assertEqual(BLUE,blocks[3]) + + def test_two_pixels_image_vertical(self): + pixels = [RED,BLUE] + im = FakeImage((1, 2), pixels) + blocks = getblocks2(im,2) + self.assertEqual(4,len(blocks)) + self.assertEqual(RED,blocks[0]) + self.assertEqual(RED,blocks[1]) + self.assertEqual(BLUE,blocks[2]) + self.assertEqual(BLUE,blocks[3]) + + +class TCavgdiff(unittest.TestCase): + def test_empty(self): + self.assertRaises(NoBlocksError, my_avgdiff, [], []) + + def test_two_blocks(self): + im = empty() + b1 = (5,10,15) + b2 = (255,250,245) + b3 = (0,0,0) + b4 = (255,0,255) + blocks1 = [b1,b2] + blocks2 = [b3,b4] + expected1 = 5 + 10 + 15 + expected2 = 0 + 250 + 10 + expected = (expected1 + expected2) // 2 + self.assertEqual(expected, my_avgdiff(blocks1, blocks2)) + + def test_blocks_not_the_same_size(self): + b = (0,0,0) + self.assertRaises(DifferentBlockCountError,my_avgdiff,[b,b],[b]) + + def test_first_arg_is_empty_but_not_second(self): + #Don't return 0 (as when the 2 lists are empty), raise! + b = (0,0,0) + self.assertRaises(DifferentBlockCountError,my_avgdiff,[],[b]) + + def test_limit(self): + ref = (0,0,0) + b1 = (10,10,10) #avg 30 + b2 = (20,20,20) #avg 45 + b3 = (30,30,30) #avg 60 + blocks1 = [ref,ref,ref] + blocks2 = [b1,b2,b3] + self.assertEqual(45,my_avgdiff(blocks1,blocks2,44)) + + def test_min_iterations(self): + ref = (0,0,0) + b1 = (10,10,10) #avg 30 + b2 = (20,20,20) #avg 45 + b3 = (10,10,10) #avg 40 + blocks1 = [ref,ref,ref] + blocks2 = [b1,b2,b3] + self.assertEqual(40,my_avgdiff(blocks1,blocks2,45 - 1,3)) + + # Bah, I don't know why this test fails, but I don't think it matters very much + # def test_just_over_the_limit(self): + # #A score just over the limit might return exactly the limit due to truncating. We should + # #ceil() the result in this case. + # ref = (0,0,0) + # b1 = (10,0,0) + # b2 = (11,0,0) + # blocks1 = [ref,ref] + # blocks2 = [b1,b2] + # self.assertEqual(11,my_avgdiff(blocks1,blocks2,10)) + # + def test_return_at_least_1_at_the_slightest_difference(self): + ref = (0,0,0) + b1 = (1,0,0) + blocks1 = [ref for i in xrange(250)] + blocks2 = [ref for i in xrange(250)] + blocks2[0] = b1 + self.assertEqual(1,my_avgdiff(blocks1,blocks2)) + + def test_return_0_if_there_is_no_difference(self): + ref = (0,0,0) + blocks1 = [ref,ref] + blocks2 = [ref,ref] + self.assertEqual(0,my_avgdiff(blocks1,blocks2)) + + +# class TCmaxdiff(unittest.TestCase): +# def test_empty(self): +# self.assertRaises(NoBlocksError,maxdiff,[],[]) +# +# def test_two_blocks(self): +# b1 = (5,10,15) +# b2 = (255,250,245) +# b3 = (0,0,0) +# b4 = (255,0,255) +# blocks1 = [b1,b2] +# blocks2 = [b3,b4] +# expected1 = 5 + 10 + 15 +# expected2 = 0 + 250 + 10 +# expected = max(expected1,expected2) +# self.assertEqual(expected,maxdiff(blocks1,blocks2)) +# +# def test_blocks_not_the_same_size(self): +# b = (0,0,0) +# self.assertRaises(DifferentBlockCountError,maxdiff,[b,b],[b]) +# +# def test_first_arg_is_empty_but_not_second(self): +# #Don't return 0 (as when the 2 lists are empty), raise! +# b = (0,0,0) +# self.assertRaises(DifferentBlockCountError,maxdiff,[],[b]) +# +# def test_limit(self): +# b1 = (5,10,15) +# b2 = (255,250,245) +# b3 = (0,0,0) +# b4 = (255,0,255) +# blocks1 = [b1,b2] +# blocks2 = [b3,b4] +# expected1 = 5 + 10 + 15 +# expected2 = 0 + 250 + 10 +# self.assertEqual(expected1,maxdiff(blocks1,blocks2,expected1 - 1)) +# + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/py/picture/cache.py b/py/picture/cache.py new file mode 100644 index 00000000..6ff0d2d1 --- /dev/null +++ b/py/picture/cache.py @@ -0,0 +1,134 @@ +#!/usr/bin/env python +""" +Unit Name: hs.picture.cache +Created By: Virgil Dupras +Created On: 2006/09/14 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:33:32 +0200 (Thu, 28 May 2009) $ + $Revision: 4392 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import os +import logging +import sqlite3 as sqlite + +import hsutil.sqlite + +from _cache import string_to_colors + +def colors_to_string(colors): + """Transform the 3 sized tuples 'colors' into a hex string. + + [(0,100,255)] --> 0064ff + [(1,2,3),(4,5,6)] --> 010203040506 + """ + return ''.join(['%02x%02x%02x' % (r,g,b) for r,g,b in colors]) + +# This function is an important bottleneck of dupeGuru PE. It has been converted to Cython. +# def string_to_colors(s): +# """Transform the string 's' in a list of 3 sized tuples. +# """ +# result = [] +# for i in xrange(0, len(s), 6): +# number = int(s[i:i+6], 16) +# result.append((number >> 16, (number >> 8) & 0xff, number & 0xff)) +# return result + +class Cache(object): + """A class to cache picture blocks. + """ + def __init__(self, db=':memory:', threaded=True): + def create_tables(): + sql = "create table pictures(path TEXT, blocks TEXT)" + self.con.execute(sql); + sql = "create index idx_path on pictures (path)" + self.con.execute(sql) + + self.dbname = db + if threaded: + self.con = hsutil.sqlite.ThreadedConn(db, True) + else: + self.con = sqlite.connect(db, isolation_level=None) + try: + self.con.execute("select * from pictures where 1=2") + except sqlite.OperationalError: # new db + create_tables() + except sqlite.DatabaseError, e: # corrupted db + logging.warning('Could not create picture cache because of an error: %s', str(e)) + self.con.close() + os.remove(db) + if threaded: + self.con = hsutil.sqlite.ThreadedConn(db, True) + else: + self.con = sqlite.connect(db, isolation_level=None) + create_tables() + + def __contains__(self, key): + sql = "select count(*) from pictures where path = ?" + result = self.con.execute(sql, [key]).fetchall() + return result[0][0] > 0 + + def __delitem__(self, key): + if key not in self: + raise KeyError(key) + sql = "delete from pictures where path = ?" + self.con.execute(sql, [key]) + + # Optimized + def __getitem__(self, key): + if isinstance(key, int): + sql = "select blocks from pictures where rowid = ?" + else: + sql = "select blocks from pictures where path = ?" + result = self.con.execute(sql, [key]).fetchone() + if result: + result = string_to_colors(result[0]) + return result + else: + raise KeyError(key) + + def __iter__(self): + sql = "select path from pictures" + result = self.con.execute(sql) + return (row[0] for row in result) + + def __len__(self): + sql = "select count(*) from pictures" + result = self.con.execute(sql).fetchall() + return result[0][0] + + def __setitem__(self, key, value): + value = colors_to_string(value) + if key in self: + sql = "update pictures set blocks = ? where path = ?" + else: + sql = "insert into pictures(blocks,path) values(?,?)" + try: + self.con.execute(sql, [value, key]) + except sqlite.OperationalError: + logging.warning('Picture cache could not set %r for key %r', value, key) + except sqlite.DatabaseError, e: + logging.warning('DatabaseError while setting %r for key %r: %s', value, key, str(e)) + + def clear(self): + sql = "delete from pictures" + self.con.execute(sql) + + def filter(self, func): + to_delete = [key for key in self if not func(key)] + for key in to_delete: + del self[key] + + def get_id(self, path): + sql = "select rowid from pictures where path = ?" + result = self.con.execute(sql, [path]).fetchone() + if result: + return result[0] + else: + raise ValueError(path) + + def get_multiple(self, rowids): + sql = "select rowid, blocks from pictures where rowid in (%s)" % ','.join(map(str, rowids)) + cur = self.con.execute(sql) + return ((rowid, string_to_colors(blocks)) for rowid, blocks in cur) + diff --git a/py/picture/cache_test.py b/py/picture/cache_test.py new file mode 100644 index 00000000..f453112f --- /dev/null +++ b/py/picture/cache_test.py @@ -0,0 +1,159 @@ +#!/usr/bin/env python +""" +Unit Name: tests.picture.cache +Created By: Virgil Dupras +Created On: 2006/09/14 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import unittest +from StringIO import StringIO +import os.path as op +import os +import threading + +from hsutil.testcase import TestCase +from .cache import * + +class TCcolors_to_string(unittest.TestCase): + def test_no_color(self): + self.assertEqual('',colors_to_string([])) + + def test_single_color(self): + self.assertEqual('000000',colors_to_string([(0,0,0)])) + self.assertEqual('010101',colors_to_string([(1,1,1)])) + self.assertEqual('0a141e',colors_to_string([(10,20,30)])) + + def test_two_colors(self): + self.assertEqual('000102030405',colors_to_string([(0,1,2),(3,4,5)])) + + +class TCstring_to_colors(unittest.TestCase): + def test_empty(self): + self.assertEqual([],string_to_colors('')) + + def test_single_color(self): + self.assertEqual([(0,0,0)],string_to_colors('000000')) + self.assertEqual([(2,3,4)],string_to_colors('020304')) + self.assertEqual([(10,20,30)],string_to_colors('0a141e')) + + def test_two_colors(self): + self.assertEqual([(10,20,30),(40,50,60)],string_to_colors('0a141e28323c')) + + def test_incomplete_color(self): + # don't return anything if it's not a complete color + self.assertEqual([],string_to_colors('102')) + + +class TCCache(TestCase): + def test_empty(self): + c = Cache() + self.assertEqual(0,len(c)) + self.assertRaises(KeyError,c.__getitem__,'foo') + + def test_set_then_retrieve_blocks(self): + c = Cache() + b = [(0,0,0),(1,2,3)] + c['foo'] = b + self.assertEqual(b,c['foo']) + + def test_delitem(self): + c = Cache() + c['foo'] = '' + del c['foo'] + self.assert_('foo' not in c) + self.assertRaises(KeyError,c.__delitem__,'foo') + + def test_persistance(self): + DBNAME = op.join(self.tmpdir(), 'hstest.db') + c = Cache(DBNAME) + c['foo'] = [(1,2,3)] + del c + c = Cache(DBNAME) + self.assertEqual([(1,2,3)],c['foo']) + del c + os.remove(DBNAME) + + def test_filter(self): + c = Cache() + c['foo'] = '' + c['bar'] = '' + c['baz'] = '' + c.filter(lambda p:p != 'bar') #only 'bar' is removed + self.assertEqual(2,len(c)) + self.assert_('foo' in c) + self.assert_('baz' in c) + self.assert_('bar' not in c) + + def test_clear(self): + c = Cache() + c['foo'] = '' + c['bar'] = '' + c['baz'] = '' + c.clear() + self.assertEqual(0,len(c)) + self.assert_('foo' not in c) + self.assert_('baz' not in c) + self.assert_('bar' not in c) + + def test_corrupted_db(self): + dbname = op.join(self.tmpdir(), 'foo.db') + fp = open(dbname, 'w') + fp.write('invalid sqlite content') + fp.close() + c = Cache(dbname) # should not raise a DatabaseError + c['foo'] = [(1, 2, 3)] + del c + c = Cache(dbname) + self.assertEqual(c['foo'], [(1, 2, 3)]) + + def test_by_id(self): + # it's possible to use the cache by referring to the files by their row_id + c = Cache() + b = [(0,0,0),(1,2,3)] + c['foo'] = b + foo_id = c.get_id('foo') + self.assertEqual(c[foo_id], b) + + +class TCCacheSQLEscape(unittest.TestCase): + def test_contains(self): + c = Cache() + self.assert_("foo'bar" not in c) + + def test_getitem(self): + c = Cache() + self.assertRaises(KeyError, c.__getitem__, "foo'bar") + + def test_setitem(self): + c = Cache() + c["foo'bar"] = [] + + def test_delitem(self): + c = Cache() + c["foo'bar"] = [] + try: + del c["foo'bar"] + except KeyError: + self.fail() + + +class TCCacheThreaded(unittest.TestCase): + def test_access_cache(self): + def thread_run(): + try: + c['foo'] = [(1,2,3)] + except sqlite.ProgrammingError: + self.fail() + + c = Cache() + t = threading.Thread(target=thread_run) + t.start() + t.join() + self.assertEqual([(1,2,3)], c['foo']) + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/py/picture/matchbase.py b/py/picture/matchbase.py new file mode 100644 index 00000000..cf0d1e89 --- /dev/null +++ b/py/picture/matchbase.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python +""" +Unit Name: hs.picture._match +Created By: Virgil Dupras +Created On: 2007/02/25 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:02:48 +0200 (Thu, 28 May 2009) $ + $Revision: 4388 $ +Copyright 2007 Hardcoded Software (http://www.hardcoded.net) +""" +import logging +import multiprocessing +from Queue import Empty +from collections import defaultdict + +from hsutil import job +from hs.utils.misc import dedupe + +from dupeguru.engine import Match +from block import avgdiff, DifferentBlockCountError, NoBlocksError +from cache import Cache + +MIN_ITERATIONS = 3 + +def get_match(first,second,percentage): + if percentage < 0: + percentage = 0 + return Match(first,second,percentage) + +class MatchFactory(object): + cached_blocks = None + block_count_per_side = 15 + threshold = 75 + match_scaled = False + + def _do_getmatches(self, files, j): + raise NotImplementedError() + + def getmatches(self, files, j=job.nulljob): + # The MemoryError handlers in there use logging without first caring about whether or not + # there is enough memory left to carry on the operation because it is assumed that the + # MemoryError happens when trying to read an image file, which is freed from memory by the + # time that MemoryError is raised. + j = j.start_subjob([2, 8]) + logging.info('Preparing %d files' % len(files)) + prepared = self.prepare_files(files, j) + logging.info('Finished preparing %d files' % len(prepared)) + return self._do_getmatches(prepared, j) + + def prepare_files(self, files, j=job.nulljob): + prepared = [] # only files for which there was no error getting blocks + try: + for picture in j.iter_with_progress(files, 'Analyzed %d/%d pictures'): + picture.dimensions + picture.unicode_path = unicode(picture.path) + try: + if picture.unicode_path not in self.cached_blocks: + blocks = picture.get_blocks(self.block_count_per_side) + self.cached_blocks[picture.unicode_path] = blocks + prepared.append(picture) + except IOError as e: + logging.warning(unicode(e)) + except MemoryError: + logging.warning(u'Ran out of memory while reading %s of size %d' % (picture.unicode_path, picture.size)) + if picture.size < 10 * 1024 * 1024: # We're really running out of memory + raise + except MemoryError: + logging.warning('Ran out of memory while preparing files') + return prepared + + +def async_compare(ref_id, other_ids, dbname, threshold): + cache = Cache(dbname, threaded=False) + limit = 100 - threshold + ref_blocks = cache[ref_id] + pairs = cache.get_multiple(other_ids) + results = [] + for other_id, other_blocks in pairs: + try: + diff = avgdiff(ref_blocks, other_blocks, limit, MIN_ITERATIONS) + percentage = 100 - diff + except (DifferentBlockCountError, NoBlocksError): + percentage = 0 + if percentage >= threshold: + results.append((ref_id, other_id, percentage)) + cache.con.close() + return results + +class AsyncMatchFactory(MatchFactory): + def _do_getmatches(self, pictures, j): + def empty_out_queue(queue, into): + try: + while True: + into.append(queue.get(block=False)) + except Empty: + pass + + j = j.start_subjob([1, 8, 1], 'Preparing for matching') + cache = self.cached_blocks + id2picture = {} + dimensions2pictures = defaultdict(set) + for picture in pictures[:]: + try: + picture.cache_id = cache.get_id(picture.unicode_path) + id2picture[picture.cache_id] = picture + except ValueError: + pictures.remove(picture) + if not self.match_scaled: + dimensions2pictures[picture.dimensions].add(picture) + pool = multiprocessing.Pool() + async_results = [] + pictures_copy = set(pictures) + for ref in j.iter_with_progress(pictures): + others = pictures_copy if self.match_scaled else dimensions2pictures[ref.dimensions] + others.remove(ref) + if others: + cache_ids = [f.cache_id for f in others] + args = (ref.cache_id, cache_ids, self.cached_blocks.dbname, self.threshold) + async_results.append(pool.apply_async(async_compare, args)) + + matches = [] + for result in j.iter_with_progress(async_results, 'Matched %d/%d pictures'): + matches.extend(result.get()) + + result = [] + for ref_id, other_id, percentage in j.iter_with_progress(matches, 'Verified %d/%d matches', every=10): + ref = id2picture[ref_id] + other = id2picture[other_id] + if percentage == 100 and ref.md5 != other.md5: + percentage = 99 + if percentage >= self.threshold: + result.append(get_match(ref, other, percentage)) + return result + + +multiprocessing.freeze_support() \ No newline at end of file diff --git a/py/results.py b/py/results.py new file mode 100644 index 00000000..a7ded5c0 --- /dev/null +++ b/py/results.py @@ -0,0 +1,359 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.results +Created By: Virgil Dupras +Created On: 2006/02/23 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 16:33:32 +0200 (Thu, 28 May 2009) $ + $Revision: 4392 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import re +from xml.sax import handler, make_parser, SAXException +from xml.sax.saxutils import XMLGenerator +from xml.sax.xmlreader import AttributesImpl + +from . import engine +from hsutil.job import nulljob +from hsutil.markable import Markable +from hsutil.misc import flatten, cond, nonone +from hsutil.str import format_size +from hsutil.files import open_if_filename + +class Results(Markable): + #---Override + def __init__(self, data_module): + super(Results, self).__init__() + self.__groups = [] + self.__group_of_duplicate = {} + self.__groups_sort_descriptor = None # This is a tuple (key, asc) + self.__dupes = None + self.__dupes_sort_descriptor = None # This is a tuple (key, asc, delta) + self.__filters = None + self.__filtered_dupes = None + self.__filtered_groups = None + self.__recalculate_stats() + self.__marked_size = 0 + self.data = data_module + + def _did_mark(self, dupe): + self.__marked_size += dupe.size + + def _did_unmark(self, dupe): + self.__marked_size -= dupe.size + + def _get_markable_count(self): + return self.__total_count + + def _is_markable(self, dupe): + if dupe.is_ref: + return False + g = self.get_group_of_duplicate(dupe) + if not g: + return False + if dupe is g.ref: + return False + if self.__filtered_dupes and dupe not in self.__filtered_dupes: + return False + return True + + #---Private + def __get_dupe_list(self): + if self.__dupes is None: + self.__dupes = flatten(group.dupes for group in self.groups) + if self.__filtered_dupes: + self.__dupes = [dupe for dupe in self.__dupes if dupe in self.__filtered_dupes] + sd = self.__dupes_sort_descriptor + if sd: + self.sort_dupes(sd[0], sd[1], sd[2]) + return self.__dupes + + def __get_groups(self): + if self.__filtered_groups is None: + return self.__groups + else: + return self.__filtered_groups + + def __get_stat_line(self): + if self.__filtered_dupes is None: + mark_count = self.mark_count + marked_size = self.__marked_size + total_count = self.__total_count + total_size = self.__total_size + else: + mark_count = len([dupe for dupe in self.__filtered_dupes if self.is_marked(dupe)]) + marked_size = sum(dupe.size for dupe in self.__filtered_dupes if self.is_marked(dupe)) + total_count = len([dupe for dupe in self.__filtered_dupes if self.is_markable(dupe)]) + total_size = sum(dupe.size for dupe in self.__filtered_dupes if self.is_markable(dupe)) + if self.mark_inverted: + marked_size = self.__total_size - marked_size + result = '%d / %d (%s / %s) duplicates marked.' % ( + mark_count, + total_count, + format_size(marked_size, 2), + format_size(total_size, 2), + ) + if self.__filters: + result += ' filter: %s' % ' --> '.join(self.__filters) + return result + + def __recalculate_stats(self): + self.__total_size = 0 + self.__total_count = 0 + for group in self.groups: + markable = [dupe for dupe in group.dupes if self._is_markable(dupe)] + self.__total_count += len(markable) + self.__total_size += sum(dupe.size for dupe in markable) + + def __set_groups(self, new_groups): + self.mark_none() + self.__groups = new_groups + self.__group_of_duplicate = {} + for g in self.__groups: + for dupe in g: + self.__group_of_duplicate[dupe] = g + if not hasattr(dupe, 'is_ref'): + dupe.is_ref = False + old_filters = nonone(self.__filters, []) + self.apply_filter(None) + for filter_str in old_filters: + self.apply_filter(filter_str) + + #---Public + def apply_filter(self, filter_str): + ''' Applies a filter 'filter_str' to self.groups + + When you apply the filter, only dupes with the filename matching 'filter_str' will be in + in the results. To cancel the filter, just call apply_filter with 'filter_str' to None, + and the results will go back to normal. + + If call apply_filter on a filtered results, the filter will be applied + *on the filtered results*. + + 'filter_str' is a string containing a regexp to filter dupes with. + ''' + if not filter_str: + self.__filtered_dupes = None + self.__filtered_groups = None + self.__filters = None + else: + if not self.__filters: + self.__filters = [] + self.__filters.append(filter_str) + filter_re = re.compile(filter_str, re.IGNORECASE) + if self.__filtered_dupes is None: + self.__filtered_dupes = flatten(g[:] for g in self.groups) + self.__filtered_dupes = set(dupe for dupe in self.__filtered_dupes if filter_re.search(dupe.name)) + filtered_groups = set() + for dupe in self.__filtered_dupes: + filtered_groups.add(self.get_group_of_duplicate(dupe)) + self.__filtered_groups = list(filtered_groups) + self.__recalculate_stats() + sd = self.__groups_sort_descriptor + if sd: + self.sort_groups(sd[0], sd[1]) + self.__dupes = None + + def get_group_of_duplicate(self, dupe): + try: + return self.__group_of_duplicate[dupe] + except (TypeError, KeyError): + return None + + is_markable = _is_markable + + def load_from_xml(self, infile, get_file, j=nulljob): + self.apply_filter(None) + handler = _ResultsHandler(get_file) + parser = make_parser() + parser.setContentHandler(handler) + try: + infile, must_close = open_if_filename(infile) + except IOError: + return + BUFSIZE = 1024 * 1024 # 1mb buffer + infile.seek(0, 2) + j.start_job(infile.tell() // BUFSIZE) + infile.seek(0, 0) + try: + while True: + data = infile.read(BUFSIZE) + if not data: + break + parser.feed(data) + j.add_progress() + except SAXException: + return + self.groups = handler.groups + for dupe_file in handler.marked: + self.mark(dupe_file) + + def make_ref(self, dupe): + g = self.get_group_of_duplicate(dupe) + r = g.ref + self._remove_mark_flag(dupe) + g.switch_ref(dupe); + if not r.is_ref: + self.__total_count += 1 + self.__total_size += r.size + if not dupe.is_ref: + self.__total_count -= 1 + self.__total_size -= dupe.size + self.__dupes = None + + def perform_on_marked(self, func, remove_from_results): + problems = [] + for d in self.dupes: + if self.is_marked(d) and (not func(d)): + problems.append(d) + if remove_from_results: + to_remove = [d for d in self.dupes if self.is_marked(d) and (d not in problems)] + self.remove_duplicates(to_remove) + self.mark_none() + for d in problems: + self.mark(d) + return len(problems) + + def remove_duplicates(self, dupes): + '''Remove 'dupes' from their respective group, and remove the group is it ends up empty. + ''' + affected_groups = set() + for dupe in dupes: + group = self.get_group_of_duplicate(dupe) + if dupe not in group.dupes: + return + group.remove_dupe(dupe, False) + self._remove_mark_flag(dupe) + self.__total_count -= 1 + self.__total_size -= dupe.size + if not group: + self.__groups.remove(group) + if self.__filtered_groups: + self.__filtered_groups.remove(group) + else: + affected_groups.add(group) + for group in affected_groups: + group.clean_matches() + self.__dupes = None + + def save_to_xml(self, outfile, with_data=False): + self.apply_filter(None) + outfile, must_close = open_if_filename(outfile, 'wb') + writer = XMLGenerator(outfile, 'utf-8') + writer.startDocument() + empty_attrs = AttributesImpl({}) + writer.startElement('results', empty_attrs) + for g in self.groups: + writer.startElement('group', empty_attrs) + dupe2index = {} + for index, d in enumerate(g): + dupe2index[d] = index + try: + words = engine.unpack_fields(d.words) + except AttributeError: + words = () + attrs = AttributesImpl({ + 'path': unicode(d.path), + 'is_ref': cond(d.is_ref, 'y', 'n'), + 'words': ','.join(words), + 'marked': cond(self.is_marked(d), 'y', 'n') + }) + writer.startElement('file', attrs) + if with_data: + data_list = self.data.GetDisplayInfo(d, g) + for data in data_list: + attrs = AttributesImpl({ + 'value': data, + }) + writer.startElement('data', attrs) + writer.endElement('data') + writer.endElement('file') + for match in g.matches: + attrs = AttributesImpl({ + 'first': str(dupe2index[match.first]), + 'second': str(dupe2index[match.second]), + 'percentage': str(int(match.percentage)), + }) + writer.startElement('match', attrs) + writer.endElement('match') + writer.endElement('group') + writer.endElement('results') + writer.endDocument() + if must_close: + outfile.close() + + def sort_dupes(self, key, asc=True, delta=False): + if not self.__dupes: + self.__get_dupe_list() + self.__dupes.sort(key=lambda d: self.data.GetDupeSortKey(d, lambda: self.get_group_of_duplicate(d), key, delta)) + if not asc: + self.__dupes.reverse() + self.__dupes_sort_descriptor = (key,asc,delta) + + def sort_groups(self,key,asc=True): + self.groups.sort(key=lambda g: self.data.GetGroupSortKey(g, key)) + if not asc: + self.groups.reverse() + self.__groups_sort_descriptor = (key,asc) + + #---Properties + dupes = property(__get_dupe_list) + groups = property(__get_groups, __set_groups) + stat_line = property(__get_stat_line) + +class _ResultsHandler(handler.ContentHandler): + def __init__(self, get_file): + self.group = None + self.dupes = None + self.marked = set() + self.groups = [] + self.get_file = get_file + + def startElement(self, name, attrs): + if name == 'group': + self.group = engine.Group() + self.dupes = [] + return + if (name == 'file') and (self.group is not None): + if not (('path' in attrs) and ('words' in attrs)): + return + path = attrs['path'] + file = self.get_file(path) + if file is None: + return + file.words = attrs['words'].split(',') + file.is_ref = attrs.get('is_ref') == 'y' + self.dupes.append(file) + if attrs.get('marked') == 'y': + self.marked.add(file) + if (name == 'match') and (self.group is not None): + try: + first_file = self.dupes[int(attrs['first'])] + second_file = self.dupes[int(attrs['second'])] + percentage = int(attrs['percentage']) + self.group.add_match(engine.Match(first_file, second_file, percentage)) + except (IndexError, KeyError, ValueError): # Covers missing attr, non-int values and indexes out of bounds + pass + + def endElement(self, name): + def do_match(ref_file, other_files, group): + if not other_files: + return + for other_file in other_files: + group.add_match(engine.get_match(ref_file, other_file)) + do_match(other_files[0], other_files[1:], group) + + if name == 'group': + group = self.group + self.group = None + dupes = self.dupes + self.dupes = [] + if group is None: + return + if len(dupes) < 2: + return + if not group.matches: # elements not present, do it manually, without % + do_match(dupes[0], dupes[1:], group) + group.prioritize(lambda x: dupes.index(x)) + self.groups.append(group) + diff --git a/py/results_test.py b/py/results_test.py new file mode 100644 index 00000000..1e74efc6 --- /dev/null +++ b/py/results_test.py @@ -0,0 +1,742 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.tests.results +Created By: Virgil Dupras +Created On: 2006/02/23 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import unittest +import StringIO +import xml.dom.minidom +import os.path as op + +from hsutil.path import Path +from hsutil.testcase import TestCase +from hsutil.misc import first + +from . import engine_test +from . import data +from . import engine +from .results import * + +class NamedObject(engine_test.NamedObject): + size = 1 + path = property(lambda x:Path('basepath') + x.name) + is_ref = False + + def __nonzero__(self): + return False #Make sure that operations are made correctly when the bool value of files is false. + +# Returns a group set that looks like that: +# "foo bar" (1) +# "bar bleh" (1024) +# "foo bleh" (1) +# "ibabtu" (1) +# "ibabtu" (1) +def GetTestGroups(): + objects = [NamedObject("foo bar"),NamedObject("bar bleh"),NamedObject("foo bleh"),NamedObject("ibabtu"),NamedObject("ibabtu")] + objects[1].size = 1024 + matches = engine.MatchFactory().getmatches(objects) #we should have 5 matches + groups = engine.get_groups(matches) #We should have 2 groups + for g in groups: + g.prioritize(lambda x:objects.index(x)) #We want the dupes to be in the same order as the list is + groups.sort(key=len, reverse=True) # We want the group with 3 members to be first. + return (objects,matches,groups) + +class TCResultsEmpty(TestCase): + def setUp(self): + self.results = Results(data) + + def test_stat_line(self): + self.assertEqual("0 / 0 (0.00 B / 0.00 B) duplicates marked.",self.results.stat_line) + + def test_groups(self): + self.assertEqual(0,len(self.results.groups)) + + def test_get_group_of_duplicate(self): + self.assert_(self.results.get_group_of_duplicate('foo') is None) + + def test_save_to_xml(self): + f = StringIO.StringIO() + self.results.save_to_xml(f) + f.seek(0) + doc = xml.dom.minidom.parse(f) + root = doc.documentElement + self.assertEqual('results',root.nodeName) + + +class TCResultsWithSomeGroups(TestCase): + def setUp(self): + self.results = Results(data) + self.objects,self.matches,self.groups = GetTestGroups() + self.results.groups = self.groups + + def test_stat_line(self): + self.assertEqual("0 / 3 (0.00 B / 1.01 KB) duplicates marked.",self.results.stat_line) + + def test_groups(self): + self.assertEqual(2,len(self.results.groups)) + + def test_get_group_of_duplicate(self): + for o in self.objects: + g = self.results.get_group_of_duplicate(o) + self.assert_(isinstance(g, engine.Group)) + self.assert_(o in g) + self.assert_(self.results.get_group_of_duplicate(self.groups[0]) is None) + + def test_remove_duplicates(self): + g1,g2 = self.results.groups + self.results.remove_duplicates([g1.dupes[0]]) + self.assertEqual(2,len(g1)) + self.assert_(g1 in self.results.groups) + self.results.remove_duplicates([g1.ref]) + self.assertEqual(2,len(g1)) + self.assert_(g1 in self.results.groups) + self.results.remove_duplicates([g1.dupes[0]]) + self.assertEqual(0,len(g1)) + self.assert_(g1 not in self.results.groups) + self.results.remove_duplicates([g2.dupes[0]]) + self.assertEqual(0,len(g2)) + self.assert_(g2 not in self.results.groups) + self.assertEqual(0,len(self.results.groups)) + + def test_remove_duplicates_with_ref_files(self): + g1,g2 = self.results.groups + self.objects[0].is_ref = True + self.objects[1].is_ref = True + self.results.remove_duplicates([self.objects[2]]) + self.assertEqual(0,len(g1)) + self.assert_(g1 not in self.results.groups) + + def test_make_ref(self): + g = self.results.groups[0] + d = g.dupes[0] + self.results.make_ref(d) + self.assert_(d is g.ref) + + def test_sort_groups(self): + self.results.make_ref(self.objects[1]) #We want to make the 1024 sized object to go ref. + g1,g2 = self.groups + self.results.sort_groups(2) #2 is the key for size + self.assert_(self.results.groups[0] is g2) + self.assert_(self.results.groups[1] is g1) + self.results.sort_groups(2,False) + self.assert_(self.results.groups[0] is g1) + self.assert_(self.results.groups[1] is g2) + + def test_set_groups_when_sorted(self): + self.results.make_ref(self.objects[1]) #We want to make the 1024 sized object to go ref. + self.results.sort_groups(2) + objects,matches,groups = GetTestGroups() + g1,g2 = groups + g1.switch_ref(objects[1]) + self.results.groups = groups + self.assert_(self.results.groups[0] is g2) + self.assert_(self.results.groups[1] is g1) + + def test_get_dupe_list(self): + self.assertEqual([self.objects[1],self.objects[2],self.objects[4]],self.results.dupes) + + def test_dupe_list_is_cached(self): + self.assert_(self.results.dupes is self.results.dupes) + + def test_dupe_list_cache_is_invalidated_when_needed(self): + o1,o2,o3,o4,o5 = self.objects + self.assertEqual([o2,o3,o5],self.results.dupes) + self.results.make_ref(o2) + self.assertEqual([o1,o3,o5],self.results.dupes) + objects,matches,groups = GetTestGroups() + o1,o2,o3,o4,o5 = objects + self.results.groups = groups + self.assertEqual([o2,o3,o5],self.results.dupes) + + def test_dupe_list_sort(self): + o1,o2,o3,o4,o5 = self.objects + o1.size = 5 + o2.size = 4 + o3.size = 3 + o4.size = 2 + o5.size = 1 + self.results.sort_dupes(2) + self.assertEqual([o5,o3,o2],self.results.dupes) + self.results.sort_dupes(2,False) + self.assertEqual([o2,o3,o5],self.results.dupes) + + def test_dupe_list_remember_sort(self): + o1,o2,o3,o4,o5 = self.objects + o1.size = 5 + o2.size = 4 + o3.size = 3 + o4.size = 2 + o5.size = 1 + self.results.sort_dupes(2) + self.results.make_ref(o2) + self.assertEqual([o5,o3,o1],self.results.dupes) + + def test_dupe_list_sort_delta_values(self): + o1,o2,o3,o4,o5 = self.objects + o1.size = 10 + o2.size = 2 #-8 + o3.size = 3 #-7 + o4.size = 20 + o5.size = 1 #-19 + self.results.sort_dupes(2,delta=True) + self.assertEqual([o5,o2,o3],self.results.dupes) + + def test_sort_empty_list(self): + #There was an infinite loop when sorting an empty list. + r = Results(data) + r.sort_dupes(0) + self.assertEqual([],r.dupes) + + def test_dupe_list_update_on_remove_duplicates(self): + o1,o2,o3,o4,o5 = self.objects + self.assertEqual(3,len(self.results.dupes)) + self.results.remove_duplicates([o2]) + self.assertEqual(2,len(self.results.dupes)) + + +class TCResultsMarkings(TestCase): + def setUp(self): + self.results = Results(data) + self.objects,self.matches,self.groups = GetTestGroups() + self.results.groups = self.groups + + def test_stat_line(self): + self.assertEqual("0 / 3 (0.00 B / 1.01 KB) duplicates marked.",self.results.stat_line) + self.results.mark(self.objects[1]) + self.assertEqual("1 / 3 (1.00 KB / 1.01 KB) duplicates marked.",self.results.stat_line) + self.results.mark_invert() + self.assertEqual("2 / 3 (2.00 B / 1.01 KB) duplicates marked.",self.results.stat_line) + self.results.mark_invert() + self.results.unmark(self.objects[1]) + self.results.mark(self.objects[2]) + self.results.mark(self.objects[4]) + self.assertEqual("2 / 3 (2.00 B / 1.01 KB) duplicates marked.",self.results.stat_line) + self.results.mark(self.objects[0]) #this is a ref, it can't be counted + self.assertEqual("2 / 3 (2.00 B / 1.01 KB) duplicates marked.",self.results.stat_line) + self.results.groups = self.groups + self.assertEqual("0 / 3 (0.00 B / 1.01 KB) duplicates marked.",self.results.stat_line) + + def test_with_ref_duplicate(self): + self.objects[1].is_ref = True + self.results.groups = self.groups + self.assert_(not self.results.mark(self.objects[1])) + self.results.mark(self.objects[2]) + self.assertEqual("1 / 2 (1.00 B / 2.00 B) duplicates marked.",self.results.stat_line) + + def test_perform_on_marked(self): + def log_object(o): + log.append(o) + return True + + log = [] + self.results.mark_all() + self.results.perform_on_marked(log_object,False) + self.assert_(self.objects[1] in log) + self.assert_(self.objects[2] in log) + self.assert_(self.objects[4] in log) + self.assertEqual(3,len(log)) + log = [] + self.results.mark_none() + self.results.mark(self.objects[4]) + self.results.perform_on_marked(log_object,True) + self.assertEqual(1,len(log)) + self.assert_(self.objects[4] in log) + self.assertEqual(1,len(self.results.groups)) + + def test_perform_on_marked_with_problems(self): + def log_object(o): + log.append(o) + return o is not self.objects[1] + + log = [] + self.results.mark_all() + self.assert_(self.results.is_marked(self.objects[1])) + self.assertEqual(1,self.results.perform_on_marked(log_object, True)) + self.assertEqual(3,len(log)) + self.assertEqual(1,len(self.results.groups)) + self.assertEqual(2,len(self.results.groups[0])) + self.assert_(self.objects[1] in self.results.groups[0]) + self.assert_(not self.results.is_marked(self.objects[2])) + self.assert_(self.results.is_marked(self.objects[1])) + + def test_perform_on_marked_with_ref(self): + def log_object(o): + log.append(o) + return True + + log = [] + self.objects[0].is_ref = True + self.objects[1].is_ref = True + self.results.mark_all() + self.results.perform_on_marked(log_object,True) + self.assert_(self.objects[1] not in log) + self.assert_(self.objects[2] in log) + self.assert_(self.objects[4] in log) + self.assertEqual(2,len(log)) + self.assertEqual(0,len(self.results.groups)) + + def test_perform_on_marked_remove_objects_only_at_the_end(self): + def check_groups(o): + self.assertEqual(3,len(g1)) + self.assertEqual(2,len(g2)) + return True + + g1,g2 = self.results.groups + self.results.mark_all() + self.results.perform_on_marked(check_groups,True) + self.assertEqual(0,len(g1)) + self.assertEqual(0,len(g2)) + self.assertEqual(0,len(self.results.groups)) + + def test_remove_duplicates(self): + g1 = self.results.groups[0] + g2 = self.results.groups[1] + self.results.mark(g1.dupes[0]) + self.assertEqual("1 / 3 (1.00 KB / 1.01 KB) duplicates marked.",self.results.stat_line) + self.results.remove_duplicates([g1.dupes[1]]) + self.assertEqual("1 / 2 (1.00 KB / 1.01 KB) duplicates marked.",self.results.stat_line) + self.results.remove_duplicates([g1.dupes[0]]) + self.assertEqual("0 / 1 (0.00 B / 1.00 B) duplicates marked.",self.results.stat_line) + + def test_make_ref(self): + g = self.results.groups[0] + d = g.dupes[0] + self.results.mark(d) + self.assertEqual("1 / 3 (1.00 KB / 1.01 KB) duplicates marked.",self.results.stat_line) + self.results.make_ref(d) + self.assertEqual("0 / 3 (0.00 B / 3.00 B) duplicates marked.",self.results.stat_line) + self.results.make_ref(d) + self.assertEqual("0 / 3 (0.00 B / 3.00 B) duplicates marked.",self.results.stat_line) + + def test_SaveXML(self): + self.results.mark(self.objects[1]) + self.results.mark_invert() + f = StringIO.StringIO() + self.results.save_to_xml(f) + f.seek(0) + doc = xml.dom.minidom.parse(f) + root = doc.documentElement + g1,g2 = root.getElementsByTagName('group') + d1,d2,d3 = g1.getElementsByTagName('file') + self.assertEqual('n',d1.getAttributeNode('marked').nodeValue) + self.assertEqual('n',d2.getAttributeNode('marked').nodeValue) + self.assertEqual('y',d3.getAttributeNode('marked').nodeValue) + d1,d2 = g2.getElementsByTagName('file') + self.assertEqual('n',d1.getAttributeNode('marked').nodeValue) + self.assertEqual('y',d2.getAttributeNode('marked').nodeValue) + + def test_LoadXML(self): + def get_file(path): + return [f for f in self.objects if str(f.path) == path][0] + + self.objects[4].name = 'ibabtu 2' #we can't have 2 files with the same path + self.results.mark(self.objects[1]) + self.results.mark_invert() + f = StringIO.StringIO() + self.results.save_to_xml(f) + f.seek(0) + r = Results(data) + r.load_from_xml(f,get_file) + self.assert_(not r.is_marked(self.objects[0])) + self.assert_(not r.is_marked(self.objects[1])) + self.assert_(r.is_marked(self.objects[2])) + self.assert_(not r.is_marked(self.objects[3])) + self.assert_(r.is_marked(self.objects[4])) + + +class TCResultsXML(TestCase): + def setUp(self): + self.results = Results(data) + self.objects, self.matches, self.groups = GetTestGroups() + self.results.groups = self.groups + + def get_file(self, path): # use this as a callback for load_from_xml + return [o for o in self.objects if o.path == path][0] + + def test_save_to_xml(self): + self.objects[0].is_ref = True + self.objects[0].words = [['foo','bar']] + f = StringIO.StringIO() + self.results.save_to_xml(f) + f.seek(0) + doc = xml.dom.minidom.parse(f) + root = doc.documentElement + self.assertEqual('results',root.nodeName) + children = [c for c in root.childNodes if c.localName] + self.assertEqual(2,len(children)) + self.assertEqual(2,len([c for c in children if c.nodeName == 'group'])) + g1,g2 = children + children = [c for c in g1.childNodes if c.localName] + self.assertEqual(6,len(children)) + self.assertEqual(3,len([c for c in children if c.nodeName == 'file'])) + self.assertEqual(3,len([c for c in children if c.nodeName == 'match'])) + d1,d2,d3 = [c for c in children if c.nodeName == 'file'] + self.assertEqual(op.join('basepath','foo bar'),d1.getAttributeNode('path').nodeValue) + self.assertEqual(op.join('basepath','bar bleh'),d2.getAttributeNode('path').nodeValue) + self.assertEqual(op.join('basepath','foo bleh'),d3.getAttributeNode('path').nodeValue) + self.assertEqual('y',d1.getAttributeNode('is_ref').nodeValue) + self.assertEqual('n',d2.getAttributeNode('is_ref').nodeValue) + self.assertEqual('n',d3.getAttributeNode('is_ref').nodeValue) + self.assertEqual('foo,bar',d1.getAttributeNode('words').nodeValue) + self.assertEqual('bar,bleh',d2.getAttributeNode('words').nodeValue) + self.assertEqual('foo,bleh',d3.getAttributeNode('words').nodeValue) + children = [c for c in g2.childNodes if c.localName] + self.assertEqual(3,len(children)) + self.assertEqual(2,len([c for c in children if c.nodeName == 'file'])) + self.assertEqual(1,len([c for c in children if c.nodeName == 'match'])) + d1,d2 = [c for c in children if c.nodeName == 'file'] + self.assertEqual(op.join('basepath','ibabtu'),d1.getAttributeNode('path').nodeValue) + self.assertEqual(op.join('basepath','ibabtu'),d2.getAttributeNode('path').nodeValue) + self.assertEqual('n',d1.getAttributeNode('is_ref').nodeValue) + self.assertEqual('n',d2.getAttributeNode('is_ref').nodeValue) + self.assertEqual('ibabtu',d1.getAttributeNode('words').nodeValue) + self.assertEqual('ibabtu',d2.getAttributeNode('words').nodeValue) + + def test_save_to_xml_with_columns(self): + class FakeDataModule: + def GetDisplayInfo(self,dupe,group): + return [str(dupe.size),dupe.foo.upper()] + + for i,object in enumerate(self.objects): + object.size = i + object.foo = u'bar\u00e9' + f = StringIO.StringIO() + self.results.data = FakeDataModule() + self.results.save_to_xml(f,True) + f.seek(0) + doc = xml.dom.minidom.parse(f) + root = doc.documentElement + g1,g2 = root.getElementsByTagName('group') + d1,d2,d3 = g1.getElementsByTagName('file') + d4,d5 = g2.getElementsByTagName('file') + self.assertEqual('0',d1.getElementsByTagName('data')[0].getAttribute('value')) + self.assertEqual(u'BAR\u00c9',d1.getElementsByTagName('data')[1].getAttribute('value')) #\u00c9 is upper of \u00e9 + self.assertEqual('1',d2.getElementsByTagName('data')[0].getAttribute('value')) + self.assertEqual('2',d3.getElementsByTagName('data')[0].getAttribute('value')) + self.assertEqual('3',d4.getElementsByTagName('data')[0].getAttribute('value')) + self.assertEqual('4',d5.getElementsByTagName('data')[0].getAttribute('value')) + + def test_LoadXML(self): + def get_file(path): + return [f for f in self.objects if str(f.path) == path][0] + + self.objects[0].is_ref = True + self.objects[4].name = 'ibabtu 2' #we can't have 2 files with the same path + f = StringIO.StringIO() + self.results.save_to_xml(f) + f.seek(0) + r = Results(data) + r.load_from_xml(f,get_file) + self.assertEqual(2,len(r.groups)) + g1,g2 = r.groups + self.assertEqual(3,len(g1)) + self.assert_(g1[0].is_ref) + self.assert_(not g1[1].is_ref) + self.assert_(not g1[2].is_ref) + self.assert_(g1[0] is self.objects[0]) + self.assert_(g1[1] is self.objects[1]) + self.assert_(g1[2] is self.objects[2]) + self.assertEqual(['foo','bar'],g1[0].words) + self.assertEqual(['bar','bleh'],g1[1].words) + self.assertEqual(['foo','bleh'],g1[2].words) + self.assertEqual(2,len(g2)) + self.assert_(not g2[0].is_ref) + self.assert_(not g2[1].is_ref) + self.assert_(g2[0] is self.objects[3]) + self.assert_(g2[1] is self.objects[4]) + self.assertEqual(['ibabtu'],g2[0].words) + self.assertEqual(['ibabtu'],g2[1].words) + + def test_LoadXML_with_filename(self): + def get_file(path): + return [f for f in self.objects if str(f.path) == path][0] + + filename = op.join(self.tmpdir(), 'dupeguru_results.xml') + self.objects[4].name = 'ibabtu 2' #we can't have 2 files with the same path + self.results.save_to_xml(filename) + r = Results(data) + r.load_from_xml(filename,get_file) + self.assertEqual(2,len(r.groups)) + + def test_LoadXML_with_some_files_that_dont_exist_anymore(self): + def get_file(path): + if path.endswith('ibabtu 2'): + return None + return [f for f in self.objects if str(f.path) == path][0] + + self.objects[4].name = 'ibabtu 2' #we can't have 2 files with the same path + f = StringIO.StringIO() + self.results.save_to_xml(f) + f.seek(0) + r = Results(data) + r.load_from_xml(f,get_file) + self.assertEqual(1,len(r.groups)) + self.assertEqual(3,len(r.groups[0])) + + def test_LoadXML_missing_attributes_and_bogus_elements(self): + def get_file(path): + return [f for f in self.objects if str(f.path) == path][0] + + doc = xml.dom.minidom.Document() + root = doc.appendChild(doc.createElement('foobar')) #The root element shouldn't matter, really. + group_node = root.appendChild(doc.createElement('group')) + dupe_node = group_node.appendChild(doc.createElement('file')) #Perfectly correct file + dupe_node.setAttribute('path',op.join('basepath','foo bar')) + dupe_node.setAttribute('is_ref','y') + dupe_node.setAttribute('words','foo,bar') + dupe_node = group_node.appendChild(doc.createElement('file')) #is_ref missing, default to 'n' + dupe_node.setAttribute('path',op.join('basepath','foo bleh')) + dupe_node.setAttribute('words','foo,bleh') + dupe_node = group_node.appendChild(doc.createElement('file')) #words are missing, invalid. + dupe_node.setAttribute('path',op.join('basepath','bar bleh')) + dupe_node = group_node.appendChild(doc.createElement('file')) #path is missing, invalid. + dupe_node.setAttribute('words','foo,bleh') + dupe_node = group_node.appendChild(doc.createElement('foobar')) #Invalid element name + dupe_node.setAttribute('path',op.join('basepath','bar bleh')) + dupe_node.setAttribute('is_ref','y') + dupe_node.setAttribute('words','bar,bleh') + match_node = group_node.appendChild(doc.createElement('match')) # match pointing to a bad index + match_node.setAttribute('first', '42') + match_node.setAttribute('second', '45') + match_node = group_node.appendChild(doc.createElement('match')) # match with missing attrs + match_node = group_node.appendChild(doc.createElement('match')) # match with non-int values + match_node.setAttribute('first', 'foo') + match_node.setAttribute('second', 'bar') + match_node.setAttribute('percentage', 'baz') + group_node = root.appendChild(doc.createElement('foobar')) #invalid group + group_node = root.appendChild(doc.createElement('group')) #empty group + f = StringIO.StringIO() + doc.writexml(f,'\t','\t','\n',encoding='utf-8') + f.seek(0) + r = Results(data) + r.load_from_xml(f,get_file) + self.assertEqual(1,len(r.groups)) + self.assertEqual(2,len(r.groups[0])) + + def test_xml_non_ascii(self): + def get_file(path): + if path == op.join('basepath',u'\xe9foo bar'): + return objects[0] + if path == op.join('basepath',u'bar bleh'): + return objects[1] + + objects = [NamedObject(u"\xe9foo bar",True),NamedObject("bar bleh",True)] + matches = engine.MatchFactory().getmatches(objects) #we should have 5 matches + groups = engine.get_groups(matches) #We should have 2 groups + for g in groups: + g.prioritize(lambda x:objects.index(x)) #We want the dupes to be in the same order as the list is + results = Results(data) + results.groups = groups + f = StringIO.StringIO() + results.save_to_xml(f) + f.seek(0) + r = Results(data) + r.load_from_xml(f,get_file) + g = r.groups[0] + self.assertEqual(u"\xe9foo bar",g[0].name) + self.assertEqual(['efoo','bar'],g[0].words) + + def test_load_invalid_xml(self): + f = StringIO.StringIO() + f.write(' len(ref.path) + + def GetDupeGroups(self, files, j=job.nulljob): + j = j.start_subjob([8, 2]) + for f in [f for f in files if not hasattr(f, 'is_ref')]: + f.is_ref = False + if self.size_threshold: + files = [f for f in files if f.size >= self.size_threshold] + logging.info('Getting matches') + if self.match_factory is None: + matches = self._getmatches(files, j) + else: + matches = self.match_factory.getmatches(files, j) + logging.info('Found %d matches' % len(matches)) + if not self.mix_file_kind: + j.set_progress(100, 'Removing false matches') + matches = [m for m in matches if get_file_ext(m.first.name) == get_file_ext(m.second.name)] + if self.ignore_list: + j = j.start_subjob(2) + iter_matches = j.iter_with_progress(matches, 'Processed %d/%d matches against the ignore list') + matches = [m for m in iter_matches + if not self.ignore_list.AreIgnored(unicode(m.first.path), unicode(m.second.path))] + matched_files = dedupe([m.first for m in matches] + [m.second for m in matches]) + if self.scan_type in (SCAN_TYPE_CONTENT, SCAN_TYPE_CONTENT_AUDIO): + md5attrname = 'md5partial' if self.scan_type == SCAN_TYPE_CONTENT_AUDIO else 'md5' + md5 = lambda f: getattr(f, md5attrname) + j = j.start_subjob(2) + for matched_file in j.iter_with_progress(matched_files, 'Analyzed %d/%d matching files'): + md5(matched_file) + j.set_progress(100, 'Removing false matches') + matches = [m for m in matches if md5(m.first) == md5(m.second)] + words_for_content = ['--'] # We compared md5. No words were involved. + for m in matches: + m.first.words = words_for_content + m.second.words = words_for_content + logging.info('Grouping matches') + groups = engine.get_groups(matches, j) + groups = [g for g in groups if any(not f.is_ref for f in g)] + logging.info('Created %d groups' % len(groups)) + j.set_progress(100, 'Doing group prioritization') + for g in groups: + g.prioritize(self._key_func, self._tie_breaker) + matched_files = dedupe([m.first for m in matches] + [m.second for m in matches]) + self.discarded_file_count = len(matched_files) - sum(len(g) for g in groups) + return groups + + match_factory = None + match_similar_words = False + min_match_percentage = 80 + mix_file_kind = True + scan_type = SCAN_TYPE_FILENAME + scanned_tags = set(['artist', 'title']) + size_threshold = 0 + word_weighting = False + +class ScannerME(Scanner): # Scanner for Music Edition + @staticmethod + def _key_func(dupe): + return (not dupe.is_ref, -dupe.bitrate, -dupe.size) + diff --git a/py/scanner_test.py b/py/scanner_test.py new file mode 100644 index 00000000..89ad1417 --- /dev/null +++ b/py/scanner_test.py @@ -0,0 +1,468 @@ +#!/usr/bin/env python +""" +Unit Name: dupeguru.tests.scanner +Created By: Virgil Dupras +Created On: 2006/03/03 +Last modified by:$Author: virgil $ +Last modified on:$Date: 2009-05-28 15:22:39 +0200 (Thu, 28 May 2009) $ + $Revision: 4385 $ +Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net) +""" +import unittest + +from hsutil import job +from hsutil.path import Path +from hsutil.testcase import TestCase + +from .engine import getwords, Match +from .ignore import IgnoreList +from .scanner import * + +class NamedObject(object): + def __init__(self, name="foobar", size=1): + self.name = name + self.size = size + self.path = Path('') + self.words = getwords(name) + + +no = NamedObject + +class TCScanner(TestCase): + def test_empty(self): + s = Scanner() + r = s.GetDupeGroups([]) + self.assertEqual([],r) + + def test_default_settings(self): + s = Scanner() + self.assertEqual(80,s.min_match_percentage) + self.assertEqual(SCAN_TYPE_FILENAME,s.scan_type) + self.assertEqual(True,s.mix_file_kind) + self.assertEqual(False,s.word_weighting) + self.assertEqual(False,s.match_similar_words) + self.assert_(isinstance(s.ignore_list,IgnoreList)) + + def test_simple_with_default_settings(self): + s = Scanner() + f = [no('foo bar'),no('foo bar'),no('foo bleh')] + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + g = r[0] + #'foo bleh' cannot be in the group because the default min match % is 80 + self.assertEqual(2,len(g)) + self.assert_(g.ref in f[:2]) + self.assert_(g.dupes[0] in f[:2]) + + def test_simple_with_lower_min_match(self): + s = Scanner() + s.min_match_percentage = 50 + f = [no('foo bar'),no('foo bar'),no('foo bleh')] + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + g = r[0] + self.assertEqual(3,len(g)) + + def test_trim_all_ref_groups(self): + s = Scanner() + f = [no('foo'),no('foo'),no('bar'),no('bar')] + f[2].is_ref = True + f[3].is_ref = True + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + + def test_priorize(self): + s = Scanner() + f = [no('foo'),no('foo'),no('bar'),no('bar')] + f[1].size = 2 + f[2].size = 3 + f[3].is_ref = True + r = s.GetDupeGroups(f) + g1,g2 = r + self.assert_(f[1] in (g1.ref,g2.ref)) + self.assert_(f[0] in (g1.dupes[0],g2.dupes[0])) + self.assert_(f[3] in (g1.ref,g2.ref)) + self.assert_(f[2] in (g1.dupes[0],g2.dupes[0])) + + def test_content_scan(self): + s = Scanner() + s.scan_type = SCAN_TYPE_CONTENT + f = [no('foo'), no('bar'), no('bleh')] + f[0].md5 = 'foobar' + f[1].md5 = 'foobar' + f[2].md5 = 'bleh' + r = s.GetDupeGroups(f) + self.assertEqual(len(r), 1) + self.assertEqual(len(r[0]), 2) + self.assertEqual(s.discarded_file_count, 0) # don't count the different md5 as discarded! + + def test_content_scan_compare_sizes_first(self): + class MyFile(no): + def get_md5(file): + self.fail() + md5 = property(get_md5) + + s = Scanner() + s.scan_type = SCAN_TYPE_CONTENT + f = [MyFile('foo',1),MyFile('bar',2)] + self.assertEqual(0,len(s.GetDupeGroups(f))) + + def test_min_match_perc_doesnt_matter_for_content_scan(self): + s = Scanner() + s.scan_type = SCAN_TYPE_CONTENT + f = [no('foo'),no('bar'),no('bleh')] + f[0].md5 = 'foobar' + f[1].md5 = 'foobar' + f[2].md5 = 'bleh' + s.min_match_percentage = 101 + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + self.assertEqual(2,len(r[0])) + s.min_match_percentage = 0 + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + self.assertEqual(2,len(r[0])) + + def test_content_scan_puts_md5_in_words_at_the_end(self): + s = Scanner() + s.scan_type = SCAN_TYPE_CONTENT + f = [no('foo'),no('bar')] + f[0].md5 = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f' + f[1].md5 = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f' + r = s.GetDupeGroups(f) + g = r[0] + self.assertEqual(['--'],g.ref.words) + self.assertEqual(['--'],g.dupes[0].words) + + def test_extension_is_not_counted_in_filename_scan(self): + s = Scanner() + s.min_match_percentage = 100 + f = [no('foo.bar'),no('foo.bleh')] + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + self.assertEqual(2,len(r[0])) + + def test_job(self): + def do_progress(progress,desc=''): + log.append(progress) + return True + s = Scanner() + log = [] + f = [no('foo bar'),no('foo bar'),no('foo bleh')] + r = s.GetDupeGroups(f, job.Job(1,do_progress)) + self.assertEqual(0,log[0]) + self.assertEqual(100,log[-1]) + + def test_mix_file_kind(self): + s = Scanner() + s.mix_file_kind = False + f = [no('foo.1'),no('foo.2')] + r = s.GetDupeGroups(f) + self.assertEqual(0,len(r)) + + def test_word_weighting(self): + s = Scanner() + s.min_match_percentage = 75 + s.word_weighting = True + f = [no('foo bar'),no('foo bar bleh')] + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + g = r[0] + m = g.get_match_of(g.dupes[0]) + self.assertEqual(75,m.percentage) # 16 letters, 12 matching + + def test_similar_words(self): + s = Scanner() + s.match_similar_words = True + f = [no('The White Stripes'),no('The Whites Stripe'),no('Limp Bizkit'),no('Limp Bizkitt')] + r = s.GetDupeGroups(f) + self.assertEqual(2,len(r)) + + def test_fields(self): + s = Scanner() + s.scan_type = SCAN_TYPE_FIELDS + f = [no('The White Stripes - Little Ghost'),no('The White Stripes - Little Acorn')] + r = s.GetDupeGroups(f) + self.assertEqual(0,len(r)) + + def test_fields_no_order(self): + s = Scanner() + s.scan_type = SCAN_TYPE_FIELDS_NO_ORDER + f = [no('The White Stripes - Little Ghost'),no('Little Ghost - The White Stripes')] + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + + def test_tag_scan(self): + s = Scanner() + s.scan_type = SCAN_TYPE_TAG + o1 = no('foo') + o2 = no('bar') + o1.artist = 'The White Stripes' + o1.title = 'The Air Near My Fingers' + o2.artist = 'The White Stripes' + o2.title = 'The Air Near My Fingers' + r = s.GetDupeGroups([o1,o2]) + self.assertEqual(1,len(r)) + + def test_tag_with_album_scan(self): + s = Scanner() + s.scan_type = SCAN_TYPE_TAG_WITH_ALBUM + o1 = no('foo') + o2 = no('bar') + o3 = no('bleh') + o1.artist = 'The White Stripes' + o1.title = 'The Air Near My Fingers' + o1.album = 'Elephant' + o2.artist = 'The White Stripes' + o2.title = 'The Air Near My Fingers' + o2.album = 'Elephant' + o3.artist = 'The White Stripes' + o3.title = 'The Air Near My Fingers' + o3.album = 'foobar' + r = s.GetDupeGroups([o1,o2,o3]) + self.assertEqual(1,len(r)) + + def test_that_dash_in_tags_dont_create_new_fields(self): + s = Scanner() + s.scan_type = SCAN_TYPE_TAG_WITH_ALBUM + s.min_match_percentage = 50 + o1 = no('foo') + o2 = no('bar') + o1.artist = 'The White Stripes - a' + o1.title = 'The Air Near My Fingers - a' + o1.album = 'Elephant - a' + o2.artist = 'The White Stripes - b' + o2.title = 'The Air Near My Fingers - b' + o2.album = 'Elephant - b' + r = s.GetDupeGroups([o1,o2]) + self.assertEqual(1,len(r)) + + def test_tag_scan_with_different_scanned(self): + s = Scanner() + s.scan_type = SCAN_TYPE_TAG + s.scanned_tags = set(['track', 'year']) + o1 = no('foo') + o2 = no('bar') + o1.artist = 'The White Stripes' + o1.title = 'some title' + o1.track = 'foo' + o1.year = 'bar' + o2.artist = 'The White Stripes' + o2.title = 'another title' + o2.track = 'foo' + o2.year = 'bar' + r = s.GetDupeGroups([o1, o2]) + self.assertEqual(1, len(r)) + + def test_tag_scan_only_scans_existing_tags(self): + s = Scanner() + s.scan_type = SCAN_TYPE_TAG + s.scanned_tags = set(['artist', 'foo']) + o1 = no('foo') + o2 = no('bar') + o1.artist = 'The White Stripes' + o1.foo = 'foo' + o2.artist = 'The White Stripes' + o2.foo = 'bar' + r = s.GetDupeGroups([o1, o2]) + self.assertEqual(1, len(r)) # Because 'foo' is not scanned, they match + + def test_tag_scan_converts_to_str(self): + s = Scanner() + s.scan_type = SCAN_TYPE_TAG + s.scanned_tags = set(['track']) + o1 = no('foo') + o2 = no('bar') + o1.track = 42 + o2.track = 42 + try: + r = s.GetDupeGroups([o1, o2]) + except TypeError: + self.fail() + self.assertEqual(1, len(r)) + + def test_tag_scan_non_ascii(self): + s = Scanner() + s.scan_type = SCAN_TYPE_TAG + s.scanned_tags = set(['title']) + o1 = no('foo') + o2 = no('bar') + o1.title = u'foobar\u00e9' + o2.title = u'foobar\u00e9' + try: + r = s.GetDupeGroups([o1, o2]) + except UnicodeEncodeError: + self.fail() + self.assertEqual(1, len(r)) + + def test_audio_content_scan(self): + s = Scanner() + s.scan_type = SCAN_TYPE_CONTENT_AUDIO + f = [no('foo'),no('bar'),no('bleh')] + f[0].md5 = 'foo' + f[1].md5 = 'bar' + f[2].md5 = 'bleh' + f[0].md5partial = 'foo' + f[1].md5partial = 'foo' + f[2].md5partial = 'bleh' + f[0].audiosize = 1 + f[1].audiosize = 1 + f[2].audiosize = 1 + r = s.GetDupeGroups(f) + self.assertEqual(1,len(r)) + self.assertEqual(2,len(r[0])) + + def test_audio_content_scan_compare_sizes_first(self): + class MyFile(no): + def get_md5(file): + self.fail() + md5partial = property(get_md5) + + s = Scanner() + s.scan_type = SCAN_TYPE_CONTENT_AUDIO + f = [MyFile('foo'),MyFile('bar')] + f[0].audiosize = 1 + f[1].audiosize = 2 + self.assertEqual(0,len(s.GetDupeGroups(f))) + + def test_ignore_list(self): + s = Scanner() + f1 = no('foobar') + f2 = no('foobar') + f3 = no('foobar') + f1.path = Path('dir1/foobar') + f2.path = Path('dir2/foobar') + f3.path = Path('dir3/foobar') + s.ignore_list.Ignore(str(f1.path),str(f2.path)) + s.ignore_list.Ignore(str(f1.path),str(f3.path)) + r = s.GetDupeGroups([f1,f2,f3]) + self.assertEqual(1,len(r)) + g = r[0] + self.assertEqual(1,len(g.dupes)) + self.assert_(f1 not in g) + self.assert_(f2 in g) + self.assert_(f3 in g) + # Ignored matches are not counted as discarded + self.assertEqual(s.discarded_file_count, 0) + + def test_ignore_list_checks_for_unicode(self): + #scanner was calling path_str for ignore list checks. Since the Path changes, it must + #be unicode(path) + s = Scanner() + f1 = no('foobar') + f2 = no('foobar') + f3 = no('foobar') + f1.path = Path(u'foo1\u00e9') + f2.path = Path(u'foo2\u00e9') + f3.path = Path(u'foo3\u00e9') + s.ignore_list.Ignore(unicode(f1.path),unicode(f2.path)) + s.ignore_list.Ignore(unicode(f1.path),unicode(f3.path)) + r = s.GetDupeGroups([f1,f2,f3]) + self.assertEqual(1,len(r)) + g = r[0] + self.assertEqual(1,len(g.dupes)) + self.assert_(f1 not in g) + self.assert_(f2 in g) + self.assert_(f3 in g) + + def test_custom_match_factory(self): + class MatchFactory(object): + def getmatches(self,objects,j=None): + return [Match(objects[0], objects[1], 420)] + + + s = Scanner() + s.match_factory = MatchFactory() + o1,o2 = no('foo'),no('bar') + groups = s.GetDupeGroups([o1,o2]) + self.assertEqual(1,len(groups)) + g = groups[0] + self.assertEqual(2,len(g)) + g.switch_ref(o1) + m = g.get_match_of(o2) + self.assertEqual((o1,o2,420),m) + + def test_file_evaluates_to_false(self): + # A very wrong way to use any() was added at some point, causing resulting group list + # to be empty. + class FalseNamedObject(NamedObject): + def __nonzero__(self): + return False + + + s = Scanner() + f1 = FalseNamedObject('foobar') + f2 = FalseNamedObject('foobar') + r = s.GetDupeGroups([f1,f2]) + self.assertEqual(1,len(r)) + + def test_size_threshold(self): + # Only file equal or higher than the size_threshold in size are scanned + s = Scanner() + f1 = no('foo', 1) + f2 = no('foo', 2) + f3 = no('foo', 3) + s.size_threshold = 2 + groups = s.GetDupeGroups([f1,f2,f3]) + self.assertEqual(len(groups), 1) + [group] = groups + self.assertEqual(len(group), 2) + self.assertTrue(f1 not in group) + self.assertTrue(f2 in group) + self.assertTrue(f3 in group) + + def test_tie_breaker_path_deepness(self): + # If there is a tie in prioritization, path deepness is used as a tie breaker + s = Scanner() + o1, o2 = no('foo'), no('foo') + o1.path = Path('foo') + o2.path = Path('foo/bar') + [group] = s.GetDupeGroups([o1, o2]) + self.assertTrue(group.ref is o2) + + def test_tie_breaker_copy(self): + # if copy is in the words used (even if it has a deeper path), it becomes a dupe + s = Scanner() + o1, o2 = no('foo bar Copy'), no('foo bar') + o1.path = Path('deeper/path') + o2.path = Path('foo') + [group] = s.GetDupeGroups([o1, o2]) + self.assertTrue(group.ref is o2) + + def test_tie_breaker_same_name_plus_digit(self): + # if ref has the same words as dupe, but has some just one extra word which is a digit, it + # becomes a dupe + s = Scanner() + o1, o2 = no('foo bar 42'), no('foo bar') + o1.path = Path('deeper/path') + o2.path = Path('foo') + [group] = s.GetDupeGroups([o1, o2]) + self.assertTrue(group.ref is o2) + + def test_partial_group_match(self): + # Count the number od discarded matches (when a file doesn't match all other dupes of the + # group) in Scanner.discarded_file_count + s = Scanner() + o1, o2, o3 = no('a b'), no('a'), no('b') + s.min_match_percentage = 50 + [group] = s.GetDupeGroups([o1, o2, o3]) + self.assertEqual(len(group), 2) + self.assertTrue(o1 in group) + self.assertTrue(o2 in group) + self.assertTrue(o3 not in group) + self.assertEqual(s.discarded_file_count, 1) + + +class TCScannerME(TestCase): + def test_priorize(self): + # in ScannerME, bitrate goes first (right after is_ref) in priorization + s = ScannerME() + o1, o2 = no('foo'), no('foo') + o1.bitrate = 1 + o2.bitrate = 2 + [group] = s.GetDupeGroups([o1, o2]) + self.assertTrue(group.ref is o2) + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/se/cocoa/AppDelegate.h b/se/cocoa/AppDelegate.h new file mode 100644 index 00000000..77d3b57f --- /dev/null +++ b/se/cocoa/AppDelegate.h @@ -0,0 +1,18 @@ +#import +#import "dgbase/AppDelegate.h" +#import "ResultWindow.h" +#import "DirectoryPanel.h" +#import "PyDupeGuru.h" + +@interface AppDelegate : AppDelegateBase +{ + IBOutlet ResultWindow *result; + + DirectoryPanel *_directoryPanel; +} +- (IBAction)openWebsite:(id)sender; +- (IBAction)toggleDirectories:(id)sender; + +- (DirectoryPanel *)directoryPanel; +- (PyDupeGuru *)py; +@end diff --git a/se/cocoa/AppDelegate.m b/se/cocoa/AppDelegate.m new file mode 100644 index 00000000..c1378a8c --- /dev/null +++ b/se/cocoa/AppDelegate.m @@ -0,0 +1,108 @@ +#import "AppDelegate.h" +#import "cocoalib/ProgressController.h" +#import "cocoalib/RegistrationInterface.h" +#import "cocoalib/Utils.h" +#import "cocoalib/ValueTransformers.h" +#import "Consts.h" + +@implementation AppDelegate ++ (void)initialize +{ + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + NSMutableDictionary *d = [NSMutableDictionary dictionary]; + [d setObject:i2n(1) forKey:@"scanType"]; + [d setObject:i2n(80) forKey:@"minMatchPercentage"]; + [d setObject:i2n(30) forKey:@"smallFileThreshold"]; + [d setObject:i2n(1) forKey:@"recreatePathType"]; + [d setObject:b2n(YES) forKey:@"wordWeighting"]; + [d setObject:b2n(NO) forKey:@"matchSimilarWords"]; + [d setObject:b2n(YES) forKey:@"mixFileKind"]; + [d setObject:b2n(NO) forKey:@"useRegexpFilter"]; + [d setObject:b2n(NO) forKey:@"removeEmptyFolders"]; + [d setObject:b2n(YES) forKey:@"ignoreSmallFiles"]; + [d setObject:b2n(NO) forKey:@"debug"]; + [d setObject:[NSArray array] forKey:@"recentDirectories"]; + [d setObject:[NSArray array] forKey:@"columnsOrder"]; + [d setObject:[NSDictionary dictionary] forKey:@"columnsWidth"]; + [[NSUserDefaultsController sharedUserDefaultsController] setInitialValues:d]; + [ud registerDefaults:d]; +} + +- (id)init +{ + self = [super init]; + VTIsIntIn *vt = [[[VTIsIntIn alloc] initWithValues:[NSIndexSet indexSetWithIndex:1] reverse:YES] autorelease]; + [NSValueTransformer setValueTransformer:vt forName:@"vtScanTypeIsNotContent"]; + _directoryPanel = nil; + _appName = APPNAME; + return self; +} + +- (IBAction)openWebsite:(id)sender +{ + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.hardcoded.net/dupeguru"]]; +} + +- (IBAction)toggleDirectories:(id)sender +{ + [[self directoryPanel] toggleVisible:sender]; +} + +- (DirectoryPanel *)directoryPanel +{ + if (!_directoryPanel) + _directoryPanel = [[DirectoryPanel alloc] initWithParentApp:self]; + return _directoryPanel; +} +- (PyDupeGuru *)py { return (PyDupeGuru *)py; } + +//Delegate +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification +{ + [[ProgressController mainProgressController] setWorker:py]; + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + //Restore Columns + NSArray *columnsOrder = [ud arrayForKey:@"columnsOrder"]; + NSDictionary *columnsWidth = [ud dictionaryForKey:@"columnsWidth"]; + if ([columnsOrder count]) + [result restoreColumnsPosition:columnsOrder widths:columnsWidth]; + //Reg stuff + if ([RegistrationInterface showNagWithApp:[self py] name:APPNAME limitDescription:LIMIT_DESC]) + [unlockMenuItem setTitle:@"Thanks for buying dupeGuru!"]; + //Restore results + [py loadIgnoreList]; + [py loadResults]; +} + +- (void)applicationWillBecomeActive:(NSNotification *)aNotification +{ + if (![[result window] isVisible]) + [result showWindow:NSApp]; +} + +- (void)applicationWillTerminate:(NSNotification *)aNotification +{ + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + [ud setObject: [result getColumnsOrder] forKey:@"columnsOrder"]; + [ud setObject: [result getColumnsWidth] forKey:@"columnsWidth"]; + [py saveResults]; + int sc = [ud integerForKey:@"sessionCountSinceLastIgnorePurge"]; + if (sc >= 10) + { + sc = -1; + [py purgeIgnoreList]; + } + sc++; + [ud setInteger:sc forKey:@"sessionCountSinceLastIgnorePurge"]; + [py saveIgnoreList]; + // NSApplication does not release nib instances objects, we must do it manually + // Well, it isn't needed because the memory is freed anyway (we are quitting the application + // But I need to release RecentDirectories so it saves the user defaults + [recentDirectories release]; +} + +- (void)recentDirecoryClicked:(NSString *)directory +{ + [[self directoryPanel] addDirectory:directory]; +} +@end diff --git a/se/cocoa/Consts.h b/se/cocoa/Consts.h new file mode 100644 index 00000000..b27af158 --- /dev/null +++ b/se/cocoa/Consts.h @@ -0,0 +1,3 @@ +#import "dgbase/Consts.h" + +#define APPNAME @"dupeGuru" \ No newline at end of file diff --git a/se/cocoa/DetailsPanel.h b/se/cocoa/DetailsPanel.h new file mode 100644 index 00000000..0d4c025d --- /dev/null +++ b/se/cocoa/DetailsPanel.h @@ -0,0 +1,13 @@ +#import +#import "cocoalib/PyApp.h" +#import "cocoalib/Table.h" + + +@interface DetailsPanel : NSWindowController +{ + IBOutlet TableView *detailsTable; +} +- (id)initWithPy:(PyApp *)aPy; + +- (void)refresh; +@end \ No newline at end of file diff --git a/se/cocoa/DetailsPanel.m b/se/cocoa/DetailsPanel.m new file mode 100644 index 00000000..1baac387 --- /dev/null +++ b/se/cocoa/DetailsPanel.m @@ -0,0 +1,16 @@ +#import "DetailsPanel.h" + +@implementation DetailsPanel +- (id)initWithPy:(PyApp *)aPy +{ + self = [super initWithWindowNibName:@"Details"]; + [self window]; //So the detailsTable is initialized. + [detailsTable setPy:aPy]; + return self; +} + +- (void)refresh +{ + [detailsTable reloadData]; +} +@end diff --git a/se/cocoa/DirectoryPanel.h b/se/cocoa/DirectoryPanel.h new file mode 100644 index 00000000..6f8141b9 --- /dev/null +++ b/se/cocoa/DirectoryPanel.h @@ -0,0 +1,7 @@ +#import +#import "dgbase/DirectoryPanel.h" + +@interface DirectoryPanel : DirectoryPanelBase +{ +} +@end diff --git a/se/cocoa/DirectoryPanel.m b/se/cocoa/DirectoryPanel.m new file mode 100644 index 00000000..dd07462d --- /dev/null +++ b/se/cocoa/DirectoryPanel.m @@ -0,0 +1,4 @@ +#import "DirectoryPanel.h" + +@implementation DirectoryPanel +@end diff --git a/se/cocoa/English.lproj/Details.nib/classes.nib b/se/cocoa/English.lproj/Details.nib/classes.nib new file mode 100644 index 00000000..e1b7cb92 --- /dev/null +++ b/se/cocoa/English.lproj/Details.nib/classes.nib @@ -0,0 +1,18 @@ +{ + IBClasses = ( + { + CLASS = DetailsPanel; + LANGUAGE = ObjC; + OUTLETS = {detailsTable = NSTableView; }; + SUPERCLASS = NSWindowController; + }, + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + CLASS = TableView; + LANGUAGE = ObjC; + OUTLETS = {py = PyApp; }; + SUPERCLASS = NSTableView; + } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/se/cocoa/English.lproj/Details.nib/info.nib b/se/cocoa/English.lproj/Details.nib/info.nib new file mode 100644 index 00000000..3f14ee77 --- /dev/null +++ b/se/cocoa/English.lproj/Details.nib/info.nib @@ -0,0 +1,16 @@ + + + + + IBDocumentLocation + 432 54 356 240 0 0 1024 746 + IBFramework Version + 443.0 + IBOpenObjects + + 5 + + IBSystem Version + 8I127 + + diff --git a/se/cocoa/English.lproj/Details.nib/keyedobjects.nib b/se/cocoa/English.lproj/Details.nib/keyedobjects.nib new file mode 100644 index 00000000..d4df1a78 Binary files /dev/null and b/se/cocoa/English.lproj/Details.nib/keyedobjects.nib differ diff --git a/se/cocoa/English.lproj/Directories.nib/classes.nib b/se/cocoa/English.lproj/Directories.nib/classes.nib new file mode 100644 index 00000000..3ebaa96a --- /dev/null +++ b/se/cocoa/English.lproj/Directories.nib/classes.nib @@ -0,0 +1,62 @@ + + + + + IBClasses + + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + ACTIONS + + askForDirectory + id + changeDirectoryState + id + popupAddDirectoryMenu + id + removeSelectedDirectory + id + toggleVisible + id + + CLASS + DirectoryPanel + LANGUAGE + ObjC + OUTLETS + + addButtonPopUp + NSPopUpButton + directories + NSOutlineView + removeButton + NSButton + + SUPERCLASS + DirectoryPanelBase + + + CLASS + OutlineView + LANGUAGE + ObjC + OUTLETS + + py + PyApp + + SUPERCLASS + NSOutlineView + + + IBVersion + 1 + + diff --git a/se/cocoa/English.lproj/Directories.nib/info.nib b/se/cocoa/English.lproj/Directories.nib/info.nib new file mode 100644 index 00000000..5c508e04 --- /dev/null +++ b/se/cocoa/English.lproj/Directories.nib/info.nib @@ -0,0 +1,20 @@ + + + + + IBFramework Version + 629 + IBLastKnownRelativeProjectPath + ../../dupeguru.xcodeproj + IBOldestOS + 5 + IBOpenObjects + + 6 + + IBSystem Version + 9B18 + targetFramework + IBCocoaFramework + + diff --git a/se/cocoa/English.lproj/Directories.nib/keyedobjects.nib b/se/cocoa/English.lproj/Directories.nib/keyedobjects.nib new file mode 100644 index 00000000..2275d202 Binary files /dev/null and b/se/cocoa/English.lproj/Directories.nib/keyedobjects.nib differ diff --git a/se/cocoa/English.lproj/InfoPlist.strings b/se/cocoa/English.lproj/InfoPlist.strings new file mode 100644 index 00000000..d224a14b Binary files /dev/null and b/se/cocoa/English.lproj/InfoPlist.strings differ diff --git a/se/cocoa/English.lproj/MainMenu.nib/classes.nib b/se/cocoa/English.lproj/MainMenu.nib/classes.nib new file mode 100644 index 00000000..3a85cf2a --- /dev/null +++ b/se/cocoa/English.lproj/MainMenu.nib/classes.nib @@ -0,0 +1,229 @@ + + + + + IBClasses + + + CLASS + NSSegmentedControl + LANGUAGE + ObjC + SUPERCLASS + NSControl + + + ACTIONS + + openWebsite + id + toggleDirectories + id + unlockApp + id + + CLASS + AppDelegate + LANGUAGE + ObjC + OUTLETS + + py + PyDupeGuru + recentDirectories + RecentDirectories + result + ResultWindow + unlockMenuItem + NSMenuItem + + SUPERCLASS + NSObject + + + CLASS + PyApp + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + CLASS + MatchesView + LANGUAGE + ObjC + SUPERCLASS + OutlineView + + + CLASS + PyDupeGuru + LANGUAGE + ObjC + SUPERCLASS + PyApp + + + ACTIONS + + changeDelta + id + changePowerMarker + id + clearIgnoreList + id + collapseAll + id + copyMarked + id + deleteMarked + id + expandAll + id + exportToXHTML + id + filter + id + ignoreSelected + id + markAll + id + markInvert + id + markNone + id + markSelected + id + markToggle + id + moveMarked + id + openSelected + id + refresh + id + removeMarked + id + removeSelected + id + renameSelected + id + resetColumnsToDefault + id + revealSelected + id + showPreferencesPanel + id + startDuplicateScan + id + switchSelected + id + toggleColumn + id + toggleDelta + id + toggleDetailsPanel + id + togglePowerMarker + id + + CLASS + ResultWindow + LANGUAGE + ObjC + OUTLETS + + actionMenu + NSPopUpButton + actionMenuView + NSView + app + id + columnsMenu + NSMenu + deltaSwitch + NSSegmentedControl + deltaSwitchView + NSView + filterField + NSSearchField + filterFieldView + NSView + matches + MatchesView + pmSwitch + NSSegmentedControl + pmSwitchView + NSView + preferencesPanel + NSWindow + py + PyDupeGuru + stats + NSTextField + + SUPERCLASS + NSWindowController + + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + ACTIONS + + checkForUpdates + id + + CLASS + SUUpdater + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + ACTIONS + + clearMenu + id + menuClick + id + + CLASS + RecentDirectories + LANGUAGE + ObjC + OUTLETS + + delegate + id + menu + NSMenu + + SUPERCLASS + NSObject + + + CLASS + OutlineView + LANGUAGE + ObjC + OUTLETS + + py + PyApp + + SUPERCLASS + NSOutlineView + + + IBVersion + 1 + + diff --git a/se/cocoa/English.lproj/MainMenu.nib/info.nib b/se/cocoa/English.lproj/MainMenu.nib/info.nib new file mode 100644 index 00000000..6799cea9 --- /dev/null +++ b/se/cocoa/English.lproj/MainMenu.nib/info.nib @@ -0,0 +1,20 @@ + + + + + IBFramework Version + 629 + IBLastKnownRelativeProjectPath + ../../dupeguru.xcodeproj + IBOldestOS + 5 + IBOpenObjects + + 524 + + IBSystem Version + 9E17 + targetFramework + IBCocoaFramework + + diff --git a/se/cocoa/English.lproj/MainMenu.nib/keyedobjects.nib b/se/cocoa/English.lproj/MainMenu.nib/keyedobjects.nib new file mode 100644 index 00000000..7136407c Binary files /dev/null and b/se/cocoa/English.lproj/MainMenu.nib/keyedobjects.nib differ diff --git a/se/cocoa/Info.plist b/se/cocoa/Info.plist new file mode 100644 index 00000000..d24efa47 --- /dev/null +++ b/se/cocoa/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleHelpBookFolder + dupeguru_help + CFBundleHelpBookName + dupeGuru Help + CFBundleIconFile + dupeguru + CFBundleIdentifier + com.hardcoded_software.dupeguru + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + hsft + CFBundleVersion + 2.7.1 + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + SUFeedURL + http://www.hardcoded.net/updates/dupeguru.appcast + + diff --git a/se/cocoa/PyDupeGuru.h b/se/cocoa/PyDupeGuru.h new file mode 100644 index 00000000..85874157 --- /dev/null +++ b/se/cocoa/PyDupeGuru.h @@ -0,0 +1,9 @@ +#import +#import "dgbase/PyDupeGuru.h" + +@interface PyDupeGuru : PyDupeGuruBase +//Scanning options +- (void)setScanType:(NSNumber *)scan_type; +- (void)setWordWeighting:(NSNumber *)words_are_weighted; +- (void)setMatchSimilarWords:(NSNumber *)match_similar_words; +@end diff --git a/se/cocoa/ResultWindow.h b/se/cocoa/ResultWindow.h new file mode 100644 index 00000000..443d5afe --- /dev/null +++ b/se/cocoa/ResultWindow.h @@ -0,0 +1,55 @@ +#import +#import "cocoalib/Outline.h" +#import "dgbase/ResultWindow.h" +#import "DetailsPanel.h" +#import "DirectoryPanel.h" + +@interface ResultWindow : ResultWindowBase +{ + IBOutlet NSPopUpButton *actionMenu; + IBOutlet NSMenu *columnsMenu; + IBOutlet NSSearchField *filterField; + IBOutlet NSSegmentedControl *pmSwitch; + IBOutlet NSWindow *preferencesPanel; + IBOutlet NSTextField *stats; + + NSString *_lastAction; + DetailsPanel *_detailsPanel; + NSMutableArray *_resultColumns; + NSMutableIndexSet *_deltaColumns; +} +- (IBAction)changePowerMarker:(id)sender; +- (IBAction)clearIgnoreList:(id)sender; +- (IBAction)exportToXHTML:(id)sender; +- (IBAction)filter:(id)sender; +- (IBAction)ignoreSelected:(id)sender; +- (IBAction)markAll:(id)sender; +- (IBAction)markInvert:(id)sender; +- (IBAction)markNone:(id)sender; +- (IBAction)markSelected:(id)sender; +- (IBAction)markToggle:(id)sender; +- (IBAction)openSelected:(id)sender; +- (IBAction)refresh:(id)sender; +- (IBAction)removeMarked:(id)sender; +- (IBAction)removeSelected:(id)sender; +- (IBAction)renameSelected:(id)sender; +- (IBAction)resetColumnsToDefault:(id)sender; +- (IBAction)revealSelected:(id)sender; +- (IBAction)showPreferencesPanel:(id)sender; +- (IBAction)startDuplicateScan:(id)sender; +- (IBAction)switchSelected:(id)sender; +- (IBAction)toggleColumn:(id)sender; +- (IBAction)toggleDelta:(id)sender; +- (IBAction)toggleDetailsPanel:(id)sender; +- (IBAction)togglePowerMarker:(id)sender; + +- (NSTableColumn *)getColumnForIdentifier:(int)aIdentifier title:(NSString *)aTitle width:(int)aWidth refCol:(NSTableColumn *)aColumn; +- (NSArray *)getColumnsOrder; +- (NSDictionary *)getColumnsWidth; +- (NSArray *)getSelected:(BOOL)aDupesOnly; +- (NSArray *)getSelectedPaths:(BOOL)aDupesOnly; +- (void)initResultColumns; +- (void)performPySelection:(NSArray *)aIndexPaths; +- (void)refreshStats; +- (void)restoreColumnsPosition:(NSArray *)aColumnsOrder widths:(NSDictionary *)aColumnsWidth; +@end diff --git a/se/cocoa/ResultWindow.m b/se/cocoa/ResultWindow.m new file mode 100644 index 00000000..49b80b56 --- /dev/null +++ b/se/cocoa/ResultWindow.m @@ -0,0 +1,460 @@ +#import "ResultWindow.h" +#import "cocoalib/Dialogs.h" +#import "cocoalib/ProgressController.h" +#import "cocoalib/Utils.h" +#import "AppDelegate.h" +#import "Consts.h" + +@implementation ResultWindow +/* Override */ +- (void)awakeFromNib +{ + [super awakeFromNib]; + _detailsPanel = nil; + _displayDelta = NO; + _powerMode = NO; + _deltaColumns = [[NSMutableIndexSet indexSetWithIndexesInRange:NSMakeRange(2,4)] retain]; + [_deltaColumns removeIndex:3]; + [deltaSwitch setSelectedSegment:0]; + [pmSwitch setSelectedSegment:0]; + [py setDisplayDeltaValues:b2n(_displayDelta)]; + [matches setTarget:self]; + [matches setDoubleAction:@selector(openSelected:)]; + [[actionMenu itemAtIndex:0] setImage:[NSImage imageNamed: @"gear"]]; + [self initResultColumns]; + [self refreshStats]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resultsMarkingChanged:) name:ResultsMarkingChangedNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(duplicateSelectionChanged:) name:DuplicateSelectionChangedNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resultsChanged:) name:ResultsChangedNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jobCompleted:) name:JobCompletedNotification object:nil]; + + NSToolbar *t = [[[NSToolbar alloc] initWithIdentifier:@"ResultWindowToolbar"] autorelease]; + [t setAllowsUserCustomization:YES]; + [t setAutosavesConfiguration:YES]; + [t setDisplayMode:NSToolbarDisplayModeIconAndLabel]; + [t setDelegate:self]; + [[self window] setToolbar:t]; +} + +/* Actions */ + +- (IBAction)changePowerMarker:(id)sender +{ + _powerMode = [pmSwitch selectedSegment] == 1; + if (_powerMode) + [matches setTag:2]; + else + [matches setTag:0]; + [self expandAll:nil]; + [self outlineView:matches didClickTableColumn:nil]; +} + +- (IBAction)clearIgnoreList:(id)sender +{ + int i = n2i([py getIgnoreListCount]); + if (!i) + return; + if ([Dialogs askYesNo:[NSString stringWithFormat:@"Do you really want to remove all %d items from the ignore list?",i]] == NSAlertSecondButtonReturn) // NO + return; + [py clearIgnoreList]; +} + +- (IBAction)exportToXHTML:(id)sender +{ + NSString *xsltPath = [[NSBundle mainBundle] pathForResource:@"dg" ofType:@"xsl"]; + NSString *cssPath = [[NSBundle mainBundle] pathForResource:@"hardcoded" ofType:@"css"]; + NSString *exported = [py exportToXHTMLwithColumns:[self getColumnsOrder] xslt:xsltPath css:cssPath]; + [[NSWorkspace sharedWorkspace] openFile:exported]; +} + +- (IBAction)filter:(id)sender +{ + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + [py setEscapeFilterRegexp:b2n(!n2b([ud objectForKey:@"useRegexpFilter"]))]; + [py applyFilter:[filterField stringValue]]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)ignoreSelected:(id)sender +{ + NSArray *nodeList = [self getSelected:YES]; + if (![nodeList count]) + return; + if ([Dialogs askYesNo:[NSString stringWithFormat:@"All selected %d matches are going to be ignored in all subsequent scans. Continue?",[nodeList count]]] == NSAlertSecondButtonReturn) // NO + return; + [self performPySelection:[self getSelectedPaths:YES]]; + [py addSelectedToIgnoreList]; + [py removeSelected]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)markAll:(id)sender +{ + [py markAll]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsMarkingChangedNotification object:self]; +} + +- (IBAction)markInvert:(id)sender +{ + [py markInvert]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsMarkingChangedNotification object:self]; +} + +- (IBAction)markNone:(id)sender +{ + [py markNone]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsMarkingChangedNotification object:self]; +} + +- (IBAction)markSelected:(id)sender +{ + [self performPySelection:[self getSelectedPaths:YES]]; + [py toggleSelectedMark]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsMarkingChangedNotification object:self]; +} + +- (IBAction)markToggle:(id)sender +{ + OVNode *node = [matches itemAtRow:[matches clickedRow]]; + [self performPySelection:[NSArray arrayWithObject:p2a([node indexPath])]]; + [py toggleSelectedMark]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsMarkingChangedNotification object:self]; +} + +- (IBAction)openSelected:(id)sender +{ + [self performPySelection:[self getSelectedPaths:NO]]; + [py openSelected]; +} + +- (IBAction)refresh:(id)sender +{ + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)removeMarked:(id)sender +{ + int mark_count = [[py getMarkCount] intValue]; + if (!mark_count) + return; + if ([Dialogs askYesNo:[NSString stringWithFormat:@"You are about to remove %d files from results. Continue?",mark_count]] == NSAlertSecondButtonReturn) // NO + return; + [py removeMarked]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)removeSelected:(id)sender +{ + NSArray *nodeList = [self getSelected:YES]; + if (![nodeList count]) + return; + if ([Dialogs askYesNo:[NSString stringWithFormat:@"You are about to remove %d files from results. Continue?",[nodeList count]]] == NSAlertSecondButtonReturn) // NO + return; + [self performPySelection:[self getSelectedPaths:YES]]; + [py removeSelected]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)renameSelected:(id)sender +{ + int col = [matches columnWithIdentifier:@"0"]; + int row = [matches selectedRow]; + [matches editColumn:col row:row withEvent:[NSApp currentEvent] select:YES]; +} + +- (IBAction)resetColumnsToDefault:(id)sender +{ + NSMutableArray *columnsOrder = [NSMutableArray array]; + [columnsOrder addObject:@"0"]; + [columnsOrder addObject:@"1"]; + [columnsOrder addObject:@"2"]; + [columnsOrder addObject:@"6"]; + NSMutableDictionary *columnsWidth = [NSMutableDictionary dictionary]; + [columnsWidth setObject:i2n(195) forKey:@"0"]; + [columnsWidth setObject:i2n(120) forKey:@"1"]; + [columnsWidth setObject:i2n(63) forKey:@"2"]; + [columnsWidth setObject:i2n(60) forKey:@"6"]; + [self restoreColumnsPosition:columnsOrder widths:columnsWidth]; +} + +- (IBAction)revealSelected:(id)sender +{ + [self performPySelection:[self getSelectedPaths:NO]]; + [py revealSelected]; +} + +- (IBAction)showPreferencesPanel:(id)sender +{ + [preferencesPanel makeKeyAndOrderFront:sender]; +} + +- (IBAction)startDuplicateScan:(id)sender +{ + if ([matches numberOfRows] > 0) + { + if ([Dialogs askYesNo:@"Are you sure you want to start a new duplicate scan?"] == NSAlertSecondButtonReturn) // NO + return; + } + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + PyDupeGuru *_py = (PyDupeGuru *)py; + [_py setScanType:[ud objectForKey:@"scanType"]]; + [_py setMinMatchPercentage:[ud objectForKey:@"minMatchPercentage"]]; + [_py setWordWeighting:[ud objectForKey:@"wordWeighting"]]; + [_py setMixFileKind:[ud objectForKey:@"mixFileKind"]]; + [_py setMatchSimilarWords:[ud objectForKey:@"matchSimilarWords"]]; + int smallFileThreshold = [ud integerForKey:@"smallFileThreshold"]; // In KB + int sizeThreshold = [ud boolForKey:@"ignoreSmallFiles"] ? smallFileThreshold * 1024 : 0; // The py side wants bytes + [_py setSizeThreshold:sizeThreshold]; + int r = n2i([py doScan]); + [matches reloadData]; + [self refreshStats]; + if (r != 0) + [[ProgressController mainProgressController] hide]; + if (r == 1) + [Dialogs showMessage:@"You cannot make a duplicate scan with only reference directories."]; + if (r == 3) + { + [Dialogs showMessage:@"The selected directories contain no scannable file."]; + [app toggleDirectories:nil]; + } +} + +- (IBAction)switchSelected:(id)sender +{ + [self performPySelection:[self getSelectedPaths:YES]]; + [py makeSelectedReference]; + [[NSNotificationCenter defaultCenter] postNotificationName:ResultsChangedNotification object:self]; +} + +- (IBAction)toggleColumn:(id)sender +{ + NSMenuItem *mi = sender; + NSString *colId = [NSString stringWithFormat:@"%d",[mi tag]]; + NSTableColumn *col = [matches tableColumnWithIdentifier:colId]; + if (col == nil) + { + //Add Column + col = [_resultColumns objectAtIndex:[mi tag]]; + [matches addTableColumn:col]; + [mi setState:NSOnState]; + } + else + { + //Remove column + [matches removeTableColumn:col]; + [mi setState:NSOffState]; + } +} + +- (IBAction)toggleDelta:(id)sender +{ + if ([deltaSwitch selectedSegment] == 1) + [deltaSwitch setSelectedSegment:0]; + else + [deltaSwitch setSelectedSegment:1]; + [self changeDelta:sender]; +} + +- (IBAction)toggleDetailsPanel:(id)sender +{ + if (!_detailsPanel) + _detailsPanel = [[DetailsPanel alloc] initWithPy:py]; + if ([[_detailsPanel window] isVisible]) + [[_detailsPanel window] close]; + else + [[_detailsPanel window] orderFront:nil]; +} + +- (IBAction)togglePowerMarker:(id)sender +{ + if ([pmSwitch selectedSegment] == 1) + [pmSwitch setSelectedSegment:0]; + else + [pmSwitch setSelectedSegment:1]; + [self changePowerMarker:sender]; +} + +/* Public */ +- (NSTableColumn *)getColumnForIdentifier:(int)aIdentifier title:(NSString *)aTitle width:(int)aWidth refCol:(NSTableColumn *)aColumn +{ + NSNumber *n = [NSNumber numberWithInt:aIdentifier]; + NSTableColumn *col = [[NSTableColumn alloc] initWithIdentifier:[n stringValue]]; + [col setWidth:aWidth]; + [col setEditable:NO]; + [[col dataCell] setFont:[[aColumn dataCell] font]]; + [[col headerCell] setStringValue:aTitle]; + [col setResizingMask:NSTableColumnUserResizingMask]; + [col setSortDescriptorPrototype:[[NSSortDescriptor alloc] initWithKey:[n stringValue] ascending:YES]]; + return col; +} + +//Returns an array of identifiers, in order. +- (NSArray *)getColumnsOrder +{ + NSTableColumn *col; + NSString *colId; + NSMutableArray *result = [NSMutableArray array]; + NSEnumerator *e = [[matches tableColumns] objectEnumerator]; + while (col = [e nextObject]) + { + colId = [col identifier]; + [result addObject:colId]; + } + return result; +} + +- (NSDictionary *)getColumnsWidth +{ + NSMutableDictionary *result = [NSMutableDictionary dictionary]; + NSTableColumn *col; + NSString *colId; + NSNumber *width; + NSEnumerator *e = [[matches tableColumns] objectEnumerator]; + while (col = [e nextObject]) + { + colId = [col identifier]; + width = [NSNumber numberWithFloat:[col width]]; + [result setObject:width forKey:colId]; + } + return result; +} + +- (NSArray *)getSelected:(BOOL)aDupesOnly +{ + if (_powerMode) + aDupesOnly = NO; + NSIndexSet *indexes = [matches selectedRowIndexes]; + NSMutableArray *nodeList = [NSMutableArray array]; + OVNode *node; + int i = [indexes firstIndex]; + while (i != NSNotFound) + { + node = [matches itemAtRow:i]; + if (!aDupesOnly || ([node level] > 1)) + [nodeList addObject:node]; + i = [indexes indexGreaterThanIndex:i]; + } + return nodeList; +} + +- (NSArray *)getSelectedPaths:(BOOL)aDupesOnly +{ + NSMutableArray *r = [NSMutableArray array]; + NSArray *selected = [self getSelected:aDupesOnly]; + NSEnumerator *e = [selected objectEnumerator]; + OVNode *node; + while (node = [e nextObject]) + [r addObject:p2a([node indexPath])]; + return r; +} + +- (void)performPySelection:(NSArray *)aIndexPaths +{ + if (_powerMode) + [py selectPowerMarkerNodePaths:aIndexPaths]; + else + [py selectResultNodePaths:aIndexPaths]; +} + +- (void)initResultColumns +{ + NSTableColumn *refCol = [matches tableColumnWithIdentifier:@"0"]; + _resultColumns = [[NSMutableArray alloc] init]; + [_resultColumns addObject:[matches tableColumnWithIdentifier:@"0"]]; // File Name + [_resultColumns addObject:[matches tableColumnWithIdentifier:@"1"]]; // Directory + [_resultColumns addObject:[matches tableColumnWithIdentifier:@"2"]]; // Size + [_resultColumns addObject:[self getColumnForIdentifier:3 title:@"Kind" width:40 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:4 title:@"Creation" width:120 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:5 title:@"Modification" width:120 refCol:refCol]]; + [_resultColumns addObject:[matches tableColumnWithIdentifier:@"6"]]; // Match % + [_resultColumns addObject:[self getColumnForIdentifier:7 title:@"Words Used" width:120 refCol:refCol]]; + [_resultColumns addObject:[self getColumnForIdentifier:8 title:@"Dupe Count" width:80 refCol:refCol]]; +} + +-(void)refreshStats +{ + [stats setStringValue:[py getStatLine]]; +} + +- (void)restoreColumnsPosition:(NSArray *)aColumnsOrder widths:(NSDictionary *)aColumnsWidth +{ + NSTableColumn *col; + NSString *colId; + NSNumber *width; + NSMenuItem *mi; + //Remove all columns + NSEnumerator *e = [[columnsMenu itemArray] objectEnumerator]; + while (mi = [e nextObject]) + { + if ([mi state] == NSOnState) + [self toggleColumn:mi]; + } + //Add columns and set widths + e = [aColumnsOrder objectEnumerator]; + while (colId = [e nextObject]) + { + if (![colId isEqual:@"mark"]) + { + col = [_resultColumns objectAtIndex:[colId intValue]]; + width = [aColumnsWidth objectForKey:[col identifier]]; + mi = [columnsMenu itemWithTag:[colId intValue]]; + if (width) + [col setWidth:[width floatValue]]; + [self toggleColumn:mi]; + } + } +} + +/* Delegate */ +- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item +{ + OVNode *node = item; + if ([[tableColumn identifier] isEqual:@"mark"]) + { + [cell setEnabled: [node isMarkable]]; + } + if ([cell isKindOfClass:[NSTextFieldCell class]]) + { + // Determine if the text color will be blue due to directory being reference. + NSTextFieldCell *textCell = cell; + if ([node isMarkable]) + [textCell setTextColor:[NSColor blackColor]]; + else + [textCell setTextColor:[NSColor blueColor]]; + if ((_displayDelta) && (_powerMode || ([node level] > 1))) + { + int i = [[tableColumn identifier] intValue]; + if ([_deltaColumns containsIndex:i]) + [textCell setTextColor:[NSColor orangeColor]]; + } + } +} + +/* Notifications */ +- (void)duplicateSelectionChanged:(NSNotification *)aNotification +{ + if (_detailsPanel) + [_detailsPanel refresh]; +} + +- (void)outlineViewSelectionDidChange:(NSNotification *)notification +{ + [self performPySelection:[self getSelectedPaths:NO]]; + [py refreshDetailsWithSelected]; + [[NSNotificationCenter defaultCenter] postNotificationName:DuplicateSelectionChangedNotification object:self]; +} + +- (void)resultsChanged:(NSNotification *)aNotification +{ + [matches reloadData]; + [self expandAll:nil]; + [self outlineViewSelectionDidChange:nil]; + [self refreshStats]; +} + +- (void)resultsMarkingChanged:(NSNotification *)aNotification +{ + [matches invalidateMarkings]; + [self refreshStats]; +} +@end diff --git a/se/cocoa/dupeguru.icns b/se/cocoa/dupeguru.icns new file mode 100755 index 00000000..6641a6b4 Binary files /dev/null and b/se/cocoa/dupeguru.icns differ diff --git a/se/cocoa/dupeguru.xcodeproj/hsoft.mode1 b/se/cocoa/dupeguru.xcodeproj/hsoft.mode1 new file mode 100644 index 00000000..6ffe0908 --- /dev/null +++ b/se/cocoa/dupeguru.xcodeproj/hsoft.mode1 @@ -0,0 +1,1369 @@ + + + + + ActivePerspectiveName + Project + AllowedModules + + + BundleLoadPath + + MaxInstances + n + Module + PBXSmartGroupTreeModule + Name + Groups and Files Outline View + + + BundleLoadPath + + MaxInstances + n + Module + PBXNavigatorGroup + Name + Editor + + + BundleLoadPath + + MaxInstances + n + Module + XCTaskListModule + Name + Task List + + + BundleLoadPath + + MaxInstances + n + Module + XCDetailModule + Name + File and Smart Group Detail Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXBuildResultsModule + Name + Detailed Build Results Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXProjectFindModule + Name + Project Batch Find Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXRunSessionModule + Name + Run Log + + + BundleLoadPath + + MaxInstances + n + Module + PBXBookmarksModule + Name + Bookmarks Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXClassBrowserModule + Name + Class Browser + + + BundleLoadPath + + MaxInstances + n + Module + PBXCVSModule + Name + Source Code Control Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXDebugBreakpointsModule + Name + Debug Breakpoints Tool + + + BundleLoadPath + + MaxInstances + n + Module + XCDockableInspector + Name + Inspector + + + BundleLoadPath + + MaxInstances + n + Module + PBXOpenQuicklyModule + Name + Open Quickly Tool + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugSessionModule + Name + Debugger + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugCLIModule + Name + Debug Console + + + Description + DefaultDescriptionKey + DockingSystemVisible + + Extension + mode1 + FavBarConfig + + PBXProjectModuleGUID + CE381CB409914B41003581CE + XCBarModuleItemNames + + XCBarModuleItems + + + FirstTimeWindowDisplayed + + Identifier + com.apple.perspectives.project.mode1 + MajorVersion + 31 + MinorVersion + 1 + Name + Default + Notifications + + OpenEditors + + PerspectiveWidths + + -1 + -1 + + Perspectives + + + ChosenToolbarItems + + active-executable-popup + action + active-buildstyle-popup + active-target-popup + buildOrClean + build-and-runOrDebug + com.apple.ide.PBXToolbarStopButton + get-info + toggle-editor + + ControllerClassBaseName + + IconName + WindowOfProjectWithEditor + Identifier + perspective.project + IsVertical + + Layout + + + BecomeActive + + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C08E77C0454961000C914BD + 1C37FABC05509CD000000102 + 1C37FABC05539CD112110102 + E2644B35053B69B200211256 + 1C37FABC04509CD000100104 + + PBXProjectModuleGUID + 1CE0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 194 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 29B97314FDCFA39411CA2CEA + 080E96DDFE201D6D7F000001 + 29B97317FDCFA39411CA2CEA + 29B97323FDCFA39411CA2CEA + 1058C7A0FEA54F0111CA2CBB + 1058C7A2FEA54F0111CA2CBB + 19C28FACFE9D520D11CA2CBB + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C37FABC05509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 37 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {194, 764}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + + XCSharingToken + com.apple.Xcode.GFSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {211, 782}} + GroupTreeTableConfiguration + + MainColumn + 194 + + RubberWindowFrame + 1 55 1366 823 0 0 1440 878 + + Module + PBXSmartGroupTreeModule + Proportion + 211pt + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CE0B20306471E060097A5F4 + PBXProjectModuleLabel + Info.plist + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1CE0B20406471E060097A5F4 + PBXProjectModuleLabel + Info.plist + _historyCapacity + 10 + bookmark + CE6D39D50C9B15B600C7FE6C + history + + CEDA43440B07D11900B3091A + CECEEB580B0CAE8E00E6972C + CECEEBE40B0CB68A00E6972C + CECEEBE60B0CB68A00E6972C + CECEEBE70B0CB68A00E6972C + CED9635E0B0F954E00DDBB8C + CE24ED9F0B552A5D00DDF502 + CE6D394A0C9B111900C7FE6C + + prevStack + + CEF411790A110C7F00E7F110 + CE6E6AE60AA528B2002F29BE + CE6E6AE70AA528B2002F29BE + CE17C9AC0B04D16D0023E222 + CE17C9AD0B04D16D0023E222 + CE17CA230B04E15F0023E222 + CED963600B0F954E00DDBB8C + CE24EDA00B552A5D00DDF502 + + + SplitCount + 1 + + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {1150, 544}} + RubberWindowFrame + 1 55 1366 823 0 0 1440 878 + + Module + PBXNavigatorGroup + Proportion + 544pt + + + ContentConfiguration + + PBXProjectModuleGUID + 1CE0B20506471E060097A5F4 + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{0, 549}, {1150, 233}} + RubberWindowFrame + 1 55 1366 823 0 0 1440 878 + + Module + XCDetailModule + Proportion + 233pt + + + Proportion + 1150pt + + + Name + Project + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + XCModuleDock + PBXNavigatorGroup + XCDetailModule + + TableOfContents + + CE6D39CF0C9B114700C7FE6C + 1CE0B1FE06471DED0097A5F4 + CE6D39D00C9B114700C7FE6C + 1CE0B20306471E060097A5F4 + 1CE0B20506471E060097A5F4 + + ToolbarConfiguration + xcode.toolbar.config.default + + + ControllerClassBaseName + + IconName + WindowOfProject + Identifier + perspective.morph + IsVertical + 0 + Layout + + + BecomeActive + 1 + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C08E77C0454961000C914BD + 1C37FABC05509CD000000102 + 1C37FABC05539CD112110102 + E2644B35053B69B200211256 + 1C37FABC04509CD000100104 + 1CC0EA4004350EF90044410B + 1CC0EA4004350EF90041110B + + PBXProjectModuleGUID + 11E0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 186 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 29B97314FDCFA39411CA2CEA + 1C37FABC05509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {186, 337}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + 1 + XCSharingToken + com.apple.Xcode.GFSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {203, 355}} + GroupTreeTableConfiguration + + MainColumn + 186 + + RubberWindowFrame + 373 269 690 397 0 0 1440 878 + + Module + PBXSmartGroupTreeModule + Proportion + 100% + + + Name + Morph + PreferredWidth + 300 + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + + TableOfContents + + 11E0B1FE06471DED0097A5F4 + + ToolbarConfiguration + xcode.toolbar.config.default.short + + + PerspectivesBarVisible + + ShelfIsVisible + + SourceDescription + file at '/System/Library/PrivateFrameworks/DevToolsInterface.framework/Versions/A/Resources/XCPerspectivesSpecificationMode1.xcperspec' + StatusbarIsVisible + + TimeStamp + 0.0 + ToolbarDisplayMode + 1 + ToolbarIsVisible + + ToolbarSizeMode + 1 + Type + Perspectives + UpdateMessage + The Default Workspace in this version of Xcode now includes support to hide and show the detail view (what has been referred to as the "Metro-Morph" feature). You must discard your current Default Workspace settings and update to the latest Default Workspace in order to gain this feature. Do you wish to update to the latest Workspace defaults for project '%@'? + WindowJustification + 5 + WindowOrderList + + 1C0AD2B3069F1EA900FABCE6 + CE381CCE09914BC8003581CE + /Users/hsoft/src/dupeguru_cocoa/dupeguru.xcodeproj + + WindowString + 1 55 1366 823 0 0 1440 878 + WindowTools + + + FirstTimeWindowDisplayed + + Identifier + windowTool.build + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CD0528F0623707200166675 + PBXProjectModuleLabel + + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {1366, 540}} + RubberWindowFrame + 0 56 1366 822 0 0 1440 878 + + Module + PBXNavigatorGroup + Proportion + 540pt + + + ContentConfiguration + + PBXProjectModuleGUID + XCMainBuildResultsModuleGUID + PBXProjectModuleLabel + Build + XCBuildResultsTrigger_Collapse + 1021 + XCBuildResultsTrigger_Open + 1011 + + GeometryConfiguration + + Frame + {{0, 545}, {1366, 236}} + RubberWindowFrame + 0 56 1366 822 0 0 1440 878 + + Module + PBXBuildResultsModule + Proportion + 236pt + + + Proportion + 781pt + + + Name + Build Results + ServiceClasses + + PBXBuildResultsModule + + StatusbarIsVisible + + TableOfContents + + CE381CCE09914BC8003581CE + CE6D39D10C9B114700C7FE6C + 1CD0528F0623707200166675 + XCMainBuildResultsModuleGUID + + ToolbarConfiguration + xcode.toolbar.config.build + WindowString + 0 56 1366 822 0 0 1440 878 + WindowToolGUID + CE381CCE09914BC8003581CE + WindowToolIsVisible + + + + FirstTimeWindowDisplayed + + Identifier + windowTool.debugger + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + Debugger + + HorizontalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {0, 258}} + {{0, 0}, {1024, 258}} + + + VerticalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {1024, 258}} + {{0, 258}, {1024, 387}} + + + + LauncherConfigVersion + 8 + PBXProjectModuleGUID + 1C162984064C10D400B95A72 + PBXProjectModuleLabel + Debug - GLUTExamples (Underwater) + + GeometryConfiguration + + DebugConsoleDrawerSize + {100, 120} + DebugConsoleVisible + None + DebugConsoleWindowFrame + {{200, 200}, {500, 300}} + DebugSTDIOWindowFrame + {{200, 200}, {500, 300}} + Frame + {{0, 0}, {1024, 645}} + RubberWindowFrame + 342 192 1024 686 0 0 1440 878 + + Module + PBXDebugSessionModule + Proportion + 645pt + + + Proportion + 645pt + + + Name + Debugger + ServiceClasses + + PBXDebugSessionModule + + StatusbarIsVisible + + TableOfContents + + 1CD10A99069EF8BA00B06720 + CE24EDA90B552A6300DDF502 + 1C162984064C10D400B95A72 + CE24EDAA0B552A6300DDF502 + CE24EDAB0B552A6300DDF502 + CE24EDAC0B552A6300DDF502 + CE24EDAD0B552A6300DDF502 + CE24EDAE0B552A6300DDF502 + CE24EDAF0B552A6300DDF502 + + ToolbarConfiguration + xcode.toolbar.config.debug + WindowString + 342 192 1024 686 0 0 1440 878 + WindowToolGUID + 1CD10A99069EF8BA00B06720 + WindowToolIsVisible + + + + FirstTimeWindowDisplayed + + Identifier + windowTool.find + IsVertical + + Layout + + + Dock + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CDD528C0622207200134675 + PBXProjectModuleLabel + AppDelegate.m + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {781, 212}} + RubberWindowFrame + 84 374 781 470 0 0 1440 878 + + Module + PBXNavigatorGroup + Proportion + 781pt + + + Proportion + 212pt + + + BecomeActive + + ContentConfiguration + + PBXProjectModuleGUID + 1CD0528E0623707200166675 + PBXProjectModuleLabel + Project Find + + GeometryConfiguration + + Frame + {{0, 217}, {781, 212}} + RubberWindowFrame + 84 374 781 470 0 0 1440 878 + + Module + PBXProjectFindModule + Proportion + 212pt + + + Proportion + 429pt + + + Name + Project Find + ServiceClasses + + PBXProjectFindModule + + StatusbarIsVisible + + TableOfContents + + 1C530D57069F1CE1000CFCEE + CECEEB510B0CAE8800E6972C + CECEEB520B0CAE8800E6972C + 1CDD528C0622207200134675 + 1CD0528E0623707200166675 + + WindowString + 84 374 781 470 0 0 1440 878 + WindowToolGUID + 1C530D57069F1CE1000CFCEE + WindowToolIsVisible + + + + Identifier + MENUSEPARATOR + + + FirstTimeWindowDisplayed + + Identifier + windowTool.debuggerConsole + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1C78EAAC065D492600B07095 + PBXProjectModuleLabel + Debugger Console + + GeometryConfiguration + + Frame + {{0, 0}, {440, 358}} + RubberWindowFrame + 72 414 440 400 0 0 1440 878 + + Module + PBXDebugCLIModule + Proportion + 358pt + + + Proportion + 359pt + + + Name + Debugger Console + ServiceClasses + + PBXDebugCLIModule + + StatusbarIsVisible + + TableOfContents + + CECD0ADE099294C1003DC359 + CE24EDB00B552A6300DDF502 + 1C78EAAC065D492600B07095 + + WindowString + 72 414 440 400 0 0 1440 878 + WindowToolGUID + CECD0ADE099294C1003DC359 + WindowToolIsVisible + + + + FirstTimeWindowDisplayed + + Identifier + windowTool.run + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + LauncherConfigVersion + 3 + PBXProjectModuleGUID + 1CD0528B0623707200166675 + PBXProjectModuleLabel + Run + Runner + + HorizontalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {367, 168}} + {{0, 173}, {367, 270}} + + + VerticalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {406, 443}} + {{411, 0}, {517, 443}} + + + + + GeometryConfiguration + + Frame + {{0, 0}, {1024, 645}} + RubberWindowFrame + 343 192 1024 686 0 0 1440 878 + + Module + PBXRunSessionModule + Proportion + 645pt + + + Proportion + 645pt + + + Name + Run Log + ServiceClasses + + PBXRunSessionModule + + StatusbarIsVisible + + TableOfContents + + 1C0AD2B3069F1EA900FABCE6 + CE6D39D20C9B114700C7FE6C + 1CD0528B0623707200166675 + CE6D39D30C9B114700C7FE6C + + ToolbarConfiguration + xcode.toolbar.config.run + WindowString + 343 192 1024 686 0 0 1440 878 + WindowToolGUID + 1C0AD2B3069F1EA900FABCE6 + WindowToolIsVisible + + + + Identifier + windowTool.scm + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1C78EAB2065D492600B07095 + PBXProjectModuleLabel + <No Editor> + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1C78EAB3065D492600B07095 + + SplitCount + 1 + + StatusBarVisibility + 1 + + GeometryConfiguration + + Frame + {{0, 0}, {452, 0}} + RubberWindowFrame + 743 379 452 308 0 0 1280 1002 + + Module + PBXNavigatorGroup + Proportion + 0pt + + + BecomeActive + 1 + ContentConfiguration + + PBXProjectModuleGUID + 1CD052920623707200166675 + PBXProjectModuleLabel + SCM + + GeometryConfiguration + + ConsoleFrame + {{0, 259}, {452, 0}} + Frame + {{0, 7}, {452, 259}} + RubberWindowFrame + 743 379 452 308 0 0 1280 1002 + TableConfiguration + + Status + 30 + FileName + 199 + Path + 197.09500122070312 + + TableFrame + {{0, 0}, {452, 250}} + + Module + PBXCVSModule + Proportion + 262pt + + + Proportion + 266pt + + + Name + SCM + ServiceClasses + + PBXCVSModule + + StatusbarIsVisible + 1 + TableOfContents + + 1C78EAB4065D492600B07095 + 1C78EAB5065D492600B07095 + 1C78EAB2065D492600B07095 + 1CD052920623707200166675 + + ToolbarConfiguration + xcode.toolbar.config.scm + WindowString + 743 379 452 308 0 0 1280 1002 + + + FirstTimeWindowDisplayed + + Identifier + windowTool.breakpoints + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C77FABC04509CD000000102 + + PBXProjectModuleGUID + 1CE0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + no + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 168 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 1C77FABC04509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {168, 350}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + + + GeometryConfiguration + + Frame + {{0, 0}, {185, 368}} + GroupTreeTableConfiguration + + MainColumn + 168 + + RubberWindowFrame + 21 314 744 409 0 0 1024 746 + + Module + PBXSmartGroupTreeModule + Proportion + 185pt + + + BecomeActive + + ContentConfiguration + + PBXProjectModuleGUID + 1CA1AED706398EBD00589147 + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{190, 0}, {554, 368}} + RubberWindowFrame + 21 314 744 409 0 0 1024 746 + + Module + XCDetailModule + Proportion + 554pt + + + Proportion + 368pt + + + MajorVersion + 2 + MinorVersion + 0 + Name + Breakpoints + ServiceClasses + + PBXSmartGroupTreeModule + XCDetailModule + + StatusbarIsVisible + + TableOfContents + + CEDA9EAC09D2BBCE00741F3F + CEDA9EAD09D2BBCE00741F3F + 1CE0B1FE06471DED0097A5F4 + 1CA1AED706398EBD00589147 + + ToolbarConfiguration + xcode.toolbar.config.breakpoints + WindowString + 21 314 744 409 0 0 1024 746 + WindowToolGUID + CEDA9EAC09D2BBCE00741F3F + WindowToolIsVisible + + + + Identifier + windowTool.debugAnimator + Layout + + + Dock + + + Module + PBXNavigatorGroup + Proportion + 100% + + + Proportion + 100% + + + Name + Debug Visualizer + ServiceClasses + + PBXNavigatorGroup + + StatusbarIsVisible + 1 + ToolbarConfiguration + xcode.toolbar.config.debugAnimator + WindowString + 100 100 700 500 0 0 1280 1002 + + + Identifier + windowTool.bookmarks + Layout + + + Dock + + + Module + PBXBookmarksModule + Proportion + 100% + + + Proportion + 100% + + + Name + Bookmarks + ServiceClasses + + PBXBookmarksModule + + StatusbarIsVisible + 0 + WindowString + 538 42 401 187 0 0 1280 1002 + + + Identifier + windowTool.classBrowser + Layout + + + Dock + + + BecomeActive + 1 + ContentConfiguration + + OptionsSetName + Hierarchy, all classes + PBXProjectModuleGUID + 1CA6456E063B45B4001379D8 + PBXProjectModuleLabel + Class Browser - NSObject + + GeometryConfiguration + + ClassesFrame + {{0, 0}, {374, 96}} + ClassesTreeTableConfiguration + + PBXClassNameColumnIdentifier + 208 + PBXClassBookColumnIdentifier + 22 + + Frame + {{0, 0}, {630, 331}} + MembersFrame + {{0, 105}, {374, 395}} + MembersTreeTableConfiguration + + PBXMemberTypeIconColumnIdentifier + 22 + PBXMemberNameColumnIdentifier + 216 + PBXMemberTypeColumnIdentifier + 97 + PBXMemberBookColumnIdentifier + 22 + + PBXModuleWindowStatusBarHidden2 + 1 + RubberWindowFrame + 385 179 630 352 0 0 1440 878 + + Module + PBXClassBrowserModule + Proportion + 332pt + + + Proportion + 332pt + + + Name + Class Browser + ServiceClasses + + PBXClassBrowserModule + + StatusbarIsVisible + 0 + TableOfContents + + 1C0AD2AF069F1E9B00FABCE6 + 1C0AD2B0069F1E9B00FABCE6 + 1CA6456E063B45B4001379D8 + + ToolbarConfiguration + xcode.toolbar.config.classbrowser + WindowString + 385 179 630 352 0 0 1440 878 + WindowToolGUID + 1C0AD2AF069F1E9B00FABCE6 + WindowToolIsVisible + 0 + + + + diff --git a/se/cocoa/dupeguru.xcodeproj/project.pbxproj b/se/cocoa/dupeguru.xcodeproj/project.pbxproj new file mode 100644 index 00000000..3755a27e --- /dev/null +++ b/se/cocoa/dupeguru.xcodeproj/project.pbxproj @@ -0,0 +1,548 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 44; + objects = { + +/* Begin PBXBuildFile section */ + 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; }; + 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; + 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; + 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; + CE073F6309CAE1A3005C1D2F /* dupeguru_help in Resources */ = {isa = PBXBuildFile; fileRef = CE073F5409CAE1A3005C1D2F /* dupeguru_help */; }; + CE0D67640ABC2D3E00E2FFD9 /* dg.xsl in Resources */ = {isa = PBXBuildFile; fileRef = CE0D67620ABC2D3E00E2FFD9 /* dg.xsl */; }; + CE0D67650ABC2D3E00E2FFD9 /* hardcoded.css in Resources */ = {isa = PBXBuildFile; fileRef = CE0D67630ABC2D3E00E2FFD9 /* hardcoded.css */; }; + CE381C9609914ACE003581CE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CE381C9409914ACE003581CE /* AppDelegate.m */; }; + CE381C9C09914ADF003581CE /* ResultWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CE381C9A09914ADF003581CE /* ResultWindow.m */; }; + CE381D0509915304003581CE /* dg_cocoa.plugin in Resources */ = {isa = PBXBuildFile; fileRef = CE381CF509915304003581CE /* dg_cocoa.plugin */; }; + CE3AA46709DB207900DB3A21 /* Directories.nib in Resources */ = {isa = PBXBuildFile; fileRef = CE3AA46509DB207900DB3A21 /* Directories.nib */; }; + CE45579B0AE3BC2B005A9546 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE45579A0AE3BC2B005A9546 /* Sparkle.framework */; }; + CE4557B40AE3BC50005A9546 /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CE45579A0AE3BC2B005A9546 /* Sparkle.framework */; }; + CE68EE6809ABC48000971085 /* DirectoryPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = CE68EE6609ABC48000971085 /* DirectoryPanel.m */; }; + CE848A1909DD85810004CB44 /* Consts.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = CE848A1809DD85810004CB44 /* Consts.h */; }; + CECA899909DB12CA00A3D774 /* Details.nib in Resources */ = {isa = PBXBuildFile; fileRef = CECA899709DB12CA00A3D774 /* Details.nib */; }; + CECA899C09DB132E00A3D774 /* DetailsPanel.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = CECA899A09DB132E00A3D774 /* DetailsPanel.h */; }; + CECA899D09DB132E00A3D774 /* DetailsPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = CECA899B09DB132E00A3D774 /* DetailsPanel.m */; }; + CEEB135209C837A2004D2330 /* dupeguru.icns in Resources */ = {isa = PBXBuildFile; fileRef = CEEB135109C837A2004D2330 /* dupeguru.icns */; }; + CEF7823809C8AA0200EF38FF /* gear.png in Resources */ = {isa = PBXBuildFile; fileRef = CEF7823709C8AA0200EF38FF /* gear.png */; }; + CEFC294609C89E3D00D9F998 /* folder32.png in Resources */ = {isa = PBXBuildFile; fileRef = CEFC294509C89E3D00D9F998 /* folder32.png */; }; + CEFC295509C89FF200D9F998 /* details32.png in Resources */ = {isa = PBXBuildFile; fileRef = CEFC295309C89FF200D9F998 /* details32.png */; }; + CEFC295609C89FF200D9F998 /* preferences32.png in Resources */ = {isa = PBXBuildFile; fileRef = CEFC295409C89FF200D9F998 /* preferences32.png */; }; + CEFC295E09C8A0B000D9F998 /* dg_logo32.png in Resources */ = {isa = PBXBuildFile; fileRef = CEFC295D09C8A0B000D9F998 /* dg_logo32.png */; }; + CEFC7F9E0FC9517500CD5728 /* Dialogs.m in Sources */ = {isa = PBXBuildFile; fileRef = CEFC7F8B0FC9517500CD5728 /* Dialogs.m */; }; + CEFC7F9F0FC9517500CD5728 /* HSErrorReportWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CEFC7F8D0FC9517500CD5728 /* HSErrorReportWindow.m */; }; + CEFC7FA00FC9517500CD5728 /* Outline.m in Sources */ = {isa = PBXBuildFile; fileRef = CEFC7F8F0FC9517500CD5728 /* Outline.m */; }; + CEFC7FA10FC9517500CD5728 /* ProgressController.m in Sources */ = {isa = PBXBuildFile; fileRef = CEFC7F910FC9517500CD5728 /* ProgressController.m */; }; + CEFC7FA20FC9517500CD5728 /* RecentDirectories.m in Sources */ = {isa = PBXBuildFile; fileRef = CEFC7F950FC9517500CD5728 /* RecentDirectories.m */; }; + CEFC7FA30FC9517500CD5728 /* RegistrationInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = CEFC7F970FC9517500CD5728 /* RegistrationInterface.m */; }; + CEFC7FA40FC9517500CD5728 /* Table.m in Sources */ = {isa = PBXBuildFile; fileRef = CEFC7F990FC9517500CD5728 /* Table.m */; }; + CEFC7FA50FC9517500CD5728 /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = CEFC7F9B0FC9517500CD5728 /* Utils.m */; }; + CEFC7FA60FC9517500CD5728 /* ValueTransformers.m in Sources */ = {isa = PBXBuildFile; fileRef = CEFC7F9D0FC9517500CD5728 /* ValueTransformers.m */; }; + CEFC7FAD0FC9518A00CD5728 /* ErrorReportWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = CEFC7FA70FC9518A00CD5728 /* ErrorReportWindow.xib */; }; + CEFC7FAE0FC9518A00CD5728 /* progress.nib in Resources */ = {isa = PBXBuildFile; fileRef = CEFC7FA90FC9518A00CD5728 /* progress.nib */; }; + CEFC7FAF0FC9518A00CD5728 /* registration.nib in Resources */ = {isa = PBXBuildFile; fileRef = CEFC7FAB0FC9518A00CD5728 /* registration.nib */; }; + CEFC7FB90FC951A700CD5728 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CEFC7FB20FC951A700CD5728 /* AppDelegate.m */; }; + CEFC7FBA0FC951A700CD5728 /* DirectoryPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = CEFC7FB50FC951A700CD5728 /* DirectoryPanel.m */; }; + CEFC7FBB0FC951A700CD5728 /* ResultWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CEFC7FB80FC951A700CD5728 /* ResultWindow.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + CECC02B709A36E8200CC0A94 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + CE4557B40AE3BC50005A9546 /* Sparkle.framework in CopyFiles */, + CECA899C09DB132E00A3D774 /* DetailsPanel.h in CopyFiles */, + CE848A1909DD85810004CB44 /* Consts.h in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; + 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; + 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; + 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 29B97319FDCFA39411CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/MainMenu.nib; sourceTree = ""; }; + 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; + 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; + 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; }; + 8D1107320486CEB800E47090 /* dupeGuru.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = dupeGuru.app; sourceTree = BUILT_PRODUCTS_DIR; }; + CE073F5409CAE1A3005C1D2F /* dupeguru_help */ = {isa = PBXFileReference; lastKnownFileType = folder; name = dupeguru_help; path = help/dupeguru_help; sourceTree = ""; }; + CE0D67620ABC2D3E00E2FFD9 /* dg.xsl */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text.xml; name = dg.xsl; path = w3/dg.xsl; sourceTree = SOURCE_ROOT; }; + CE0D67630ABC2D3E00E2FFD9 /* hardcoded.css */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text; name = hardcoded.css; path = w3/hardcoded.css; sourceTree = SOURCE_ROOT; }; + CE381C9409914ACE003581CE /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = SOURCE_ROOT; }; + CE381C9509914ACE003581CE /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = SOURCE_ROOT; }; + CE381C9A09914ADF003581CE /* ResultWindow.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = ResultWindow.m; sourceTree = SOURCE_ROOT; }; + CE381C9B09914ADF003581CE /* ResultWindow.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = ResultWindow.h; sourceTree = SOURCE_ROOT; }; + CE381CF509915304003581CE /* dg_cocoa.plugin */ = {isa = PBXFileReference; lastKnownFileType = folder; name = dg_cocoa.plugin; path = py/dist/dg_cocoa.plugin; sourceTree = SOURCE_ROOT; }; + CE3AA46609DB207900DB3A21 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/Directories.nib; sourceTree = ""; }; + CE45579A0AE3BC2B005A9546 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = /Library/Frameworks/Sparkle.framework; sourceTree = ""; }; + CE68EE6509ABC48000971085 /* DirectoryPanel.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = DirectoryPanel.h; sourceTree = SOURCE_ROOT; }; + CE68EE6609ABC48000971085 /* DirectoryPanel.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = DirectoryPanel.m; sourceTree = SOURCE_ROOT; }; + CE848A1809DD85810004CB44 /* Consts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Consts.h; sourceTree = ""; }; + CECA899809DB12CA00A3D774 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/Details.nib; sourceTree = ""; }; + CECA899A09DB132E00A3D774 /* DetailsPanel.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = DetailsPanel.h; sourceTree = ""; }; + CECA899B09DB132E00A3D774 /* DetailsPanel.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = DetailsPanel.m; sourceTree = ""; }; + CEEB135109C837A2004D2330 /* dupeguru.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = dupeguru.icns; sourceTree = ""; }; + CEF7823709C8AA0200EF38FF /* gear.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = gear.png; path = images/gear.png; sourceTree = ""; }; + CEFC294509C89E3D00D9F998 /* folder32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = folder32.png; path = images/folder32.png; sourceTree = SOURCE_ROOT; }; + CEFC295309C89FF200D9F998 /* details32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = details32.png; path = images/details32.png; sourceTree = SOURCE_ROOT; }; + CEFC295409C89FF200D9F998 /* preferences32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = preferences32.png; path = images/preferences32.png; sourceTree = SOURCE_ROOT; }; + CEFC295D09C8A0B000D9F998 /* dg_logo32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = dg_logo32.png; path = images/dg_logo32.png; sourceTree = SOURCE_ROOT; }; + CEFC7F8A0FC9517500CD5728 /* Dialogs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Dialogs.h; path = cocoalib/Dialogs.h; sourceTree = SOURCE_ROOT; }; + CEFC7F8B0FC9517500CD5728 /* Dialogs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Dialogs.m; path = cocoalib/Dialogs.m; sourceTree = SOURCE_ROOT; }; + CEFC7F8C0FC9517500CD5728 /* HSErrorReportWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HSErrorReportWindow.h; path = cocoalib/HSErrorReportWindow.h; sourceTree = SOURCE_ROOT; }; + CEFC7F8D0FC9517500CD5728 /* HSErrorReportWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HSErrorReportWindow.m; path = cocoalib/HSErrorReportWindow.m; sourceTree = SOURCE_ROOT; }; + CEFC7F8E0FC9517500CD5728 /* Outline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Outline.h; path = cocoalib/Outline.h; sourceTree = SOURCE_ROOT; }; + CEFC7F8F0FC9517500CD5728 /* Outline.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Outline.m; path = cocoalib/Outline.m; sourceTree = SOURCE_ROOT; }; + CEFC7F900FC9517500CD5728 /* ProgressController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ProgressController.h; path = cocoalib/ProgressController.h; sourceTree = SOURCE_ROOT; }; + CEFC7F910FC9517500CD5728 /* ProgressController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ProgressController.m; path = cocoalib/ProgressController.m; sourceTree = SOURCE_ROOT; }; + CEFC7F920FC9517500CD5728 /* PyApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PyApp.h; path = cocoalib/PyApp.h; sourceTree = SOURCE_ROOT; }; + CEFC7F930FC9517500CD5728 /* PyRegistrable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PyRegistrable.h; path = cocoalib/PyRegistrable.h; sourceTree = SOURCE_ROOT; }; + CEFC7F940FC9517500CD5728 /* RecentDirectories.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RecentDirectories.h; path = cocoalib/RecentDirectories.h; sourceTree = SOURCE_ROOT; }; + CEFC7F950FC9517500CD5728 /* RecentDirectories.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RecentDirectories.m; path = cocoalib/RecentDirectories.m; sourceTree = SOURCE_ROOT; }; + CEFC7F960FC9517500CD5728 /* RegistrationInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegistrationInterface.h; path = cocoalib/RegistrationInterface.h; sourceTree = SOURCE_ROOT; }; + CEFC7F970FC9517500CD5728 /* RegistrationInterface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RegistrationInterface.m; path = cocoalib/RegistrationInterface.m; sourceTree = SOURCE_ROOT; }; + CEFC7F980FC9517500CD5728 /* Table.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Table.h; path = cocoalib/Table.h; sourceTree = SOURCE_ROOT; }; + CEFC7F990FC9517500CD5728 /* Table.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Table.m; path = cocoalib/Table.m; sourceTree = SOURCE_ROOT; }; + CEFC7F9A0FC9517500CD5728 /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Utils.h; path = cocoalib/Utils.h; sourceTree = SOURCE_ROOT; }; + CEFC7F9B0FC9517500CD5728 /* Utils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Utils.m; path = cocoalib/Utils.m; sourceTree = SOURCE_ROOT; }; + CEFC7F9C0FC9517500CD5728 /* ValueTransformers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueTransformers.h; path = cocoalib/ValueTransformers.h; sourceTree = SOURCE_ROOT; }; + CEFC7F9D0FC9517500CD5728 /* ValueTransformers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ValueTransformers.m; path = cocoalib/ValueTransformers.m; sourceTree = SOURCE_ROOT; }; + CEFC7FA80FC9518A00CD5728 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = cocoalib/English.lproj/ErrorReportWindow.xib; sourceTree = ""; }; + CEFC7FAA0FC9518A00CD5728 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = cocoalib/English.lproj/progress.nib; sourceTree = ""; }; + CEFC7FAC0FC9518A00CD5728 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = cocoalib/English.lproj/registration.nib; sourceTree = ""; }; + CEFC7FB10FC951A700CD5728 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = dgbase/AppDelegate.h; sourceTree = SOURCE_ROOT; }; + CEFC7FB20FC951A700CD5728 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = dgbase/AppDelegate.m; sourceTree = SOURCE_ROOT; }; + CEFC7FB30FC951A700CD5728 /* Consts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Consts.h; path = dgbase/Consts.h; sourceTree = SOURCE_ROOT; }; + CEFC7FB40FC951A700CD5728 /* DirectoryPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DirectoryPanel.h; path = dgbase/DirectoryPanel.h; sourceTree = SOURCE_ROOT; }; + CEFC7FB50FC951A700CD5728 /* DirectoryPanel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DirectoryPanel.m; path = dgbase/DirectoryPanel.m; sourceTree = SOURCE_ROOT; }; + CEFC7FB60FC951A700CD5728 /* PyDupeGuru.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PyDupeGuru.h; path = dgbase/PyDupeGuru.h; sourceTree = SOURCE_ROOT; }; + CEFC7FB70FC951A700CD5728 /* ResultWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ResultWindow.h; path = dgbase/ResultWindow.h; sourceTree = SOURCE_ROOT; }; + CEFC7FB80FC951A700CD5728 /* ResultWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ResultWindow.m; path = dgbase/ResultWindow.m; sourceTree = SOURCE_ROOT; }; + CEFF18A009A4D387005E6321 /* PyDupeGuru.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = PyDupeGuru.h; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8D11072E0486CEB800E47090 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, + CE45579B0AE3BC2B005A9546 /* Sparkle.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 080E96DDFE201D6D7F000001 /* DGSE */ = { + isa = PBXGroup; + children = ( + CE381C9509914ACE003581CE /* AppDelegate.h */, + CE381C9409914ACE003581CE /* AppDelegate.m */, + CE848A1809DD85810004CB44 /* Consts.h */, + CECA899A09DB132E00A3D774 /* DetailsPanel.h */, + CECA899B09DB132E00A3D774 /* DetailsPanel.m */, + CE68EE6509ABC48000971085 /* DirectoryPanel.h */, + CE68EE6609ABC48000971085 /* DirectoryPanel.m */, + CEFF18A009A4D387005E6321 /* PyDupeGuru.h */, + CE381C9B09914ADF003581CE /* ResultWindow.h */, + CE381C9A09914ADF003581CE /* ResultWindow.m */, + 29B97316FDCFA39411CA2CEA /* main.m */, + ); + name = DGSE; + sourceTree = ""; + }; + 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = { + isa = PBXGroup; + children = ( + CE45579A0AE3BC2B005A9546 /* Sparkle.framework */, + 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */, + ); + name = "Linked Frameworks"; + sourceTree = ""; + }; + 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 29B97324FDCFA39411CA2CEA /* AppKit.framework */, + 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */, + 29B97325FDCFA39411CA2CEA /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; + 19C28FACFE9D520D11CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 8D1107320486CEB800E47090 /* dupeGuru.app */, + ); + name = Products; + sourceTree = ""; + }; + 29B97314FDCFA39411CA2CEA /* dupeguru */ = { + isa = PBXGroup; + children = ( + 080E96DDFE201D6D7F000001 /* DGSE */, + CEFC7FB00FC9518F00CD5728 /* dgbase */, + CEFC7F890FC9513600CD5728 /* cocoalib */, + 29B97317FDCFA39411CA2CEA /* Resources */, + 29B97323FDCFA39411CA2CEA /* Frameworks */, + 19C28FACFE9D520D11CA2CBB /* Products */, + ); + name = dupeguru; + sourceTree = ""; + }; + 29B97317FDCFA39411CA2CEA /* Resources */ = { + isa = PBXGroup; + children = ( + CE073F5409CAE1A3005C1D2F /* dupeguru_help */, + CE381CF509915304003581CE /* dg_cocoa.plugin */, + CEFC294309C89E0000D9F998 /* images */, + CE0D67610ABC2D3E00E2FFD9 /* w3 */, + CEEB135109C837A2004D2330 /* dupeguru.icns */, + 8D1107310486CEB800E47090 /* Info.plist */, + 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */, + CECA899709DB12CA00A3D774 /* Details.nib */, + CE3AA46509DB207900DB3A21 /* Directories.nib */, + 29B97318FDCFA39411CA2CEA /* MainMenu.nib */, + ); + name = Resources; + sourceTree = ""; + }; + 29B97323FDCFA39411CA2CEA /* Frameworks */ = { + isa = PBXGroup; + children = ( + 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */, + 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */, + ); + name = Frameworks; + sourceTree = ""; + }; + CE0D67610ABC2D3E00E2FFD9 /* w3 */ = { + isa = PBXGroup; + children = ( + CE0D67620ABC2D3E00E2FFD9 /* dg.xsl */, + CE0D67630ABC2D3E00E2FFD9 /* hardcoded.css */, + ); + path = w3; + sourceTree = ""; + }; + CEFC294309C89E0000D9F998 /* images */ = { + isa = PBXGroup; + children = ( + CEF7823709C8AA0200EF38FF /* gear.png */, + CEFC295D09C8A0B000D9F998 /* dg_logo32.png */, + CEFC295309C89FF200D9F998 /* details32.png */, + CEFC295409C89FF200D9F998 /* preferences32.png */, + CEFC294509C89E3D00D9F998 /* folder32.png */, + ); + name = images; + sourceTree = ""; + }; + CEFC7F890FC9513600CD5728 /* cocoalib */ = { + isa = PBXGroup; + children = ( + CEFC7FA70FC9518A00CD5728 /* ErrorReportWindow.xib */, + CEFC7FA90FC9518A00CD5728 /* progress.nib */, + CEFC7FAB0FC9518A00CD5728 /* registration.nib */, + CEFC7F8A0FC9517500CD5728 /* Dialogs.h */, + CEFC7F8B0FC9517500CD5728 /* Dialogs.m */, + CEFC7F8C0FC9517500CD5728 /* HSErrorReportWindow.h */, + CEFC7F8D0FC9517500CD5728 /* HSErrorReportWindow.m */, + CEFC7F8E0FC9517500CD5728 /* Outline.h */, + CEFC7F8F0FC9517500CD5728 /* Outline.m */, + CEFC7F900FC9517500CD5728 /* ProgressController.h */, + CEFC7F910FC9517500CD5728 /* ProgressController.m */, + CEFC7F920FC9517500CD5728 /* PyApp.h */, + CEFC7F930FC9517500CD5728 /* PyRegistrable.h */, + CEFC7F940FC9517500CD5728 /* RecentDirectories.h */, + CEFC7F950FC9517500CD5728 /* RecentDirectories.m */, + CEFC7F960FC9517500CD5728 /* RegistrationInterface.h */, + CEFC7F970FC9517500CD5728 /* RegistrationInterface.m */, + CEFC7F980FC9517500CD5728 /* Table.h */, + CEFC7F990FC9517500CD5728 /* Table.m */, + CEFC7F9A0FC9517500CD5728 /* Utils.h */, + CEFC7F9B0FC9517500CD5728 /* Utils.m */, + CEFC7F9C0FC9517500CD5728 /* ValueTransformers.h */, + CEFC7F9D0FC9517500CD5728 /* ValueTransformers.m */, + ); + name = cocoalib; + sourceTree = ""; + }; + CEFC7FB00FC9518F00CD5728 /* dgbase */ = { + isa = PBXGroup; + children = ( + CEFC7FB10FC951A700CD5728 /* AppDelegate.h */, + CEFC7FB20FC951A700CD5728 /* AppDelegate.m */, + CEFC7FB30FC951A700CD5728 /* Consts.h */, + CEFC7FB40FC951A700CD5728 /* DirectoryPanel.h */, + CEFC7FB50FC951A700CD5728 /* DirectoryPanel.m */, + CEFC7FB60FC951A700CD5728 /* PyDupeGuru.h */, + CEFC7FB70FC951A700CD5728 /* ResultWindow.h */, + CEFC7FB80FC951A700CD5728 /* ResultWindow.m */, + ); + name = dgbase; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8D1107260486CEB800E47090 /* dupeguru */ = { + isa = PBXNativeTarget; + buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "dupeguru" */; + buildPhases = ( + 8D1107290486CEB800E47090 /* Resources */, + 8D11072C0486CEB800E47090 /* Sources */, + 8D11072E0486CEB800E47090 /* Frameworks */, + CECC02B709A36E8200CC0A94 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = dupeguru; + productInstallPath = "$(HOME)/Applications"; + productName = dupeguru; + productReference = 8D1107320486CEB800E47090 /* dupeGuru.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 29B97313FDCFA39411CA2CEA /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = NO; + }; + buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "dupeguru" */; + compatibilityVersion = "Xcode 3.0"; + hasScannedForEncodings = 1; + mainGroup = 29B97314FDCFA39411CA2CEA /* dupeguru */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8D1107260486CEB800E47090 /* dupeguru */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8D1107290486CEB800E47090 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */, + 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */, + CE381D0509915304003581CE /* dg_cocoa.plugin in Resources */, + CE073F6309CAE1A3005C1D2F /* dupeguru_help in Resources */, + CEEB135209C837A2004D2330 /* dupeguru.icns in Resources */, + CEFC294609C89E3D00D9F998 /* folder32.png in Resources */, + CEFC295509C89FF200D9F998 /* details32.png in Resources */, + CEFC295609C89FF200D9F998 /* preferences32.png in Resources */, + CEFC295E09C8A0B000D9F998 /* dg_logo32.png in Resources */, + CEF7823809C8AA0200EF38FF /* gear.png in Resources */, + CECA899909DB12CA00A3D774 /* Details.nib in Resources */, + CE3AA46709DB207900DB3A21 /* Directories.nib in Resources */, + CE0D67640ABC2D3E00E2FFD9 /* dg.xsl in Resources */, + CE0D67650ABC2D3E00E2FFD9 /* hardcoded.css in Resources */, + CEFC7FAD0FC9518A00CD5728 /* ErrorReportWindow.xib in Resources */, + CEFC7FAE0FC9518A00CD5728 /* progress.nib in Resources */, + CEFC7FAF0FC9518A00CD5728 /* registration.nib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8D11072C0486CEB800E47090 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D11072D0486CEB800E47090 /* main.m in Sources */, + CE381C9609914ACE003581CE /* AppDelegate.m in Sources */, + CE381C9C09914ADF003581CE /* ResultWindow.m in Sources */, + CE68EE6809ABC48000971085 /* DirectoryPanel.m in Sources */, + CECA899D09DB132E00A3D774 /* DetailsPanel.m in Sources */, + CEFC7F9E0FC9517500CD5728 /* Dialogs.m in Sources */, + CEFC7F9F0FC9517500CD5728 /* HSErrorReportWindow.m in Sources */, + CEFC7FA00FC9517500CD5728 /* Outline.m in Sources */, + CEFC7FA10FC9517500CD5728 /* ProgressController.m in Sources */, + CEFC7FA20FC9517500CD5728 /* RecentDirectories.m in Sources */, + CEFC7FA30FC9517500CD5728 /* RegistrationInterface.m in Sources */, + CEFC7FA40FC9517500CD5728 /* Table.m in Sources */, + CEFC7FA50FC9517500CD5728 /* Utils.m in Sources */, + CEFC7FA60FC9517500CD5728 /* ValueTransformers.m in Sources */, + CEFC7FB90FC951A700CD5728 /* AppDelegate.m in Sources */, + CEFC7FBA0FC951A700CD5728 /* DirectoryPanel.m in Sources */, + CEFC7FBB0FC951A700CD5728 /* ResultWindow.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 089C165DFE840E0CC02AAC07 /* English */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + 29B97318FDCFA39411CA2CEA /* MainMenu.nib */ = { + isa = PBXVariantGroup; + children = ( + 29B97319FDCFA39411CA2CEA /* English */, + ); + name = MainMenu.nib; + sourceTree = SOURCE_ROOT; + }; + CE3AA46509DB207900DB3A21 /* Directories.nib */ = { + isa = PBXVariantGroup; + children = ( + CE3AA46609DB207900DB3A21 /* English */, + ); + name = Directories.nib; + sourceTree = ""; + }; + CECA899709DB12CA00A3D774 /* Details.nib */ = { + isa = PBXVariantGroup; + children = ( + CECA899809DB12CA00A3D774 /* English */, + ); + name = Details.nib; + sourceTree = ""; + }; + CEFC7FA70FC9518A00CD5728 /* ErrorReportWindow.xib */ = { + isa = PBXVariantGroup; + children = ( + CEFC7FA80FC9518A00CD5728 /* English */, + ); + name = ErrorReportWindow.xib; + sourceTree = SOURCE_ROOT; + }; + CEFC7FA90FC9518A00CD5728 /* progress.nib */ = { + isa = PBXVariantGroup; + children = ( + CEFC7FAA0FC9518A00CD5728 /* English */, + ); + name = progress.nib; + sourceTree = SOURCE_ROOT; + }; + CEFC7FAB0FC9518A00CD5728 /* registration.nib */ = { + isa = PBXVariantGroup; + children = ( + CEFC7FAC0FC9518A00CD5728 /* English */, + ); + name = registration.nib; + sourceTree = SOURCE_ROOT; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + C01FCF4B08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(FRAMEWORK_SEARCH_PATHS)", + "$(SRCROOT)/../../../cocoalib/build/Release", + "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", + ); + FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)/../../base/cocoa/build/Release\""; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Applications"; + PRODUCT_NAME = dupeGuru; + WRAPPER_EXTENSION = app; + ZERO_LINK = YES; + }; + name = Debug; + }; + C01FCF4C08A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + ppc, + i386, + ); + FRAMEWORK_SEARCH_PATHS = ( + "$(FRAMEWORK_SEARCH_PATHS)", + "$(SRCROOT)/../../../cocoalib/build/Release", + "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", + ); + FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)/../../base/cocoa/build/Release\""; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_MODEL_TUNING = G5; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Applications"; + PRODUCT_NAME = dupeGuru; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; + C01FCF4F08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_C_LANGUAGE_STANDARD = c99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.4; + PREBINDING = NO; + SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; + }; + name = Debug; + }; + C01FCF5008A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + ppc, + i386, + ); + FRAMEWORK_SEARCH_PATHS = "@executable_path/../Frameworks"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.4; + PREBINDING = NO; + SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "dupeguru" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4B08A954540054247B /* Debug */, + C01FCF4C08A954540054247B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C01FCF4E08A954540054247B /* Build configuration list for PBXProject "dupeguru" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4F08A954540054247B /* Debug */, + C01FCF5008A954540054247B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; +} diff --git a/se/cocoa/gen.py b/se/cocoa/gen.py new file mode 100644 index 00000000..4101b2a0 --- /dev/null +++ b/se/cocoa/gen.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +import os + +print "Generating help" +os.chdir('help') +os.system('python -u gen.py') +os.system('/Developer/Applications/Utilities/Help\\ Indexer.app/Contents/MacOS/Help\\ Indexer dupeguru_help') +os.chdir('..') + +print "Generating py plugin" +os.chdir('py') +os.system('python -u gen.py') +os.chdir('..') \ No newline at end of file diff --git a/se/cocoa/main.m b/se/cocoa/main.m new file mode 100644 index 00000000..c5f30658 --- /dev/null +++ b/se/cocoa/main.m @@ -0,0 +1,21 @@ +// +// main.m +// dupeguru +// +// Created by Virgil Dupras on 2006/02/01. +// Copyright __MyCompanyName__ 2006. All rights reserved. +// + +#import + +int main(int argc, char *argv[]) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSString *pluginPath = [[NSBundle mainBundle] + pathForResource:@"dg_cocoa" + ofType:@"plugin"]; + NSBundle *pluginBundle = [NSBundle bundleWithPath:pluginPath]; + [pluginBundle load]; + [pool release]; + return NSApplicationMain(argc, (const char **) argv); +} diff --git a/se/cocoa/py/dg_cocoa.py b/se/cocoa/py/dg_cocoa.py new file mode 100644 index 00000000..63a4df2c --- /dev/null +++ b/se/cocoa/py/dg_cocoa.py @@ -0,0 +1,208 @@ +#!/usr/bin/env python +import objc +from AppKit import * + +from dupeguru import app_se_cocoa, scanner + +# Fix py2app imports with chokes on relative imports +from dupeguru import app, app_cocoa, data, directories, engine, export, ignore, results, scanner +from hsfs import auto, manual, stats, tree, utils +from hsfs.phys import bundle + +class PyApp(NSObject): + pass #fake class + +class PyDupeGuru(PyApp): + def init(self): + self = super(PyDupeGuru,self).init() + self.app = app_se_cocoa.DupeGuru() + return self + + #---Directories + def addDirectory_(self,directory): + return self.app.AddDirectory(directory) + + def removeDirectory_(self,index): + self.app.RemoveDirectory(index) + + def setDirectory_state_(self,node_path,state): + self.app.SetDirectoryState(node_path,state) + + #---Results + def clearIgnoreList(self): + self.app.scanner.ignore_list.Clear() + + def doScan(self): + return self.app.start_scanning() + + def exportToXHTMLwithColumns_xslt_css_(self,column_ids,xslt_path,css_path): + return self.app.ExportToXHTML(column_ids,xslt_path,css_path) + + def loadIgnoreList(self): + self.app.LoadIgnoreList() + + def loadResults(self): + self.app.load() + + def markAll(self): + self.app.results.mark_all() + + def markNone(self): + self.app.results.mark_none() + + def markInvert(self): + self.app.results.mark_invert() + + def purgeIgnoreList(self): + self.app.PurgeIgnoreList() + + def toggleSelectedMark(self): + self.app.ToggleSelectedMarkState() + + def saveIgnoreList(self): + self.app.SaveIgnoreList() + + def saveResults(self): + self.app.Save() + + def refreshDetailsWithSelected(self): + self.app.RefreshDetailsWithSelected() + + def selectResultNodePaths_(self,node_paths): + self.app.SelectResultNodePaths(node_paths) + + def selectPowerMarkerNodePaths_(self,node_paths): + self.app.SelectPowerMarkerNodePaths(node_paths) + + #---Actions + def addSelectedToIgnoreList(self): + self.app.AddSelectedToIgnoreList() + + def deleteMarked(self): + self.app.delete_marked() + + def applyFilter_(self, filter): + self.app.ApplyFilter(filter) + + def makeSelectedReference(self): + self.app.MakeSelectedReference() + + def copyOrMove_markedTo_recreatePath_(self,copy,destination,recreate_path): + self.app.copy_or_move_marked(copy, destination, recreate_path) + + def openSelected(self): + self.app.OpenSelected() + + def removeMarked(self): + self.app.results.perform_on_marked(lambda x:True, True) + + def removeSelected(self): + self.app.RemoveSelected() + + def renameSelected_(self,newname): + return self.app.RenameSelected(newname) + + def revealSelected(self): + self.app.RevealSelected() + + #---Misc + def sortDupesBy_ascending_(self,key,asc): + self.app.sort_dupes(key,asc) + + def sortGroupsBy_ascending_(self,key,asc): + self.app.sort_groups(key,asc) + + #---Information + def getIgnoreListCount(self): + return len(self.app.scanner.ignore_list) + + def getMarkCount(self): + return self.app.results.mark_count + + def getStatLine(self): + return self.app.stat_line + + def getOperationalErrorCount(self): + return self.app.last_op_error_count + + #---Data + @objc.signature('i@:i') + def getOutlineViewMaxLevel_(self, tag): + return self.app.GetOutlineViewMaxLevel(tag) + + @objc.signature('@@:i@') + def getOutlineView_childCountsForPath_(self, tag, node_path): + return self.app.GetOutlineViewChildCounts(tag, node_path) + + def getOutlineView_valuesForIndexes_(self,tag,node_path): + return self.app.GetOutlineViewValues(tag,node_path) + + def getOutlineView_markedAtIndexes_(self,tag,node_path): + return self.app.GetOutlineViewMarked(tag,node_path) + + def getTableViewCount_(self,tag): + return self.app.GetTableViewCount(tag) + + def getTableViewMarkedIndexes_(self,tag): + return self.app.GetTableViewMarkedIndexes(tag) + + def getTableView_valuesForRow_(self,tag,row): + return self.app.GetTableViewValues(tag,row) + + #---Properties + def setMinMatchPercentage_(self,percentage): + self.app.scanner.min_match_percentage = int(percentage) + + def setScanType_(self,scan_type): + try: + self.app.scanner.scan_type = [ + scanner.SCAN_TYPE_FILENAME, + scanner.SCAN_TYPE_CONTENT + ][scan_type] + except IndexError: + pass + + def setWordWeighting_(self,words_are_weighted): + self.app.scanner.word_weighting = words_are_weighted + + def setMixFileKind_(self,mix_file_kind): + self.app.scanner.mix_file_kind = mix_file_kind + + def setDisplayDeltaValues_(self,display_delta_values): + self.app.display_delta_values= display_delta_values + + def setMatchSimilarWords_(self,match_similar_words): + self.app.scanner.match_similar_words = match_similar_words + + def setEscapeFilterRegexp_(self, escape_filter_regexp): + self.app.options['escape_filter_regexp'] = escape_filter_regexp + + def setRemoveEmptyFolders_(self, remove_empty_folders): + self.app.options['clean_empty_dirs'] = remove_empty_folders + + @objc.signature('v@:i') + def setSizeThreshold_(self, size_threshold): + self.app.scanner.size_threshold = size_threshold + + #---Worker + def getJobProgress(self): + return self.app.progress.last_progress + + def getJobDesc(self): + return self.app.progress.last_desc + + def cancelJob(self): + self.app.progress.job_cancelled = True + + #---Registration + @objc.signature('i@:') + def isRegistered(self): + return self.app.registered + + @objc.signature('i@:@@') + def isCodeValid_withEmail_(self, code, email): + return self.app.is_code_valid(code, email) + + def setRegisteredCode_andEmail_(self, code, email): + self.app.set_registration(code, email) + diff --git a/se/cocoa/py/gen.py b/se/cocoa/py/gen.py new file mode 100644 index 00000000..2279eb36 --- /dev/null +++ b/se/cocoa/py/gen.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +import os +import os.path as op +import shutil + +print "Cleaning build and dist" +if op.exists('build'): + shutil.rmtree('build') +if op.exists('dist'): + shutil.rmtree('dist') + +print "Buiding the py2app plugin" + +os.system('python -u setup.py py2app') \ No newline at end of file diff --git a/se/cocoa/py/setup.py b/se/cocoa/py/setup.py new file mode 100644 index 00000000..6d37e3c5 --- /dev/null +++ b/se/cocoa/py/setup.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +from distutils.core import setup +import py2app + +from hsutil.build import move_testdata_out, put_testdata_back + +move_log = move_testdata_out() +try: + setup( + plugin = ['dg_cocoa.py'], + ) +finally: + put_testdata_back(move_log) \ No newline at end of file diff --git a/se/cocoa/w3/dg.xsl b/se/cocoa/w3/dg.xsl new file mode 100644 index 00000000..4f982fce --- /dev/null +++ b/se/cocoa/w3/dg.xsl @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + indented + + + + + + + + + + + + + + + + + + + + + + + + + + + + dupeGuru Results + + + +

dupeGuru Results

+ + + + + +
+ + +
+ +
\ No newline at end of file diff --git a/se/cocoa/w3/hardcoded.css b/se/cocoa/w3/hardcoded.css new file mode 100644 index 00000000..ed243bcc --- /dev/null +++ b/se/cocoa/w3/hardcoded.css @@ -0,0 +1,71 @@ +BODY +{ + background-color:white; +} + +BODY,A,P,UL,TABLE,TR,TD +{ + font-family:Tahoma,Arial,sans-serif; + font-size:10pt; + color: #4477AA; +} + +TABLE +{ + background-color: #225588; + margin-left: auto; + margin-right: auto; + width: 90%; +} + +TR +{ + background-color: white; +} + +TH +{ + font-weight: bold; + color: black; + background-color: #C8D6E5; +} + +TH TD +{ + color:black; +} + +TD +{ + padding-left: 2pt; +} + +TD.rightelem +{ + text-align:right; + /*padding-left:0pt;*/ + padding-right: 2pt; + width: 17%; +} + +TD.indented +{ + padding-left: 12pt; +} + +H1 +{ + font-family:"Courier New",monospace; + color:#6699CC; + font-size:18pt; + color:#6da500; + border-color: #70A0CF; + border-width: 1pt; + border-style: solid; + margin-top: 16pt; + margin-left: 5%; + margin-right: 5%; + padding-top: 2pt; + padding-bottom:2pt; + text-align: center; +} \ No newline at end of file diff --git a/se/help/changelog.yaml b/se/help/changelog.yaml new file mode 100644 index 00000000..8bb0a392 --- /dev/null +++ b/se/help/changelog.yaml @@ -0,0 +1,230 @@ +- date: 2009-05-29 + version: 2.7.1 + description: | + * Fixed a bug causing crashes when having application files in the results. + * Fixed a bug causing a GUI freeze at the beginning of a scan with a lot of files. + * Fixed a bug that sometimes caused a crash when an action was cancelled, and then started again. +- date: 2009-05-25 + version: 2.7.0 + description: | + * Converted the Windows GUI to Qt. + * Improved the reliability of the scanning process. +- date: 2009-03-27 + version: 2.6.1 + description: | + * **Fixed** an occasional crash caused by permission issues. + * **Fixed** a bug where the "X discarded" notice would show a too large number of discarded + duplicates. +- date: 2008-09-10 + description: "* **Added** a small file threshold preference.\r\n* **Added** a notice\ + \ in the status bar when matches were discarded during the scan.\r\n* **Improved**\ + \ duplicate prioritization (smartly chooses which file you will keep).\r\n* **Improved**\ + \ scan progress feedback.\r\n* **Improved** responsiveness of the user interface\ + \ for certain actions." + version: 2.6.0 +- date: 2008-08-10 + description: "
    \n\t\t\t\t\t\t
  • Improved the speed of results loading\ + \ and saving.
  • \n\t\t\t\t\t\t
  • Fixed a crash sometimes occurring during\ + \ duplicate deletion.
  • \n\t\t
" + version: 2.5.4 +- date: 2008-07-08 + description: "
    \n\t\t\t\t\t\t
  • Improved unicode handling for filenames.\ + \ dupeGuru will now find a lot more duplicates if your files have non-ascii characters\ + \ in it.
  • \n\t\t\t\t\t\t
  • Fixed \"Clear Ignore List\" crash in Windows.
  • \n\ + \t\t
" + version: 2.5.3 +- date: 2008-01-10 + description: "
    \n\t\t\t\t\t\t
  • Improved the handling of low memory situations.
  • \n\ + \t\t\t\t\t\t
  • Improved the directory panel. The \"Remove\" button changes\ + \ to \"Put Back\" when an excluded directory is selected.
  • \n\t\t\t\t\t\t
  • Improved\ + \ scan, delete and move speed in situations where there were a lot of duplicates.
  • \n\ + \t\t\t\t\t\t
  • Fixed occasional crashes when moving bundles (such as .app\ + \ files).
  • \n\t\t\t\t\t\t
  • Fixed occasional crashes when moving a\ + \ lot of files at once.
  • \n\t\t
" + version: 2.5.2 +- date: 2007-11-22 + description: "
    \n\t\t\t\t\t\t
  • Added the \"Remove empty folders\" option.
  • \n\ + \t\t\t\t\t\t
  • Fixed results load/save issues.
  • \n\t\t\t\t\t\t
  • Fixed\ + \ occasional status bar inaccuracies when the results are filtered.
  • \n\t\t\ + \
" + version: 2.5.1 +- date: 2007-09-15 + description: "
    \n\t\t\t\t\t\t
  • Added post scan filtering.
  • \n\t\t\ + \t\t\t\t
  • Fixed issues with the rename feature under Windows
  • \n\t\ + \t\t\t\t\t
  • Fixed some user interface annoyances under Windows
  • \n\ + \t\t
" + version: 2.5.0 +- date: 2007-04-14 + description: "
    \n\t\t\t\t\t\t
  • Improved UI responsiveness (using threads)\ + \ under Mac OS X.
  • \n\t\t\t\t\t\t
  • Improved result load/save speed\ + \ and memory usage.
  • \n\t\t
" + version: 2.4.8 +- date: 2007-03-10 + description: "
    \n\t\t\t\t\t\t
  • Fixed a \"bad file descriptor\" error\ + \ occasionally popping up.
  • \n\t\t\t\t\t\t
  • Fixed a bug with non-latin\ + \ directory names.
  • \n\t\t
" + version: 2.4.7 +- date: 2007-02-10 + description: "
    \n\t\t\t\t\t\t
  • Added Re-orderable columns. In fact,\ + \ I re-added the feature which was lost in the C# conversion in 2.4.0 (Windows).
  • \n\ + \t\t\t\t\t\t
  • Changed the behavior of the scanning engine when setting\ + \ the hardness to 100. It will now only match files that have their words in the\ + \ same order.
  • \n\t\t\t\t\t\t
  • Fixed a bug with all the Delete/Move/Copy\ + \ actions with certain kinds of files.
  • \n\t\t
" + version: 2.4.6 +- date: 2007-01-11 + description: "
    \n\t\t\t\t\t\t
  • Fixed a bug with the Move action.
  • \n\ + \t\t
" + version: 2.4.5 +- date: 2007-01-07 + description: "
    \n\t\t\t\t\t\t
  • Fixed a \"ghosting\" bug. Dupes deleted\ + \ by dupeGuru would sometimes come back in subsequent scans (Windows).
  • \n\t\ + \t\t\t\t\t
  • Fixed bugs sometimes making dupeGuru crash when marking a\ + \ dupe (Windows).
  • \n\t\t\t\t\t\t
  • Fixed some minor visual glitches\ + \ (Windows).
  • \n\t\t
" + version: 2.4.4 +- date: 2006-12-08 + description: "
    \n\t\t\t\t\t\t
  • Fixed a mishandling of \".app\" files\ + \ (OS X).
  • \n\t\t\t\t\t\t
  • Fixed a bug preventing files from \"reference\"\ + \ directories to be displayed in blue in the results (Windows).
  • \n\t\t\t\t\ + \t\t
  • Fixed a bug preventing some files to be sent to the recycle bin\ + \ (Windows).
  • \n\t\t\t\t\t\t
  • Fixed a bug in the packaging preventing\ + \ certain Windows configurations to start dupeGuru at all.
  • \n\t\t \ + \
" + version: 2.4.3 +- date: 2006-11-18 + description: "
    \n\t\t\t\t\t\t
  • Fixed a bug with directory states.
  • \n\ + \t\t
" + version: 2.4.2 +- date: 2006-11-15 + description: "
    \n\t\t\t\t\t\t
  • Fixed a bug causing the ignore list not\ + \ to be saved.
  • \n\t\t\t\t\t\t
  • Fixed a bug sometimes making delete\ + \ and move operations stall.
  • \n\t\t
" + version: 2.4.1 +- date: 2006-11-10 + description: "
    \n\t\t\t\t\t\t
  • Changed the Windows interface. It is\ + \ now .NET based.
  • \n\t\t\t\t\t\t
  • Added an auto-update feature to\ + \ the windows version.
  • \n\t\t\t\t\t\t
  • Changed the way power marking\ + \ works. It is now a mode instead of a separate window.
  • \n\t\t\t\t\t\t
  • Changed\ + \ the \"Size (MB)\" column for a \"Size (KB)\" column. The values are now \"ceiled\"\ + \ instead of rounded. Therefore, a size \"0\" is now really 0 bytes, not just\ + \ a value too small to be rounded up. It is also the case for delta values.
  • \n\ + \t\t\t\t\t\t
  • Removed the min word length/count options. These came from\ + \ Mp3 Filter, and just aren't used anymore. Word weighting does pretty much the\ + \ same job.
  • \n\t\t
" + version: 2.4.0 +- date: 2006-11-07 + description: "
    \n\t\t\t\t\t\t
  • Improved speed and memory usage of the\ + \ scanning engine, again. Does it mean there was a lot of improvements to be made?\ + \ Nah...
  • \n\t\t
" + version: 2.3.4 +- date: 2006-11-02 + description: "
    \n\t\t\t\t\t\t
  • Improved speed and memory usage of the\ + \ scanning engine, especially when the scan results in a lot of duplicates.
  • \n\ + \t\t\t\t\t\t
  • Now I wonder if Sparkle is going to work well...
  • \n\t\t \ + \
" + version: 2.3.3 +- date: 2006-10-16 + description: "
    \n\t\t\t\t\t\t
  • Added an auto-update feature in the Mac\ + \ OS X version (with Sparkle).
  • \n\t\t\t\t\t\t
  • Fixed a bug preventing\ + \ some duplicate reports to be created correctly under Windows.
  • \n\t\t \ + \
" + version: 2.3.2 +- date: 2006-10-02 + description: "
    \n\t\t\t\t\t\t
  • Fixed a bug preventing some duplicates\ + \ to be found, especially when scanning lots of files.
  • \n\t\t
" + version: 2.3.1 +- date: 2006-09-22 + description: "
    \n\t\t\t\t\t\t
  • Added XHTML export feature.
  • \n\t\t\ + \
" + version: 2.3.0 +- date: 2006-08-31 + description: "
    \n\t\t\t\t\t\t
  • Added sticky columns.
  • \n\t\t\t\t\t\ + \t
  • Fixed an issue with file caching between scans.
  • \n\t\t\t\t\t\t\ +
  • Fixed an issue preventing some duplicates from being deleted/moved/copied.
  • \n\ + \t\t
" + version: 2.2.10 +- date: 2006-08-27 + description: "
    \n\t\t\t\t\t\t
  • Fixed an issue with ignore list and unicode.
  • \n\ + \t\t\t\t\t\t
  • Fixed an issue with file attribute fetching sometimes causing\ + \ dupeGuru to crash.
  • \n\t\t\t\t\t\t
  • Fixed an issue in the directories\ + \ panel under Windows.
  • \n\t\t
" + version: 2.2.9 +- date: 2006-08-17 + description: "
    \n\t\t\t\t\t\t
  • Fixed an issue in the duplicate seeking\ + \ engine preventing some duplicates to be found.
  • \n\t\t
" + version: 2.2.8 +- date: 2006-08-12 + description: "
    \n\t\t\t\t\t\t
  • Improved unicode support.
  • \n\t\t\t\ + \t\t\t
  • Improved the \"Reveal in Finder\" (\"Open Containing Folder\"\ + \ in Windows) feature so it selects the file in the folder it opens.
  • \n\t\t\ + \
" + version: 2.2.7 +- date: 2006-08-07 + description: "
    \n\t\t\t\t\t\t
  • Improved the ignore list system.
  • \n\ + \t\t\t\t\t\t
  • dupeGuru is now a Universal application on Mac OS X.
  • \n\t\t\ + \
" + version: 2.2.6 +- date: 2006-07-26 + description: "
    \n\t\t\t\t\t\t
  • Improved application (.app) dupe detection\ + \ on Mac OS X.
  • \n\t\t\t\t\t\t
  • Fixed an issue that occasionally made\ + \ dupeGuru crash on startup.
  • \n\t\t
" + version: 2.2.5 +- date: 2006-06-27 + description: "
    \n\t\t\t\t\t\t
  • Fixed an issue with Move and Copy features.
  • \n\ + \t\t
" + version: 2.2.4 +- date: 2006-06-15 + description: "
    \n\t\t\t\t\t\t
  • Improved duplicate scanning speed.
  • \n\ + \t\t\t\t\t\t
  • Added a warning that a file couldn't be renamed if a file\ + \ with the same name already exists.
  • \n\t\t
" + version: 2.2.3 +- date: 2006-06-07 + description: "
    \n\t\t\t\t\t\t
  • Added \"Rename Selected\" feature.
  • \n\ + \t\t\t\t\t\t
  • Fixed some minor issues with \"Reload Last Results\" feature.
  • \n\ + \t\t\t\t\t\t
  • Fixed ignore list issues.
  • \n\t\t
" + version: 2.2.2 +- date: 2006-05-22 + description: "
    \n\t\t \t
  • Fixed occasional progress bar woes\ + \ under Windows.
  • \n\t\t\t\t\t\t
  • Fixed a bug in the registration\ + \ system under Windows.
  • \n\t\t\t\t\t\t
  • Nothing has been changed in the\ + \ Mac OS X version, but I want to keep version in sync.
  • \n\t\t \ + \
" + version: 2.2.1 +- date: 2006-05-10 + description: "
    \n\t\t \t
  • Added destination path re-creation\ + \ options.
  • \n\t\t\t\t\t\t
  • Added an ignore list.
  • \n\t\t\t\t\t\ + \t
  • Changed the main icon.
  • \n\t\t\t\t\t\t
  • Improved dramatically\ + \ the delta values feature.
  • \n\t\t
" + version: 2.2.0 +- date: 2006-04-18 + description: "
    \n\t\t \t
  • Added the \"Match similar words\"\ + \ option.
  • \n\t\t\t\t\t\t
  • Fixed Power marking issues under Mac.
  • \n\ + \t\t
" + version: 2.1.2 +- date: 2006-04-14 + description: "
    \n\t\t \t
  • Added the \"Display delta values\"\ + \ option.
  • \n\t\t\t\t\t\t
  • Improved Power marking sorting speed under\ + \ Mac.
  • \n\t\t\t\t\t\t
  • Fixed Power marking sorting issues.
  • \n\ + \t\t
" + version: 2.1.1 +- date: 2006-04-03 + description: "
    \n\t\t \t
  • Added the Power Marker feature.
  • \n\ + \t\t\t\t\t\t
  • Fixed a column sorting bug. The results would sometimes\ + \ lose their sort order.
  • \n\t\t\t\t\t\t
  • Fixed a bug with the Make\ + \ Reference feature. The results sometimes wasn't correctly refreshed after the\ + \ reference switch.
  • \n\t\t
" + version: 2.1.0 +- date: 2006-03-23 + description: "
    \n\t\t \t
  • Fixed an issue occasionally occurring\ + \ when trying to reload results from removable media that is no longer present.
  • \n\ + \t\t
" + version: 2.0.1 +- date: 2006-03-17 + description: "
    \n\t\t \t
  • Complete rewrite.
  • \n\t\t \ + \ \t
  • Now runs on Mac OS X.
  • \n\t\t
" + version: 2.0.0 +- date: 2004-09-24 + description: "
    \n\t\t \t
  • Initial release.
  • \n\t\t \ + \
" + version: 1.0.0 diff --git a/se/help/gen.py b/se/help/gen.py new file mode 100644 index 00000000..3f067c83 --- /dev/null +++ b/se/help/gen.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python +# Unit Name: +# Created By: Virgil Dupras +# Created On: 2009-05-24 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import os + +from web import generate_help + +generate_help.main('.', 'dupeguru_help', force_render=True) diff --git a/se/help/skeleton/hardcoded.css b/se/help/skeleton/hardcoded.css new file mode 100644 index 00000000..a3b17c5b --- /dev/null +++ b/se/help/skeleton/hardcoded.css @@ -0,0 +1,409 @@ +/***************************************************** + General settings +*****************************************************/ + +BODY +{ + background-color:white; +} + +BODY,A,P,UL,TABLE,TR,TD +{ + font-family:Tahoma,Arial,sans-serif; + font-size:10pt; + color: #4477AA;/*darker than 5588bb for the sake of the eyes*/ +} + +/***************************************************** + "A" settings +*****************************************************/ + +A +{ + color: #ae322b; + text-decoration:underline; + font-weight:bold; +} + +A.glossaryword {color:#A0A0A0;} + +A.noline +{ + text-decoration: none; +} + + +/***************************************************** + Menu and mainframe settings +*****************************************************/ + +.maincontainer +{ + display:block; + margin-left:7%; + margin-right:7%; + padding-left:5px; + padding-right:0px; + border-color:#CCCCCC; + border-style:solid; + border-width:2px; + border-right-width:0px; + border-bottom-width:0px; + border-top-color:#ae322b; + vertical-align:top; +} + +TD.menuframe +{ + width:30%; +} + +.menu +{ + margin:4px 4px 4px 4px; + margin-top: 16pt; + border-color:gray; + border-width:1px; + border-style:dotted; + padding-top:10pt; + padding-bottom:10pt; + padding-right:6pt; +} + +.submenu +{ + list-style-type: none; + margin-left:26pt; + margin-top:0pt; + margin-bottom:0pt; + padding-left:0pt; +} + +A.menuitem,A.menuitem_selected +{ + font-size:14pt; + font-family:Tahoma,Arial,sans-serif; + font-weight:normal; + padding-left:10pt; + color:#5588bb; + margin-right:2pt; + margin-left:4pt; + text-decoration:none; +} + +A.menuitem_selected +{ + font-weight:bold; +} + +A.submenuitem +{ + font-family:Tahoma,Arial,sans-serif; + font-weight:normal; + color:#5588bb; + text-decoration:none; +} + +.titleline +{ + border-width:3px; + border-style:solid; + border-left-width:0px; + border-right-width:0px; + border-top-width:0px; + border-color:#CCCCCC; + margin-left:28pt; + margin-right:2pt; + line-height:1px; + padding-top:0px; + margin-top:0px; + display:block; +} + +.titledescrip +{ + text-align:left; + display:block; + margin-left:26pt; + color:#ae322b; +} + +.mainlogo +{ + display:block; + margin-left:8%; + margin-top:4pt; + margin-bottom:4pt; +} + +/***************************************************** + IMG settings +*****************************************************/ + +IMG +{ + border-style:none; +} + +IMG.smallbutton +{ + margin-right: 20px; + float:none; +} + +IMG.floating +{ + float:left; + margin-right: 4pt; + margin-bottom: 4pt; +} + +IMG.lefticon +{ + vertical-align: middle; + padding-right: 2pt; +} + +IMG.righticon +{ + vertical-align: middle; + padding-left: 2pt; +} + +/***************************************************** + TABLE settings +*****************************************************/ + +TABLE +{ + border-style:none; +} + +TABLE.box +{ + width: 90%; + margin-left:5%; +} + +TABLE.centered +{ + margin-left: auto; + margin-right: auto; +} + +TABLE.hardcoded +{ + background-color: #225588; + margin-left: auto; + margin-right: auto; + width: 90%; +} + +TR { background-color: transparent; } + +TABLE.hardcoded TR { background-color: white } + +TABLE.hardcoded TR.header +{ + font-weight: bold; + color: black; + background-color: #C8D6E5; +} + +TABLE.hardcoded TR.header TD {color:black;} + +TABLE.hardcoded TD { padding-left: 2pt; } + +TD.minimelem { + padding-right:0px; + padding-left:0px; + text-align:center; +} + +TD.rightelem +{ + text-align:right; + /*padding-left:0pt;*/ + padding-right: 2pt; + width: 17%; +} + +/***************************************************** + P settings +*****************************************************/ + +p,.sub{text-align:justify;} +.centered{text-align:center;} +.sub +{ + padding-left: 16pt; + padding-right:16pt; +} + +.Note, .ContactInfo +{ + border-color: #ae322b; + border-width: 1pt; + border-style: dashed; + text-align:justify; + padding: 2pt 2pt 2pt 2pt; + margin-bottom:4pt; + margin-top:8pt; + list-style-position:inside; +} + +.ContactInfo +{ + width:60%; + margin-left:5%; +} + +.NewsItem +{ + border-color:#ae322b; + border-style: solid; + border-right:none; + border-top:none; + border-left:none; + border-bottom-width:1px; + text-align:justify; + padding-left:4pt; + padding-right:4pt; + padding-bottom:8pt; +} + +/***************************************************** + Lists settings +*****************************************************/ +UL.plain +{ + list-style-type: none; + padding-left:0px; + margin-left:0px; +} + +LI.plain +{ + list-style-type: none; +} + +LI.section +{ + padding-top: 6pt; +} + +UL.longtext LI +{ + border-color: #ae322b; + border-width:0px; + border-top-width:1px; + border-style:solid; + margin-top:12px; +} + +/* + with UL.longtext LI, there can be anything between + the UL and the LI, and it will still make the + lontext thing, I must break it with this hack +*/ +UL.longtext UL LI +{ + border-style:none; + margin-top:2px; +} + + +/***************************************************** + Titles settings +*****************************************************/ + +H1,H2,H3 +{ + font-family:"Courier New",monospace; + color:#5588bb; +} + +H1 +{ + font-size:18pt; + color: #ae322b; + border-color: #70A0CF; + border-width: 1pt; + border-style: solid; + margin-top: 16pt; + margin-left: 5%; + margin-right: 5%; + padding-top: 2pt; + padding-bottom:2pt; + text-align: center; +} + +H2 +{ + border-color: #ae322b; + border-bottom-width: 2px; + border-top-width: 0pt; + border-left-width: 2px; + border-right-width: 0pt; + border-bottom-color: #cccccc; + border-style: solid; + margin-top: 16pt; + margin-left: 0pt; + margin-right: 0pt; + padding-bottom:3pt; + padding-left:5pt; + text-align: left; + font-size:16pt; +} + +H3 +{ + display:block; + color:#ae322b; + border-color: #70A0CF; + border-bottom-width: 2px; + border-top-width: 0pt; + border-left-width: 0pt; + border-right-width: 0pt; + border-style: dashed; + margin-top: 12pt; + margin-left: 0pt; + margin-bottom: 4pt; + width:auto; + padding-bottom:3pt; + padding-right:2pt; + padding-left:2pt; + text-align: left; + font-weight:bold; +} + + +/***************************************************** + Misc. classes +*****************************************************/ +.longtext:first-letter {font-size: 150%} + +.price, .loweredprice, .specialprice {font-weight:bold;} + +.loweredprice {text-decoration:line-through} + +.specialprice {color:red} + +form +{ + margin:0px; +} + +.program_summary +{ + float:right; + margin: 32pt; + margin-top:0pt; + margin-bottom:0pt; +} + +.screenshot +{ + float:left; + margin: 8pt; +} \ No newline at end of file diff --git a/se/help/skeleton/images/hs_title.png b/se/help/skeleton/images/hs_title.png new file mode 100644 index 00000000..07bd89c6 Binary files /dev/null and b/se/help/skeleton/images/hs_title.png differ diff --git a/se/help/templates/base_dg.mako b/se/help/templates/base_dg.mako new file mode 100644 index 00000000..7767c49f --- /dev/null +++ b/se/help/templates/base_dg.mako @@ -0,0 +1,14 @@ +<%inherit file="/base_help.mako"/> +${next.body()} + +<%def name="menu()"><% +self.menuitem('intro.htm', 'Introduction', 'Introduction to dupeGuru') +self.menuitem('quick_start.htm', 'Quick Start', 'Quickly get into the action') +self.menuitem('directories.htm', 'Directories', 'Managing dupeGuru directories') +self.menuitem('preferences.htm', 'Preferences', 'Setting dupeGuru preferences') +self.menuitem('results.htm', 'Results', 'Time to delete these duplicates!') +self.menuitem('power_marker.htm', 'Power Marker', 'Take control of your duplicates') +self.menuitem('faq.htm', 'F.A.Q.', 'Frequently Asked Questions') +self.menuitem('versions.htm', 'Version History', 'Changes dupeGuru went through') +self.menuitem('credits.htm', 'Credits', 'People who contributed to dupeGuru') +%> \ No newline at end of file diff --git a/se/help/templates/credits.mako b/se/help/templates/credits.mako new file mode 100644 index 00000000..269d7463 --- /dev/null +++ b/se/help/templates/credits.mako @@ -0,0 +1,20 @@ +<%! + title = 'Credits' + selected_menu_item = 'Credits' +%> +<%inherit file="/base_dg.mako"/> +Below is the list of people who contributed, directly or indirectly to dupeGuru. + +${self.credit('Virgil Dupras', 'Developer', "That's me, Hardcoded Software founder", 'www.hardcoded.net', 'hsoft@hardcoded.net')} + +${self.credit('Jerome', 'Icon designer', "Icons in dupeGuru are from him")} + +${self.credit('Python', 'Programming language', "The bestest of the bests", 'www.python.org')} + +${self.credit('PyObjC', 'Python-to-Cocoa bridge', "Used for the Mac OS X version", 'pyobjc.sourceforge.net')} + +${self.credit('Python for .NET', 'Python-to-.NET bridge', "Used for the Windows version", 'sourceforge.net/projects/pythonnet/')} + +${self.credit('Sparkle', 'Auto-update library', "Used for the Mac OS X version", 'andymatuschak.org/pages/sparkle')} + +${self.credit('You', 'dupeGuru user', "What would I do without you?")} diff --git a/se/help/templates/directories.mako b/se/help/templates/directories.mako new file mode 100644 index 00000000..e75b47bd --- /dev/null +++ b/se/help/templates/directories.mako @@ -0,0 +1,24 @@ +<%! + title = 'Directories' + selected_menu_item = 'Directories' +%> +<%inherit file="/base_dg.mako"/> + +There is a panel in dupeGuru called **Directories**. You can open it by clicking on the **Directories** button. This directory contains the list of the directories that will be scanned when you click on **Start Scanning**. + +This panel is quite straightforward to use. If you want to add a directory, click on **Add**. If you added directories before, a popup menu with a list of recent directories you added will pop. You can click on one of them to add it directly to your list. If you click on the first item of the popup menu, **Add New Directory...**, you will be prompted for a directory to add. If you never added a directory, no menu will pop and you will directly be prompted for a new directory to add. + +To remove a directory, select the directory to remove and click on **Remove**. If a subdirectory is selected when you click remove, the selected directory will be set to **excluded** state (see below) instead of being removed. + +Directory states +----- + +Every directory can be in one of these 3 states: + +* **Normal:** Duplicates found in these directories can be deleted. +* **Reference:** Duplicates found in this directory **cannot** be deleted. Files in reference directories will be in a blue color in the results. +* **Excluded:** Files in this directory will not be included in the scan. + +The default state of a directory is, of course, **Normal**. You can use **Reference** state for a directory if you want to be sure that you won't delete any file from it. + +When you set the state of a directory, all subdirectories of this directory automatically inherit this state unless you explicitly set a subdirectory's state. diff --git a/se/help/templates/faq.mako b/se/help/templates/faq.mako new file mode 100644 index 00000000..659d8b14 --- /dev/null +++ b/se/help/templates/faq.mako @@ -0,0 +1,64 @@ +<%! + title = 'dupeGuru F.A.Q.' + selected_menu_item = 'F.A.Q.' +%> +<%inherit file="/base_dg.mako"/> + +<%text filter="md"> +### What is dupeGuru? + +dupeGuru is a tool to find duplicate files on your computer. It can scan either filenames or content. The filename scan features a fuzzy matching algorithm that can find duplicate filenames even when they are not exactly the same. + +### What makes it better than other duplicate scanners? + +The scanning engine is extremely flexible. You can tweak it to really get the kind of results you want. You can read more about dupeGuru tweaking option at the [Preferences page](preferences.htm). + +### How safe is it to use dupeGuru? + +Very safe. dupeGuru has been designed to make sure you don't delete files you didn't mean to delete. First, there is the reference directory system that lets you define directories where you absolutely **don't** want dupeGuru to let you delete files there, and then there is the group reference system that makes sure that you will **always** keep at least one member of the duplicate group. + +### What are the demo limitations of dupeGuru? + +In demo mode, you can only perform actions (delete/copy/move) on 10 duplicates per session. + +### The mark box of a file I want to delete is disabled. What must I do? + +You cannot mark the reference (The first file) of a duplicate group. However, what you can do is to promote a duplicate file to reference. Thus, if a file you want to mark is reference, select a duplicate file in the group that you want to promote to reference, and click on **Actions-->Make Selected Reference**. If the reference file is from a reference directory (filename written in blue letters), you cannot remove it from the reference position. + +### I have a directory from which I really don't want to delete files. + +If you want to be sure that dupeGuru will never delete file from a particular directory, just open the **Directories panel**, select that directory, and set its state to **Reference**. + +### What is this '(X discarded)' notice in the status bar? + +In some cases, some matches are not included in the final results for security reasons. Let me use an example. We have 3 file: A, B and C. We scan them using a low filter hardness. The scanner determines that A matches with B, A matches with C, but B does **not** match with C. Here, dupeGuru has kind of a problem. It cannot create a duplicate group with A, B and C in it because not all files in the group would match together. It could create 2 groups: one A-B group and then one A-C group, but it will not, for security reasons. Lets think about it: If B doesn't match with C, it probably means that either B, C or both are not actually duplicates. If there would be 2 groups (A-B and A-C), you would end up delete both B and C. And if one of them is not a duplicate, that is really not what you want to do, right? So what dupeGuru does in a case like this is to discard the A-C match (and adds a notice in the status bar). Thus, if you delete B and re-run a scan, you will have a A-C match in your next results. + +### I want to mark all files from a specific directory. What can I do? + +Enable the [Power Marker](power_marker.htm) mode and click on the Directory column to sort your duplicates by Directory. It will then be easy for you to select all duplicates from the same directory, and then press Space to mark all selected duplicates. + +### I want to remove all files that are more than 300 KB away from their reference file. What can I do? + +* Enable the [Power Marker](power_marker.htm) mode. +* Enable the **Delta Values** mode. +* Click on the "Size" column to sort the results by size. +* Select all duplicates below -300. +* Click on **Remove Selected from Results**. +* Select all duplicates over 300. +* Click on **Remove Selected from Results**. + +### I want to make my latest modified files reference files. What can I do? + +* Enable the [Power Marker](power_marker.htm) mode. +* Enable the **Delta Values** mode. +* Click on the "Modification" column to sort the results by modification date. +* Click on the "Modification" column again to reverse the sort order (see Power Marker page to know why). +* Select all duplicates over 0. +* Click on **Make Selected Reference**. + +### I want to mark all duplicates containing the word "copy". How do I do that? + +* **Windows**: Click on **Actions --> Apply Filter**, then type "copy", then click OK. +* **Mac OS X**: Type "copy" in the "Filter" field in the toolbar. +* Click on **Mark --> Mark All**. + \ No newline at end of file diff --git a/se/help/templates/intro.mako b/se/help/templates/intro.mako new file mode 100644 index 00000000..0fd3019b --- /dev/null +++ b/se/help/templates/intro.mako @@ -0,0 +1,13 @@ +<%! + title = 'Introduction to dupeGuru' + selected_menu_item = 'introduction' +%> +<%inherit file="/base_dg.mako"/> + +dupeGuru is a tool to find duplicate files on your computer. It can scan either filenames or contents. The filename scan features a fuzzy matching algorithm that can find duplicate filenames even when they are not exactly the same. + +Although dupeGuru can easily be used without documentation, reading this file will help you to master it. If you are looking for guidance for your first duplicate scan, you can take a look at the [Quick Start](quick_start.htm) section. + +It is a good idea to keep dupeGuru updated. You can download the latest version on the [dupeGuru homepage](http://www.hardcoded.net/dupeguru/). + +<%def name="meta()"> \ No newline at end of file diff --git a/se/help/templates/power_marker.mako b/se/help/templates/power_marker.mako new file mode 100644 index 00000000..26078f3d --- /dev/null +++ b/se/help/templates/power_marker.mako @@ -0,0 +1,33 @@ +<%! + title = 'Power Marker' + selected_menu_item = 'Power Marker' +%> +<%inherit file="/base_dg.mako"/> + +You will probably not use the Power Marker feature very often, but if you get into a situation where you need it, you will be pretty happy that this feature exists. + +What is it? +----- + +When the Power Marker mode is enabled, the duplicates are shown without their respective reference file. You can select, mark and sort this list, just like in normal mode. + +So, what is it for? +----- + +The dupeGuru results, when in normal mode, are sorted according to duplicate groups' **reference file**. This means that if you want, for example, to mark all duplicates with the "exe" extension, you cannot just sort the results by "Kind" to have all exe duplicates together because a group can be composed of more than one kind of files. That is where Power Marker comes into play. To mark all your "exe" duplicates, you just have to: + +* Enable the Power marker mode. +* Add the "Kind" column with the "Columns" menu. +* Click on that "Kind" column to sort the list by kind. +* Locate the first duplicate with a "exe" kind. +* Select it. +* Scroll down the list to locate the last duplicate with a "exe" kind. +* Hold Shift and click on it. +* Press Space to mark all selected duplicates. + +Power Marker and delta values +----- + +The Power Marker unveil its true power when you use it with the **Delta Values** switch turned on. When you turn it on, relative values will be displayed instead of absolute ones. So if, for example, you want to remove from your results all duplicates that are more than 300 KB away from their reference, you could sort the Power Marker by Size, select all duplicates under -300 in the Size column, delete them, and then do the same for duplicates over 300 at the bottom of the list. + +You could also use it to change the reference priority of your duplicate list. When you make a fresh scan, if there are no reference directories, the reference file of every group is the biggest file. If you want to change that, for example, to the latest modification time, you can sort the Power Marker by modification time in **descending** order, select all duplicates with a modification time delta value higher than 0 and click on **Make Selected Reference**. The reason why you must make the sort order descending is because if 2 files among the same duplicate group are selected when you click on **Make Selected Reference**, only the first of the list will be made reference, the other will be ignored. And since you want the last modified file to be reference, having the sort order descending assures you that the first item of the list will be the last modified. diff --git a/se/help/templates/preferences.mako b/se/help/templates/preferences.mako new file mode 100644 index 00000000..578fe8b2 --- /dev/null +++ b/se/help/templates/preferences.mako @@ -0,0 +1,27 @@ +<%! + title = 'Preferences' + selected_menu_item = 'Preferences' +%> +<%inherit file="/base_dg.mako"/> + +**Scan Type:** This option determines what aspect of the files will be compared in the duplicate scan. If you select **Filename**, dupeGuru will compare every filenames word-by-word and, depending on the other settings below, it will determine if enough words are matching to consider 2 files duplicates. If you select **Content**, only files with the exact same content will match. + +**Filter Hardness:** If you chose the **Filename** scan type, this option determines how similar two filenames must be for dupeGuru to consider them duplicates. If the filter hardness is, for example 80, it means that 80% of the words of two filenames must match. To determine the matching percentage, dupeGuru first counts the total number of words in **both** filenames, then count the number of words matching (every word matching count as 2), and then divide the number of words matching by the total number of words. If the result is higher or equal to the filter hardness, we have a duplicate match. For example, "a b c d" and "c d e" have a matching percentage of 57 (4 words matching, 7 total words). + +**Word weighting:** If you chose the **Filename** scan type, this option slightly changes how matching percentage is calculated. With word weighting, instead of having a value of 1 in the duplicate count and total word count, every word have a value equal to the number of characters they have. With word weighting, "ab cde fghi" and "ab cde fghij" would have a matching percentage of 53% (19 total characters, 10 characters matching (4 for "ab" and 6 for "cde")). + +**Match similar words:** If you turn this option on, similar words will be counted as matches. For example "The White Stripes" and "The White Stripe" would have a match % of 100 instead of 66 with that option turned on. **Warning:** Use this option with caution. It is likely that you will get a lot of false positives in your results when turning it on. However, it will help you to find duplicates that you wouldn't have found otherwise. The scan process also is significantly slower with this option turned on. + +**Can mix file kind:** If you check this box, duplicate groups are allowed to have files with different extensions. If you don't check it, well, they aren't! + +**Use regular expressions when filtering:** If you check this box, the filtering feature will treat your filter query as a **regular expression**. Explaining them is beyond the scope of this document. A good place to start learning it is . + +**Remove empty folders after delete or move:** When this option is enabled, folders are deleted after a file is deleted or moved and the folder is empty. + +**Copy and Move:** Determines how the Copy and Move operations (in the Action menu) will behave. + +* **Right in destination:** All files will be sent directly in the selected destination, without trying to recreate the source path at all. +* **Recreate relative path:** The source file's path will be re-created in the destination directory up to the root selection in the Directories panel. For example, if you added "/Users/foobar/Music" to your Directories panel and you move "/Users/foobar/Music/Artist/Album/the_song.mp3" to the destination "/Users/foobar/MyDestination", the final destination for the file will be "/Users/foobar/MyDestination/Artist/Album" ("/Users/foobar/Music" has been trimmed from source's path in the final destination.). +* **Recreate absolute path:** The source file's path will be re-created in the destination directory in it's entirety. For example, if you move "/Users/foobar/Music/Artist/Album/the_song.mp3" to the destination "/Users/foobar/MyDestination", the final destination for the file will be "/Users/foobar/MyDestination/Users/foobar/Music/Artist/Album". + +In all cases, dupeGuru nicely handles naming conflicts by prepending a number to the destination filename if the filename already exists in the destination. diff --git a/se/help/templates/quick_start.mako b/se/help/templates/quick_start.mako new file mode 100644 index 00000000..dde33c65 --- /dev/null +++ b/se/help/templates/quick_start.mako @@ -0,0 +1,18 @@ +<%! + title = 'Quick Start' + selected_menu_item = 'Quick Start' +%> +<%inherit file="/base_dg.mako"/> + +To get you quickly started with dupeGuru, let's just make a standard scan using default preferences. + +* Click on **Directories**. +* Click on **Add**. +* Choose a directory you want to scan for duplicates. +* Click on **Start Scanning**. +* Wait until the scan process is over. +* Look at every duplicate (The files that are indented) and verify that it is indeed a duplicate to the group's reference (The file above the duplicate that is not indented and have a disabled mark box). +* If a file is a false duplicate, select it and click on **Actions-->Remove Selected from Results**. +* Once you are sure that there is no false duplicate in your results, click on **Edit-->Mark All**, and then **Actions-->Send Marked to Recycle bin**. + +That is only a basic scan. There are a lot of tweaking you can do to get different results and several methods of examining and modifying your results. To know about them, just read the rest of this help file. diff --git a/se/help/templates/results.mako b/se/help/templates/results.mako new file mode 100644 index 00000000..53aa176f --- /dev/null +++ b/se/help/templates/results.mako @@ -0,0 +1,73 @@ +<%! + title = 'Results' + selected_menu_item = 'Results' +%> +<%inherit file="/base_dg.mako"/> + +When dupeGuru is finished scanning for duplicates, it will show its results in the form of duplicate group list. + +About duplicate groups +----- + +A duplicate group is a group of files that all match together. Every group has a **reference file** and one or more **duplicate files**. The reference file is the first file of the group. Its mark box is disabled. Below it, and indented, are the duplicate files. + +You can mark duplicate files, but you can never mark the reference file of a group. This is a security measure to prevent dupeGuru from deleting not only duplicate files, but their reference. You sure don't want that, do you? + +What determines which files are reference and which files are duplicates is first their directory state. A files from a reference directory will always be reference in a duplicate group. If all files are from a normal directory, the size determine which file will be the reference of a duplicate group. dupeGuru assumes that you always want to keep the biggest file, so the biggest files will take the reference position. + +You can change the reference file of a group manually. To do so, select the duplicate file you want to promote to reference, and click on **Actions-->Make Selected Reference**. + +Reviewing results +----- + +Although you can just click on **Edit-->Mark All** and then **Actions-->Send Marked to Recycle bin** to quickly delete all duplicate files in your results, it is always recommended to review all duplicates before deleting them. + +To help you reviewing the results, you can bring up the **Details panel**. This panel shows all the details of the currently selected file as well as its reference's details. This is very handy to quickly determine if a duplicate really is a duplicate. You can also double-click on a file to open it with its associated application. + +If you have more false duplicates than true duplicates (If your filter hardness is very low), the best way to proceed would be to review duplicates, mark true duplicates and then click on **Actions-->Send Marked to Recycle bin**. If you have more true duplicates than false duplicates, you can instead mark all files that are false duplicates, and use **Actions-->Remove Marked from Results**. + +Marking and Selecting +----- + +A **marked** duplicate is a duplicate with the little box next to it having a check-mark. A **selected** duplicate is a duplicate being highlighted. The multiple selection actions can be performed in dupeGuru in the standard way (Shift/Command/Control click). You can toggle all selected duplicates' mark state by pressing **space**. + +Delta Values +----- + +If you turn this switch on, some columns will display the value relative to the duplicate's reference instead of the absolute values. These delta values will also be displayed in a different color so you can spot them easily. For example, if a duplicate is 1.2 MB and its reference is 1.4 MB, the Size column will display -0.2 MB. This option is a killer feature when combined with the [Power Marker](power_marker.htm). + +Filtering +----- + +dupeGuru supports post-scan filtering. With it, you can narrow down your results so you can perform actions on a subset of it. For example, you could easily mark all duplicates with their filename containing "copy" from your results using the filter. + +**Windows:** To use the filtering feature, click on Actions --> Apply Filter, write down the filter you want to apply and click OK. To go back to unfiltered results, click on Actions --> Cancel Filter. + +**Mac OS X:** To use the filtering feature, type your filter in the "Filter" search field in the toolbar. To go back to unfiltered result, blank out the field, or click on the "X". + +In simple mode (the default mode), whatever you type as the filter is the string used to perform the actual filtering, with the exception of one wildcard: **\***. Thus, if you type "[*]" as your filter, it will match anything with [] brackets in it, whatever is in between those brackets. + +For more advanced filtering, you can turn "Use regular expressions when filtering" on. The filtering feature will then use **regular expressions**. A regular expression is a language for matching text. Explaining them is beyond the scope of this document. A good place to start learning it is . + +Matches are case insensitive in both simple and regexp mode. + +For the filter to match, your regular expression don't have to match the whole filename, it just have to contain a string matching the expression. + +You might notice that not all duplicates in the filtered results will match your filter. That is because as soon as one single duplicate in a group matches the filter, the whole group stays in the results so you can have a better view of the duplicate's context. However, non-matching duplicates are in "reference mode". Therefore, you can perform actions like Mark All and be sure to only mark filtered duplicates. + +Action Menu +----- + +* **Start Duplicate Scan:** Starts a new duplicate scan. +* **Clear Ignore List:** Remove all ignored matches you added. You have to start a new scan for the newly cleared ignore list to be effective. +* **Export Results to XHTML:** Take the current results, and create an XHTML file out of it. The columns that are visible when you click on this button will be the columns present in the XHTML file. The file will automatically be opened in your default browser. +* **Send Marked to Trash:** Send all marked duplicates to trash, obviously. +* **Move Marked to...:** Prompt you for a destination, and then move all marked files to that destination. Source file's path might be re-created in destination, depending on the "Copy and Move" preference. +* **Copy Marked to...:** Prompt you for a destination, and then copy all marked files to that destination. Source file's path might be re-created in destination, depending on the "Copy and Move" preference. +* **Remove Marked from Results:** Remove all marked duplicates from results. The actual files will not be touched and will stay where they are. +* **Remove Selected from Results:** Remove all selected duplicates from results. Note that all selected reference files will be ignored, only duplicates can be removed with this action. +* **Make Selected Reference:** Promote all selected duplicates to reference. If a duplicate is a part of a group having a reference file coming from a reference directory (in blue color), no action will be taken for this duplicate. If more than one duplicate among the same group are selected, only the first of each group will be promoted. +* **Add Selected to Ignore List:** This first removes all selected duplicates from results, and then add the match of that duplicate and the current reference in the ignore list. This match will not come up again in further scan. The duplicate itself might come back, but it will be matched with another reference file. You can clear the ignore list with the Clear Ignore List command. +* **Open Selected with Default Application:** Open the file with the application associated with selected file's type. +* **Reveal Selected in Finder:** Open the folder containing selected file. +* **Rename Selected:** Prompts you for a new name, and then rename the selected file. diff --git a/se/help/templates/versions.mako b/se/help/templates/versions.mako new file mode 100644 index 00000000..354a294d --- /dev/null +++ b/se/help/templates/versions.mako @@ -0,0 +1,6 @@ +<%! + title = 'dupeGuru version history' + selected_menu_item = 'Version History' +%> +<%inherit file="/base_dg.mako"/> +${self.output_changelogs(changelog)} \ No newline at end of file diff --git a/se/qt/app.py b/se/qt/app.py new file mode 100644 index 00000000..3859a5f8 --- /dev/null +++ b/se/qt/app.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# Unit Name: app +# Created By: Virgil Dupras +# Created On: 2009-05-24 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from dupeguru import data + +from base.app import DupeGuru as DupeGuruBase +from details_dialog import DetailsDialog +from preferences import Preferences +from preferences_dialog import PreferencesDialog + +class DupeGuru(DupeGuruBase): + LOGO_NAME = 'logo_se' + NAME = 'dupeGuru' + VERSION = '2.7.1' + DELTA_COLUMNS = frozenset([2, 4, 5]) + + def __init__(self): + DupeGuruBase.__init__(self, data, appid=4) + + def _update_options(self): + DupeGuruBase._update_options(self) + self.scanner.min_match_percentage = self.prefs.filter_hardness + self.scanner.scan_type = self.prefs.scan_type + self.scanner.word_weighting = self.prefs.word_weighting + self.scanner.match_similar_words = self.prefs.match_similar + threshold = self.prefs.small_file_threshold if self.prefs.ignore_small_files else 0 + self.scanner.size_threshold = threshold * 1024 # threshold is in KB. the scanner wants bytes + + def _create_details_dialog(self, parent): + return DetailsDialog(parent, self) + + def _create_preferences(self): + return Preferences() + + def _create_preferences_dialog(self, parent): + return PreferencesDialog(parent, self) + diff --git a/se/qt/app_win.py b/se/qt/app_win.py new file mode 100644 index 00000000..8088bce6 --- /dev/null +++ b/se/qt/app_win.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# Unit Name: app_win +# Created By: Virgil Dupras +# Created On: 2009-05-24 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import winshell + +import app + +class DupeGuru(app.DupeGuru): + @staticmethod + def _recycle_dupe(dupe): + winshell.delete_file(unicode(dupe.path), no_confirm=True) + diff --git a/se/qt/build.py b/se/qt/build.py new file mode 100644 index 00000000..ff2b3e69 --- /dev/null +++ b/se/qt/build.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# Unit Name: build +# Created By: Virgil Dupras +# Created On: 2009-05-24 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +# On Windows, PyInstaller is used to build an exe (py2exe creates a very bad looking icon +# The release version is outdated. Use at least r672 on http://svn.pyinstaller.org/trunk + +import os +import os.path as op +import shutil +from app import DupeGuru + +def print_and_do(cmd): + print cmd + os.system(cmd) + +# Removing build and dist +if op.exists('build'): + shutil.rmtree('build') +if op.exists('dist'): + shutil.rmtree('dist') + +version = DupeGuru.VERSION +versioncomma = version.replace('.', ', ') + ', 0' +verinfo = open('verinfo').read() +verinfo = verinfo.replace('$versioncomma', versioncomma).replace('$version', version) +fp = open('verinfo_tmp', 'w') +fp.write(verinfo) +fp.close() +print_and_do("python C:\\Python26\\pyinstaller\\Build.py dgse.spec") +os.remove('verinfo_tmp') + +print_and_do("xcopy /Y C:\\src\\vs_comp\\msvcrt dist") +print_and_do("xcopy /Y /S /I help\\dupeguru_help dist\\help") + +aicom = '"\\Program Files\\Caphyon\\Advanced Installer\\AdvancedInstaller.com"' +shutil.copy('installer.aip', 'installer_tmp.aip') # this is so we don'a have to re-commit installer.aip at every version change +print_and_do('%s /edit installer_tmp.aip /SetVersion %s' % (aicom, version)) +print_and_do('%s /build installer_tmp.aip -force' % aicom) +os.remove('installer_tmp.aip') \ No newline at end of file diff --git a/se/qt/details_dialog.py b/se/qt/details_dialog.py new file mode 100644 index 00000000..df72ee52 --- /dev/null +++ b/se/qt/details_dialog.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# Unit Name: details_dialog +# Created By: Virgil Dupras +# Created On: 2009-05-24 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import Qt +from PyQt4.QtGui import QDialog + +from base.details_table import DetailsModel +from details_dialog_ui import Ui_DetailsDialog + +class DetailsDialog(QDialog, Ui_DetailsDialog): + def __init__(self, parent, app): + QDialog.__init__(self, parent, Qt.Tool) + self.app = app + self.setupUi(self) + self.model = DetailsModel(app) + self.tableView.setModel(self.model) diff --git a/se/qt/details_dialog.ui b/se/qt/details_dialog.ui new file mode 100644 index 00000000..1dc063d0 --- /dev/null +++ b/se/qt/details_dialog.ui @@ -0,0 +1,53 @@ + + + DetailsDialog + + + + 0 + 0 + 502 + 186 + + + + + 200 + 0 + + + + Details + + + + 0 + + + 0 + + + + + true + + + QAbstractItemView::SelectRows + + + false + + + + + + + + DetailsTable + QTableView +
base.details_table
+
+
+ + +
diff --git a/se/qt/dgse.spec b/se/qt/dgse.spec new file mode 100644 index 00000000..e2229597 --- /dev/null +++ b/se/qt/dgse.spec @@ -0,0 +1,19 @@ +# -*- mode: python -*- +a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), 'start.py'], + pathex=['C:\\src\\dupeguru\\se\\qt']) +pyz = PYZ(a.pure) +exe = EXE(pyz, + a.scripts, + exclude_binaries=1, + name=os.path.join('build\\pyi.win32\\dupeGuru', 'dupeGuru.exe'), + debug=False, + strip=False, + upx=True, + console=False , icon='base\\images\\dgse_logo.ico', version='verinfo_tmp') +coll = COLLECT( exe, + a.binaries, + a.zipfiles, + a.datas, + strip=False, + upx=True, + name=os.path.join('dist')) diff --git a/se/qt/gen.py b/se/qt/gen.py new file mode 100644 index 00000000..b712a5b6 --- /dev/null +++ b/se/qt/gen.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +# Unit Name: gen +# Created By: Virgil Dupras +# Created On: 2009-05-24 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +import os + +def print_and_do(cmd): + print cmd + os.system(cmd) + +os.chdir('dupeguru') +print_and_do('python gen.py') +os.chdir('..') + +os.chdir('base') +print_and_do('python gen.py') +os.chdir('..') + +print_and_do("pyuic4 details_dialog.ui > details_dialog_ui.py") +print_and_do("pyuic4 preferences_dialog.ui > preferences_dialog_ui.py") + +os.chdir('help') +print_and_do('python gen.py') +os.chdir('..') diff --git a/se/qt/installer.aip b/se/qt/installer.aip new file mode 100644 index 00000000..c60f88ae --- /dev/null +++ b/se/qt/installer.aip @@ -0,0 +1,257 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/se/qt/preferences.py b/se/qt/preferences.py new file mode 100644 index 00000000..b978bc6d --- /dev/null +++ b/se/qt/preferences.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# Unit Name: preferences +# Created By: Virgil Dupras +# Created On: 2009-05-24 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from dupeguru.scanner import SCAN_TYPE_FILENAME, SCAN_TYPE_CONTENT + +from base.preferences import Preferences as PreferencesBase + +class Preferences(PreferencesBase): + # (width, is_visible) + COLUMNS_DEFAULT_ATTRS = [ + (200, True), # name + (180, True), # path + (60, True), # size + (40, False), # Kind + (120, False), # creation + (120, False), # modification + (60, True), # match % + (120, False), # Words Used + (80, False), # dupe count + ] + + def _load_specific(self, settings, get): + self.scan_type = get('ScanType', self.scan_type) + self.word_weighting = get('WordWeighting', self.word_weighting) + self.match_similar = get('MatchSimilar', self.match_similar) + self.ignore_small_files = get('IgnoreSmallFiles', self.ignore_small_files) + self.small_file_threshold = get('SmallFileThreshold', self.small_file_threshold) + + def _reset_specific(self): + self.filter_hardness = 80 + self.scan_type = SCAN_TYPE_CONTENT + self.word_weighting = True + self.match_similar = False + self.ignore_small_files = True + self.small_file_threshold = 10 # KB + + def _save_specific(self, settings, set_): + set_('ScanType', self.scan_type) + set_('WordWeighting', self.word_weighting) + set_('MatchSimilar', self.match_similar) + set_('IgnoreSmallFiles', self.ignore_small_files) + set_('SmallFileThreshold', self.small_file_threshold) + diff --git a/se/qt/preferences_dialog.py b/se/qt/preferences_dialog.py new file mode 100644 index 00000000..80be1ac9 --- /dev/null +++ b/se/qt/preferences_dialog.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python +# Unit Name: preferences_dialog +# Created By: Virgil Dupras +# Created On: 2009-05-24 +# $Id$ +# Copyright 2009 Hardcoded Software (http://www.hardcoded.net) + +from PyQt4.QtCore import SIGNAL, Qt +from PyQt4.QtGui import QDialog, QDialogButtonBox + +from hsutil.misc import tryint + +from dupeguru.scanner import SCAN_TYPE_FILENAME, SCAN_TYPE_CONTENT + +from preferences_dialog_ui import Ui_PreferencesDialog +import preferences + +SCAN_TYPE_ORDER = [ + SCAN_TYPE_FILENAME, + SCAN_TYPE_CONTENT, +] + +class PreferencesDialog(QDialog, Ui_PreferencesDialog): + def __init__(self, parent, app): + flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint + QDialog.__init__(self, parent, flags) + self.app = app + self._setupUi() + + self.connect(self.buttonBox, SIGNAL('clicked(QAbstractButton*)'), self.buttonClicked) + self.connect(self.scanTypeComboBox, SIGNAL('currentIndexChanged(int)'), self.scanTypeChanged) + + def _setupUi(self): + self.setupUi(self) + + def load(self, prefs=None): + if prefs is None: + prefs = self.app.prefs + self.filterHardnessSlider.setValue(prefs.filter_hardness) + self.filterHardnessLabel.setNum(prefs.filter_hardness) + scan_type_index = SCAN_TYPE_ORDER.index(prefs.scan_type) + self.scanTypeComboBox.setCurrentIndex(scan_type_index) + setchecked = lambda cb, b: cb.setCheckState(Qt.Checked if b else Qt.Unchecked) + setchecked(self.matchSimilarBox, prefs.match_similar) + setchecked(self.wordWeightingBox, prefs.word_weighting) + setchecked(self.mixFileKindBox, prefs.mix_file_kind) + setchecked(self.useRegexpBox, prefs.use_regexp) + setchecked(self.removeEmptyFoldersBox, prefs.remove_empty_folders) + setchecked(self.ignoreSmallFilesBox, prefs.ignore_small_files) + self.sizeThresholdEdit.setText(unicode(prefs.small_file_threshold)) + self.copyMoveDestinationComboBox.setCurrentIndex(prefs.destination_type) + + def save(self): + prefs = self.app.prefs + prefs.filter_hardness = self.filterHardnessSlider.value() + prefs.scan_type = SCAN_TYPE_ORDER[self.scanTypeComboBox.currentIndex()] + ischecked = lambda cb: cb.checkState() == Qt.Checked + prefs.match_similar = ischecked(self.matchSimilarBox) + prefs.word_weighting = ischecked(self.wordWeightingBox) + prefs.mix_file_kind = ischecked(self.mixFileKindBox) + prefs.use_regexp = ischecked(self.useRegexpBox) + prefs.remove_empty_folders = ischecked(self.removeEmptyFoldersBox) + prefs.ignore_small_files = ischecked(self.ignoreSmallFilesBox) + prefs.small_file_threshold = tryint(self.sizeThresholdEdit.text()) + prefs.destination_type = self.copyMoveDestinationComboBox.currentIndex() + + def resetToDefaults(self): + self.load(preferences.Preferences()) + + #--- Events + def buttonClicked(self, button): + role = self.buttonBox.buttonRole(button) + if role == QDialogButtonBox.ResetRole: + self.resetToDefaults() + + def scanTypeChanged(self, index): + scan_type = SCAN_TYPE_ORDER[self.scanTypeComboBox.currentIndex()] + word_based = scan_type == SCAN_TYPE_FILENAME + self.filterHardnessSlider.setEnabled(word_based) + self.matchSimilarBox.setEnabled(word_based) + self.wordWeightingBox.setEnabled(word_based) + diff --git a/se/qt/preferences_dialog.ui b/se/qt/preferences_dialog.ui new file mode 100644 index 00000000..368228fa --- /dev/null +++ b/se/qt/preferences_dialog.ui @@ -0,0 +1,389 @@ + + + PreferencesDialog + + + + 0 + 0 + 294 + 296 + + + + Preferences + + + false + + + true + + + + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Scan Type: + + + + + + + + Filename + + + + + Contents + + + + + + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Filter Hardness: + + + + + + + 0 + + + + + 12 + + + + + + 0 + 0 + + + + 1 + + + 100 + + + true + + + Qt::Horizontal + + + + + + + + 21 + 0 + + + + 100 + + + + + + + + + 0 + + + + + More Results + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Less Results + + + + + + + + + + + + + + 0 + 134 + + + + + + 0 + 0 + 350 + 21 + + + + Word weighting + + + + + + 0 + 22 + 350 + 21 + + + + Match similar words + + + + + + 0 + 44 + 350 + 21 + + + + Can mix file kind + + + + + + 0 + 66 + 350 + 21 + + + + Use regular expressions when filtering + + + + + + 0 + 88 + 350 + 21 + + + + Remove empty folders on delete or move + + + + + + 0 + 110 + 171 + 21 + + + + Ignore files smaller than + + + + + + 170 + 110 + 51 + 22 + + + + + + + 230 + 110 + 21 + 17 + + + + KB + + + + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Copy and Move: + + + + + + + + 0 + 0 + + + + + Right in destination + + + + + Recreate relative path + + + + + Recreate absolute path + + + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults + + + + + + + + + filterHardnessSlider + valueChanged(int) + filterHardnessLabel + setNum(int) + + + 182 + 26 + + + 271 + 26 + + + + + buttonBox + accepted() + PreferencesDialog + accept() + + + 182 + 228 + + + 182 + 124 + + + + + buttonBox + rejected() + PreferencesDialog + reject() + + + 182 + 228 + + + 182 + 124 + + + + + diff --git a/se/qt/profile.py b/se/qt/profile.py new file mode 100644 index 00000000..c1aefca9 --- /dev/null +++ b/se/qt/profile.py @@ -0,0 +1,20 @@ +import sys +import cProfile +import pstats + +from PyQt4.QtCore import QCoreApplication +from PyQt4.QtGui import QApplication + +if sys.platform == 'win32': + from app_win import DupeGuru +else: + from app import DupeGuru + +if __name__ == "__main__": + app = QApplication(sys.argv) + QCoreApplication.setOrganizationName('Hardcoded Software') + QCoreApplication.setApplicationName('dupeGuru') + dgapp = DupeGuru() + cProfile.run('app.exec_()', '/tmp/prof') + p = pstats.Stats('/tmp/prof') + p.sort_stats('time').print_stats() \ No newline at end of file diff --git a/se/qt/start.py b/se/qt/start.py new file mode 100644 index 00000000..41118430 --- /dev/null +++ b/se/qt/start.py @@ -0,0 +1,20 @@ +import sys + +from PyQt4.QtCore import QCoreApplication +from PyQt4.QtGui import QApplication, QIcon, QPixmap + +import base.dg_rc + +if sys.platform == 'win32': + from app_win import DupeGuru +else: + from app import DupeGuru + +if __name__ == "__main__": + app = QApplication(sys.argv) + app.setWindowIcon(QIcon(QPixmap(":/logo_se"))) + QCoreApplication.setOrganizationName('Hardcoded Software') + QCoreApplication.setApplicationName(DupeGuru.NAME) + QCoreApplication.setApplicationVersion(DupeGuru.VERSION) + dgapp = DupeGuru() + sys.exit(app.exec_()) \ No newline at end of file diff --git a/se/qt/verinfo b/se/qt/verinfo new file mode 100644 index 00000000..b32801d5 --- /dev/null +++ b/se/qt/verinfo @@ -0,0 +1,28 @@ +VSVersionInfo( + ffi=FixedFileInfo( + filevers=($versioncomma), + prodvers=($versioncomma), + mask=0x17, + flags=0x0, + OS=0x4, + fileType=0x1, + subtype=0x0, + date=(0, 0) + ), + kids=[ + StringFileInfo( + [ + StringTable( + '040904b0', + [StringStruct('CompanyName', 'Hardcoded Software'), + StringStruct('FileDescription', 'dupeGuru'), + StringStruct('FileVersion', '$version'), + StringStruct('InternalName', 'dupeGuru.exe'), + StringStruct('LegalCopyright', '(c) Hardcoded Software. All rights reserved.'), + StringStruct('OriginalFilename', 'dupeGuru.exe'), + StringStruct('ProductName', 'dupeGuru'), + StringStruct('ProductVersion', '$versioncomma')]) + ]), + VarFileInfo([VarStruct('Translation', [1033])]) + ] +)