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

Fail to parse some tenhou records. #25

Open
canuse opened this issue Nov 27, 2019 · 3 comments
Open

Fail to parse some tenhou records. #25

canuse opened this issue Nov 27, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@canuse
Copy link
Contributor

canuse commented Nov 27, 2019

When parsing some files using from_file, an xml'Namespace' object has no attribute 'n0' (sometimes n1) error occured:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\canuse\PycharmProjects\auto-white-reimu\mahjong\record\reader.py", line 187, in from_file
    return TenhouRecord(next(ET.parse(file).iter()))
  File "C:\Users\canuse\PycharmProjects\auto-white-reimu\mahjong\record\reader.py", line 140, in __init__
    [meta.UN.n0, meta.UN.n1, meta.UN.n2, meta.UN.n3],
AttributeError: 'Namespace' object has no attribute 'n1'

A total of 18469 file was processed and this error occured 98 times ( with 'n0' 83 times and 'n1' 15 times)

For example,
2019010115gm-00a9-0000-21b95613.xml raised an 'n1' error and 2019010202gm-00a9-0000-3142addc.xml raised an 'n0' error
2019010115gm-00a9-0000-21b95613.zip
2019010202gm-00a9-0000-3142addc.zip

@Ledenel Ledenel added the bug Something isn't working label Nov 27, 2019
@Ledenel
Copy link
Owner

Ledenel commented Nov 27, 2019

This example shows that there should be some internel wrong assumption made by me. Could you please provide the tenhou.net paifu link, to visualize that what is really happening during the game?

@canuse
Copy link
Contributor Author

canuse commented Nov 27, 2019

@Ledenel
Copy link
Owner

Ledenel commented Nov 27, 2019

I've not found anything useful in visualization, but for mesages below:

    <GO type="169" lobby="0" />
    <UN n0="%E3%81%84%E3%81%AA%E3%81%97%E3%82%93%E3%80%82" n1="%42%41%52%34" n2="%E3%81%82%E3%81%A1%E3%82%87%E3%83%BC" n3="%E6%81%A9%E7%94%B0%E5%B8%8C" dan="17,16,16,17" rate="2197.33,2149.89,2024.85,2159.75" sx="M,M,M,F" />
    <TAIKYOKU oya="0" />
    <BYE who="0" />
    <UN n0="%E3%81%84%E3%81%AA%E3%81%97%E3%82%93%E3%80%82" />
    <INIT seed="0,0,0,3,0,8" ten="250,250,250,250" oya="0" hai0="103,107,95,48,32,126,108,101,100,14,135,9,61" hai1="5,71,113,53,55,22,36,125,105,132,128,79,52" hai2="81,121,6,35,70,18,111,83,110,87,93,29,34" hai3="66,20,91,92,94,104,123,33,21,96,57,45,43" />

You could see that player 0 has disconnected and immediately reconnected before the first name (maybe some network issue)

The issue is, when treat event before INIT as game meta settings I assumed that each element will only appeared once, which is wrong since above UN appeared twice.

setattr(namespace, message.tag, Namespace(**message.attrib))

Here, when reducing multiple elements, this will replace the old attributes when same element re-appeared. add some condition to merge may solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants