mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-23 15:11:39 +00:00
Initial commit.
--HG-- extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%402
This commit is contained in:
225
me/cocoa/py/dg_cocoa.py
Normal file
225
me/cocoa/py/dg_cocoa.py
Normal file
@@ -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)
|
||||
|
||||
18
me/cocoa/py/gen.py
Normal file
18
me/cocoa/py/gen.py
Normal file
@@ -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')
|
||||
14
me/cocoa/py/setup.py
Normal file
14
me/cocoa/py/setup.py
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user