mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 13:43:39 +02:00
fix CLI completion for ebook-convert
msgpack.loads will produce mutable, unhashable lists by default when unpacking values that were originally saved as dicts with tuple keys. Which ebook-convert-complete does. This results in errors when trying to reassemble the dict. Fix by allowing our msgpack wrapper to forward arguments, and by having ebook-convert-complete unpack lists as tuples.
This commit is contained in:
parent
b42963af61
commit
5ba0e29dd0
2 changed files with 5 additions and 5 deletions
|
|
@ -117,7 +117,7 @@ def __init__(self, comp_line, pos):
|
|||
self.previous = words[-2 if prefix else -1]
|
||||
from calibre.utils.serialize import msgpack_loads
|
||||
self.cache = msgpack_loads(open(os.path.join(sys.resources_location,
|
||||
'ebook-convert-complete.calibre_msgpack'), 'rb').read())
|
||||
'ebook-convert-complete.calibre_msgpack'), 'rb').read(), use_list=False)
|
||||
self.complete(wc)
|
||||
|
||||
def complete(self, wc):
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ def encoder(obj):
|
|||
return encoder
|
||||
|
||||
|
||||
def msgpack_dumps(obj):
|
||||
def msgpack_dumps(obj, **kw):
|
||||
import msgpack
|
||||
return msgpack.packb(obj, default=create_encoder(), use_bin_type=True)
|
||||
return msgpack.packb(obj, default=create_encoder(), use_bin_type=True, **kw)
|
||||
|
||||
|
||||
def json_dumps(data, **kw):
|
||||
|
|
@ -107,9 +107,9 @@ def msgpack_decoder(code, data):
|
|||
return decoders[code](msgpack_loads(data), False)
|
||||
|
||||
|
||||
def msgpack_loads(dump):
|
||||
def msgpack_loads(dump, **kw):
|
||||
import msgpack
|
||||
return msgpack.unpackb(dump, ext_hook=msgpack_decoder, raw=False)
|
||||
return msgpack.unpackb(dump, ext_hook=msgpack_decoder, raw=False, **kw)
|
||||
|
||||
|
||||
def json_loads(data):
|
||||
|
|
|
|||
Loading…
Reference in a new issue