mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 06:37:17 +00:00
Converted to py3k. There's probably some bugs still. So far, I managed to run dupeGuru SE under pyobjc and qt.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.hardcoded.net/licenses/hs_license
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
|
||||
import logging
|
||||
import os
|
||||
@@ -54,7 +54,7 @@ class DupeGuru(DupeGuruBase, QObject):
|
||||
DELTA_COLUMNS = frozenset()
|
||||
|
||||
def __init__(self, data_module, appid):
|
||||
appdata = unicode(QDesktopServices.storageLocation(QDesktopServices.DataLocation))
|
||||
appdata = str(QDesktopServices.storageLocation(QDesktopServices.DataLocation))
|
||||
if not op.exists(appdata):
|
||||
os.makedirs(appdata)
|
||||
# For basicConfig() to work, we have to be sure that no logging has taken place before this call.
|
||||
@@ -120,7 +120,7 @@ class DupeGuru(DupeGuruBase, QObject):
|
||||
#--- Override
|
||||
@staticmethod
|
||||
def _open_path(path):
|
||||
url = QUrl.fromLocalFile(unicode(path))
|
||||
url = QUrl.fromLocalFile(str(path))
|
||||
QDesktopServices.openUrl(url)
|
||||
|
||||
@staticmethod
|
||||
@@ -150,7 +150,7 @@ class DupeGuru(DupeGuruBase, QObject):
|
||||
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))
|
||||
destination = str(QFileDialog.getExistingDirectory(self.main_window, title, '', flags))
|
||||
if not destination:
|
||||
return
|
||||
recreate_path = self.prefs.destination_type
|
||||
|
||||
@@ -52,9 +52,9 @@ class DirectoriesDialog(QDialog, Ui_DirectoriesDialog):
|
||||
# label = 'Remove' if node.parent is None else 'Exclude'
|
||||
|
||||
def addButtonClicked(self):
|
||||
title = u"Select a directory to add to the scanning list"
|
||||
title = "Select a directory to add to the scanning list"
|
||||
flags = QFileDialog.ShowDirsOnly
|
||||
dirpath = unicode(QFileDialog.getExistingDirectory(self, title, self.lastAddedFolder, flags))
|
||||
dirpath = str(QFileDialog.getExistingDirectory(self, title, self.lastAddedFolder, flags))
|
||||
if not dirpath:
|
||||
return
|
||||
self.lastAddedFolder = dirpath
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.hardcoded.net/licenses/hs_license
|
||||
|
||||
import urllib
|
||||
import urllib.parse
|
||||
|
||||
from PyQt4.QtCore import QModelIndex, Qt, QRect, QEvent, QPoint, QUrl
|
||||
from PyQt4.QtGui import (QComboBox, QStyledItemDelegate, QMouseEvent, QApplication, QBrush, QStyle,
|
||||
@@ -101,9 +101,9 @@ class DirectoriesModel(TreeModel):
|
||||
if not mimeData.hasFormat('text/uri-list'):
|
||||
return False
|
||||
data = str(mimeData.data('text/uri-list'))
|
||||
unquoted = urllib.unquote(data)
|
||||
urls = unicode(unquoted, 'utf-8').split('\r\n')
|
||||
paths = [unicode(QUrl(url).toLocalFile()) for url in urls if url]
|
||||
unquoted = urllib.parse.unquote(data)
|
||||
urls = str(unquoted, 'utf-8').split('\r\n')
|
||||
paths = [str(QUrl(url).toLocalFile()) for url in urls if url]
|
||||
for path in paths:
|
||||
self.model.add_directory(path)
|
||||
self.reset()
|
||||
|
||||
@@ -16,10 +16,10 @@ from hsutil.misc import nonone
|
||||
|
||||
from core.app import NoScannableFileError, AllFilesAreRefError
|
||||
|
||||
import dg_rc
|
||||
from main_window_ui import Ui_MainWindow
|
||||
from results_model import ResultsModel
|
||||
from stats_label import StatsLabel
|
||||
from . import dg_rc
|
||||
from .main_window_ui import Ui_MainWindow
|
||||
from .results_model import ResultsModel
|
||||
from .stats_label import StatsLabel
|
||||
|
||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
def __init__(self, app):
|
||||
@@ -104,7 +104,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
h = self.resultsView.header()
|
||||
h.setResizeMode(QHeaderView.Interactive)
|
||||
prefs = self.app.prefs
|
||||
attrs = zip(prefs.columns_width, prefs.columns_visible)
|
||||
attrs = list(zip(prefs.columns_width, prefs.columns_visible))
|
||||
for index, (width, visible) in enumerate(attrs):
|
||||
h.resizeSection(index, width)
|
||||
h.setSectionHidden(index, not visible)
|
||||
@@ -145,7 +145,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
answer, ok = QInputDialog.getText(self, title, msg, QLineEdit.Normal, text)
|
||||
if not ok:
|
||||
return
|
||||
answer = unicode(answer)
|
||||
answer = str(answer)
|
||||
self.app.apply_filter(answer)
|
||||
self._last_filter = answer
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ import logging
|
||||
import sys
|
||||
|
||||
if sys.platform == 'win32':
|
||||
from platform_win import *
|
||||
from .platform_win import *
|
||||
elif sys.platform == 'darwin':
|
||||
from platform_osx import *
|
||||
from .platform_osx import *
|
||||
elif sys.platform == 'linux2':
|
||||
from platform_lnx import *
|
||||
from .platform_lnx import *
|
||||
else:
|
||||
pass # unsupported platform
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.hardcoded.net/licenses/hs_license
|
||||
|
||||
INITIAL_FOLDER_IN_DIALOGS = u'/'
|
||||
INITIAL_FOLDER_IN_DIALOGS = '/'
|
||||
HELP_PATH = '/usr/local/share/dupeguru_{0}/help'
|
||||
|
||||
@@ -9,5 +9,5 @@
|
||||
|
||||
# dummy unit to allow the app to run under OSX during development
|
||||
|
||||
INITIAL_FOLDER_IN_DIALOGS = u'/'
|
||||
INITIAL_FOLDER_IN_DIALOGS = '/'
|
||||
HELP_PATH = ''
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.hardcoded.net/licenses/hs_license
|
||||
|
||||
INITIAL_FOLDER_IN_DIALOGS = u'C:\\'
|
||||
INITIAL_FOLDER_IN_DIALOGS = 'C:\\'
|
||||
HELP_PATH = 'help'
|
||||
|
||||
@@ -112,7 +112,7 @@ class ResultsModel(TreeModel):
|
||||
return True
|
||||
if role == Qt.EditRole:
|
||||
if index.column() == 0:
|
||||
value = unicode(value.toString())
|
||||
value = str(value.toString())
|
||||
return self.model.rename_selected(value)
|
||||
return False
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ class PreferencesDialog(QDialog, Ui_PreferencesDialog):
|
||||
prefs.use_regexp = ischecked(self.useRegexpBox)
|
||||
prefs.remove_empty_folders = ischecked(self.removeEmptyFoldersBox)
|
||||
prefs.destination_type = self.copyMoveDestinationComboBox.currentIndex()
|
||||
prefs.custom_command = unicode(self.customCommandEdit.text())
|
||||
prefs.custom_command = str(self.customCommandEdit.text())
|
||||
|
||||
def resetToDefaults(self):
|
||||
self.load(preferences.Preferences())
|
||||
|
||||
@@ -41,14 +41,14 @@ class File(fs.File):
|
||||
fs.File._read_info(self, field)
|
||||
if field == 'dimensions':
|
||||
try:
|
||||
im = PIL.Image.open(unicode(self.path))
|
||||
im = PIL.Image.open(str(self.path))
|
||||
self.dimensions = im.size
|
||||
except IOError:
|
||||
self.dimensions = (0, 0)
|
||||
logging.warning(u"Could not read image '%s'", unicode(self.path))
|
||||
logging.warning("Could not read image '%s'", str(self.path))
|
||||
|
||||
def get_blocks(self, block_count_per_side):
|
||||
image = QImage(unicode(self.path))
|
||||
image = QImage(str(self.path))
|
||||
image = image.convertToFormat(QImage.Format_RGB888)
|
||||
return getblocks(image, block_count_per_side)
|
||||
|
||||
|
||||
@@ -28,11 +28,11 @@ class DetailsDialog(DetailsDialogBase, Ui_DetailsDialog):
|
||||
group = self.app.results.get_group_of_duplicate(dupe)
|
||||
ref = group.ref
|
||||
|
||||
self.selectedPixmap = QPixmap(unicode(dupe.path))
|
||||
self.selectedPixmap = QPixmap(str(dupe.path))
|
||||
if ref is dupe:
|
||||
self.referencePixmap = None
|
||||
else:
|
||||
self.referencePixmap = QPixmap(unicode(ref.path))
|
||||
self.referencePixmap = QPixmap(str(ref.path))
|
||||
self._updateImages()
|
||||
|
||||
def _updateImages(self):
|
||||
|
||||
@@ -15,7 +15,7 @@ def move(src, dst):
|
||||
return
|
||||
if op.exists(dst):
|
||||
os.remove(dst)
|
||||
print 'Moving %s --> %s' % (src, dst)
|
||||
print('Moving %s --> %s' % (src, dst))
|
||||
os.rename(src, dst)
|
||||
|
||||
os.chdir('modules')
|
||||
|
||||
@@ -46,7 +46,7 @@ class PreferencesDialog(QDialog, Ui_PreferencesDialog):
|
||||
prefs.use_regexp = ischecked(self.useRegexpBox)
|
||||
prefs.remove_empty_folders = ischecked(self.removeEmptyFoldersBox)
|
||||
prefs.destination_type = self.copyMoveDestinationComboBox.currentIndex()
|
||||
prefs.custom_command = unicode(self.customCommandEdit.text())
|
||||
prefs.custom_command = str(self.customCommandEdit.text())
|
||||
|
||||
def resetToDefaults(self):
|
||||
self.load(preferences.Preferences())
|
||||
|
||||
@@ -48,7 +48,7 @@ class PreferencesDialog(QDialog, Ui_PreferencesDialog):
|
||||
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.sizeThresholdEdit.setText(str(prefs.small_file_threshold))
|
||||
self.copyMoveDestinationComboBox.setCurrentIndex(prefs.destination_type)
|
||||
self.customCommandEdit.setText(prefs.custom_command)
|
||||
|
||||
@@ -65,7 +65,7 @@ class PreferencesDialog(QDialog, Ui_PreferencesDialog):
|
||||
prefs.ignore_small_files = ischecked(self.ignoreSmallFilesBox)
|
||||
prefs.small_file_threshold = tryint(self.sizeThresholdEdit.text())
|
||||
prefs.destination_type = self.copyMoveDestinationComboBox.currentIndex()
|
||||
prefs.custom_command = unicode(self.customCommandEdit.text())
|
||||
prefs.custom_command = str(self.customCommandEdit.text())
|
||||
|
||||
def resetToDefaults(self):
|
||||
self.load(preferences.Preferences())
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
# http://www.hardcoded.net/licenses/hs_license
|
||||
|
||||
import sys
|
||||
import sip
|
||||
sip.setapi('QVariant', 1)
|
||||
|
||||
from PyQt4.QtCore import QCoreApplication
|
||||
from PyQt4.QtGui import QApplication, QIcon, QPixmap
|
||||
|
||||
Reference in New Issue
Block a user