Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key Error of "ID_NAME_MAP[message_info.type]" #46

Open
Erimus-Koo opened this issue Jan 5, 2023 · 5 comments
Open

Key Error of "ID_NAME_MAP[message_info.type]" #46

Erimus-Koo opened this issue Jan 5, 2023 · 5 comments

Comments

@Erimus-Koo
Copy link

Erimus-Koo commented Jan 5, 2023

Environments

Keynote: version 12.2.1 (7035.0.161)
keynote-parser: 1.12.2.0
python: 3.10.9

Error message

Reading Index/CalculationEngine.iwa...:  61%|███████████████████████████████████████████████████████████▍                                      | 103/170 [00:00<00:00, 2282.54it/s]
Traceback (most recent call last):
  File "/Users/erimus/.pyenv/versions/3.10.9/envs/test/lib/python3.10/site-packages/keynote_parser/codec.py", line 195, in from_buffer
    klass = ID_NAME_MAP[message_info.type]
KeyError: 6383

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/erimus/.pyenv/versions/3.10.9/envs/test/lib/python3.10/site-packages/keynote_parser/codec.py", line 43, in from_buffer
    chunk, data = IWACompressedChunk.from_buffer(data, filename)
  File "/Users/erimus/.pyenv/versions/3.10.9/envs/test/lib/python3.10/site-packages/keynote_parser/codec.py", line 107, in from_buffer
    archive, data = IWAArchiveSegment.from_buffer(data, filename)
  File "/Users/erimus/.pyenv/versions/3.10.9/envs/test/lib/python3.10/site-packages/keynote_parser/codec.py", line 197, in from_buffer
    raise NotImplementedError(
NotImplementedError: Don't know how to parse Protobuf message type 6383

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/erimus/.pyenv/versions/3.10.9/envs/test/lib/python3.10/site-packages/keynote_parser/file_utils.py", line 230, in process
    process_file(filename, handle, sink, replacements, raw, on_replace)
  File "/Users/erimus/.pyenv/versions/3.10.9/envs/test/lib/python3.10/site-packages/keynote_parser/file_utils.py", line 175, in process_file
    file = IWAFile.from_buffer(contents, filename)
  File "/Users/erimus/.pyenv/versions/3.10.9/envs/test/lib/python3.10/site-packages/keynote_parser/codec.py", line 49, in from_buffer
    raise_from(ValueError("Failed to deserialize " + filename), e)
  File "/Users/erimus/.pyenv/versions/3.10.9/envs/test/lib/python3.10/site-packages/future/utils/__init__.py", line 403, in raise_from
    exec(execstr, myglobals, mylocals)
  File "<string>", line 1, in <module>
ValueError: Failed to deserialize Index/CalculationEngine.iwa

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/erimus/.pyenv/versions/test/bin/keynote-parser", line 8, in <module>
    sys.exit(main())
  File "/Users/erimus/.pyenv/versions/3.10.9/envs/test/lib/python3.10/site-packages/keynote_parser/command_line.py", line 121, in main
    args.func(**vars(args))
  File "/Users/erimus/.pyenv/versions/3.10.9/envs/test/lib/python3.10/site-packages/keynote_parser/command_line.py", line 25, in unpack_command
    process(input, output or input.replace('.key', ''), replacements=parse_replacements(**kwargs))
  File "/Users/erimus/.pyenv/versions/3.10.9/envs/test/lib/python3.10/site-packages/keynote_parser/file_utils.py", line 232, in process
    raise ValueError("Failed to process file %s due to: %s" % (filename, e))
ValueError: Failed to process file Index/CalculationEngine.iwa due to: Failed to deserialize Index/CalculationEngine.iw
@Erimus-Koo
Copy link
Author

I've found out the problem page and output a "error_sample.key" file, and do you need it?

@Erimus-Koo
Copy link
Author

The problems happened while some objects used(and error key):

  • 6383: table
  • 10000: 2d donut chart

@Erimus-Koo
Copy link
Author

Erimus-Koo commented Jan 6, 2023

And there's another problem is, after once used the "replace" command, it looks like a codec error occurred.
Here is the console:

    _file.filename = _file.filename.encode("cp437").decode("utf-8")
  File "/Users/erimus/.pyenv/versions/3.10.9/lib/python3.10/encodings/cp437.py", line 12, in encode
    return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode characters in position 10-16: character maps to <undefined>
  • Before using the "replace" command, unpack did work.
  • The first time use "replace", success.
  • And use "replace" or "unpack" again, above error occurred.
  • It happens while the image name contains Chinese characters.

@amasmiller
Copy link

I am also seeing the error when parsing the identifier 6383, which appears to be the result of having a table in the file. Python 3.8.2, keynote-parser v1.12.2.0, Keynote v12.2.1.

Example .key file generating the error is attached (attached in .zip format because Github is cranky about .key files).

example.zip

@amasmiller
Copy link

I fixed the issues I was having by making a few modifications to codec.py and mapping.py. See https://github.com/psobot/keynote-parser/pull/48/files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants