Added setting for rename to use the archive type

git-svn-id: http://comictagger.googlecode.com/svn/trunk@318 6c5673fe-1810-88d6-992b-cd32ca31540c
This commit is contained in:
beville 2013-01-21 01:07:45 +00:00
parent f2b1db5479
commit d26441306a
5 changed files with 32 additions and 11 deletions

View File

@ -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 )

View File

@ -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 )

View File

@ -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)

View File

@ -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)

View File

@ -22,7 +22,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>4</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -354,7 +354,7 @@
<rect>
<x>11</x>
<y>21</y>
<width>242</width>
<width>246</width>
<height>182</height>
</rect>
</property>
@ -483,6 +483,13 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="cbxChangeExtension">
<property name="text">
<string>Change Extension Based On Archive Type</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>