View Single Post
Old 03-11-2024, 12:10 PM   #1
moldy
Enthusiast
moldy began at the beginning.
 
Posts: 43
Karma: 10
Join Date: Oct 2015
Device: Kindle
Search and Replace from a List

In Editor/Saved Searches I am trying to import a json file to search for multiple items and replace from a list. For example:

Code:
{
  "searches": [
    {
      "case_sensitive": false,
      "dot_all": false,
      "find": ["John", "Paul", "George", "Ringo"],
      "mode": "regex",
      "name": "B-S",
      "replace": ["Mick", "Kieth", "Ronnie", "Charlie"]
    }
  ],
  "version": 1
}
However when I run the search it gives the error:
calibre, version 7.6.0
Code:
ERROR: Unhandled exception: <b>TypeError</b>:unhashable type: 'list'

calibre 7.6  embedded-python: True
Windows-10-10.0.22631-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.22631')
Python 3.11.5
Windows: ('10', '10.0.22631', 'SP0', 'Multiprocessor Free')
Interface language: None
EXE path: C:\Program Files\Calibre2\calibre-parallel.exe
Successfully initialized third party plugins: Count Pages (1, 13, 5)
Traceback (most recent call last):
  File "calibre\gui2\tweak_book\boss.py", line 1111, in run_saved_searches
  File "calibre\gui2\tweak_book\search.py", line 1411, in run_search
  File "calibre\gui2\tweak_book\search.py", line 1411, in <listcomp>
  File "calibre\gui2\tweak_book\search.py", line 1312, in get_search_regex
  File "calibre\ebooks\conversion\search_replace.py", line 14, in compile_regular_expression
TypeError: unhashable type: 'list'
I have done something similar in the past but I lost all my Calibre stuff in a PC crash and I can't remember how I did it.
Can someone point me in the right direction please?
moldy is offline   Reply With Quote