Metadata search and replace: Allow replacing the entire set of identifiers instead of only a specific identifier when doing a search and replace. To do this, choose a source field other than identifiers and set the destination identifier type to: *

This commit is contained in:
Kovid Goyal 2013-03-05 17:05:08 +05:30
commit 8585c580c7
2 changed files with 14 additions and 5 deletions

View File

@ -712,7 +712,8 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
dest_mode = self.replace_mode.currentIndex()
if self.destination_field_fm['is_csp']:
if not unicode(self.s_r_dst_ident.text()):
dest_ident = unicode(self.s_r_dst_ident.text())
if not dest_ident or (src == 'identifiers' and dest_ident == '*'):
raise Exception(_('You must specify a destination identifier type'))
if self.destination_field_fm['is_multiple']:
@ -816,13 +817,18 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
# convert the colon-separated pair strings back into a dict,
# which is what set_identifiers wants
dst_id_type = unicode(self.s_r_dst_ident.text())
if dst_id_type:
if dst_id_type and dst_id_type != '*':
v = ''.join(val)
ids = mi.get(dest)
ids[dst_id_type] = v
val = ids
else:
val = dict([(t.split(':')) for t in val])
try:
val = dict([(t.split(':')) for t in val])
except:
raise Exception(_('Invalid identifier string. It must be a '
'comma-separated list of pairs of '
'strings separated by a colon'))
else:
val = self.s_r_replace_mode_separator().join(val)
if dest == 'title' and len(val) == 0:

View File

@ -504,7 +504,7 @@ from the value in the box</string>
<item>
<widget class="QCheckBox" name="restore_original">
<property name="toolTip">
<string>When doing a same format to same format conversion,
<string>When doing a same format to same format conversion,
for e.g., EPUB to EPUB, calibre saves the original EPUB
as ORIGINAL_EPUB. This option tells calibre to restore
the EPUB from ORIGINAL_EPUB. Useful if you did a bulk
@ -1006,7 +1006,10 @@ not multiple and the destination field is multiple</string>
</sizepolicy>
</property>
<property name="toolTip">
<string>Choose which identifier type to operate upon</string>
<string>&lt;p&gt;Choose which identifier type to operate upon. When the
source field is something other than 'identifiers' you can enter
a * if you want to replace the entire set of identifiers with
the result of the search/replace.&lt;/p&gt;</string>
</property>
</widget>
</item>