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

construct.core.MappingError - Same error consistently #77

Closed
benglle opened this issue Apr 30, 2022 · 2 comments
Closed

construct.core.MappingError - Same error consistently #77

benglle opened this issue Apr 30, 2022 · 2 comments

Comments

@benglle
Copy link

benglle commented Apr 30, 2022

I keep getting the following error with any example I attempt using. I have nothing really to offer other than pointing out the obvious that the error I'm getting is occurring when I call the methods from mgz. I've tried to get around this by installing the latest version on github, and through pypi. Both versions of this library seem to have the exact same error which is shown below after a few notes:

Notes: I've tried both having the aoe2 save game file in the same folder as my python program (in case the spaces in the directory cause any issue), and I've also used the directory of file in the actual aoe2 save folder.

Traceback (most recent call last):
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 2844, in _decode
    return self.decoding[obj]
KeyError: 8

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 2784, in _parse
    return self.subcon._parse(stream, context, path)
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 311, in _parse
    return self._decode(self.subcon._parse(stream, context, path), context)
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 2849, in _decode
    raise MappingError("no decoding mapping for %r" % (obj,))
construct.core.MappingError: no decoding mapping for 8

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\barke\OneDrive\Desktop\aoe2_stats_parser\parser.py", line 8, in <module>
    header.parse_stream(data)
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 171, in parse_stream
    return self._parse(stream, context2, "(parsing)")
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 295, in _parse
    return self.subcon._parse(stream, context, path)
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 295, in _parse
    return self.subcon._parse(stream, context, path)
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\mgz\util.py", line 58, in _parse
    return self.subcon._parse(new_stream, context, path)
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 357, in _parse
    return self.subcon.parse(data, context)
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 158, in parse
    return self.parse_stream(BytesIO(data), context, **kw)
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 171, in parse_stream
    return self._parse(stream, context2, "(parsing)")
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 867, in _parse
    subobj = sc._parse(stream, context, path)
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 2784, in _parse
    return self.subcon._parse(stream, context, path)
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 1594, in _parse
    obj = self.cases.get(key, self.default)._parse(stream, context, path)
  File "C:\Users\barke\AppData\Local\Programs\Python\Python310\lib\site-packages\construct\core.py", line 2788, in _parse
    raise e.__class__("%s\n    %s" % (e, path))
construct.core.MappingError: no decoding mapping for 8
    (parsing) -> de -> de

Here's my code that I'm using, although if I use any of the examples - none of them work.

import os
from mgz import header, body

PATH = 'example.aoe2record'

with open(PATH, 'rb') as data:
    eof = os.fstat(data.fileno()).st_size
    header.parse_stream(data)
    body.meta.parse_stream(data)
    while data.tell() < eof:
        body.operation.parse_stream(data)
@benglle
Copy link
Author

benglle commented Apr 30, 2022

I've identified the issue, which is that the new DLC for aoe2 means this latest version is not compatible yet. I've tried a save example given, and it works perfectly.

@benglle benglle closed this as completed Apr 30, 2022
@happyleavesaoc
Copy link
Owner

FYI, new DLC is now supported.

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