From d26441306af739022ee9c3d6ef519f1d491e67b9 Mon Sep 17 00:00:00 2001 From: beville Date: Mon, 21 Jan 2013 01:07:45 +0000 Subject: [PATCH] Added setting for rename to use the archive type git-svn-id: http://comictagger.googlecode.com/svn/trunk@318 6c5673fe-1810-88d6-992b-cd32ca31540c --- comictagger.py | 12 ++++++------ renamewindow.py | 10 +++++++++- settings.py | 6 ++++-- settingswindow.py | 4 ++++ settingswindow.ui | 11 +++++++++-- 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/comictagger.py b/comictagger.py index 1a745af..5890320 100755 --- a/comictagger.py +++ b/comictagger.py @@ -419,12 +419,12 @@ def process_file_cli( filename, opts, settings, match_results ): print msg_hdr + "Can't rename without series name" return - if ca.isZip(): - new_ext = ".cbz" - elif ca.isRar(): - new_ext = ".cbr" - else: - new_ext = None # default + new_ext = None # default + if settings.rename_extension_based_on_archive: + if ca.isZip(): + new_ext = ".cbz" + elif ca.isRar(): + new_ext = ".cbr" renamer = FileRenamer( md ) renamer.setTemplate( settings.rename_template ) diff --git a/renamewindow.py b/renamewindow.py index 163236f..0088e63 100644 --- a/renamewindow.py +++ b/renamewindow.py @@ -55,11 +55,19 @@ class RenameWindow(QtGui.QDialog): self.twList.setSortingEnabled(False) for ca in self.comic_archive_list: + + new_ext = None # default + if self.settings.rename_extension_based_on_archive: + if ca.isZip(): + new_ext = ".cbz" + elif ca.isRar(): + new_ext = ".cbr" + md = ca.readMetadata(self.data_style) if md.isEmpty: md = ca.metadataFromFilename() self.renamer.setMetadata( md ) - new_name = self.renamer.determineName( ca.path ) + new_name = self.renamer.determineName( ca.path, ext=new_ext ) row = self.twList.rowCount() self.twList.insertRow( row ) diff --git a/settings.py b/settings.py index 23c774c..f0f0dc5 100644 --- a/settings.py +++ b/settings.py @@ -85,7 +85,7 @@ class ComicTaggerSettings: self.rename_template = "%series% #%issue% (%year%)" self.rename_issue_number_padding = 3 self.rename_use_smart_string_cleanup = True - + self.rename_extension_based_on_archive = True def __init__(self): @@ -192,8 +192,9 @@ class ComicTaggerSettings: self.rename_issue_number_padding = self.config.getint( 'rename', 'rename_issue_number_padding' ) if self.config.has_option('rename', 'rename_use_smart_string_cleanup'): self.rename_use_smart_string_cleanup = self.config.getboolean( 'rename', 'rename_use_smart_string_cleanup' ) + if self.config.has_option('rename', 'rename_extension_based_on_archive'): + self.rename_extension_based_on_archive = self.config.getboolean( 'rename', 'rename_extension_based_on_archive' ) - def save( self ): if not self.config.has_section( 'settings' ): @@ -248,6 +249,7 @@ class ComicTaggerSettings: self.config.set( 'rename', 'rename_template', self.rename_template ) self.config.set( 'rename', 'rename_issue_number_padding', self.rename_issue_number_padding ) self.config.set( 'rename', 'rename_use_smart_string_cleanup', self.rename_use_smart_string_cleanup ) + self.config.set( 'rename', 'rename_extension_based_on_archive', self.rename_extension_based_on_archive ) with open( self.settings_file, 'wb') as configfile: self.config.write(configfile) diff --git a/settingswindow.py b/settingswindow.py index fd9b3c7..2debe83 100644 --- a/settingswindow.py +++ b/settingswindow.py @@ -141,6 +141,9 @@ class SettingsWindow(QtGui.QDialog): self.leIssueNumPadding.setText( str(self.settings.rename_issue_number_padding) ) if self.settings.rename_use_smart_string_cleanup: self.cbxSmartCleanup.setCheckState( QtCore.Qt.Checked ) + if self.settings.rename_extension_based_on_archive: + self.cbxChangeExtension.setCheckState( QtCore.Qt.Checked ) + def accept( self ): @@ -174,6 +177,7 @@ class SettingsWindow(QtGui.QDialog): self.settings.rename_template = str(self.leRenameTemplate.text()) self.settings.rename_issue_number_padding = int(self.leIssueNumPadding.text()) self.settings.rename_use_smart_string_cleanup = self.cbxSmartCleanup.isChecked() + self.settings.rename_extension_based_on_archive = self.cbxChangeExtension.isChecked() self.settings.save() QtGui.QDialog.accept(self) diff --git a/settingswindow.ui b/settingswindow.ui index 24b59e3..d7e9ead 100644 --- a/settingswindow.ui +++ b/settingswindow.ui @@ -22,7 +22,7 @@ - 0 + 4 @@ -354,7 +354,7 @@ 11 21 - 242 + 246 182 @@ -483,6 +483,13 @@ + + + + Change Extension Based On Archive Type + + +