★ wanayoo — archive 1999 https://github.com/ValvePython/vdf/pull/25Nouvelle recherche | Portail wanayoo
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

Fix dota2-items parse error: <TypeError: 'str' object does not support item assignment> #25

Open
wants to merge 1 commit into
base: master
from

Conversation

@SeRi0uS007
Copy link

@SeRi0uS007 SeRi0uS007 commented Jan 7, 2020

I have an error when i parse items_game.txt from this link: GameTracking-Dota2

Traceback:

Traceback (most recent call last):
  File "C:\Users\***\AppData\Local\Programs\Python\Python38\lib\asyncio\runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "C:\Users\***\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 612, in run_until_complete
    return future.result()
  File "C:/Users/***/***/***/Python/NamePicker/main.py", line 71, in main
    await fetcher.fetch_all_sources()
  File "C:/Users/***/***/***/Python/NamePicker/main.py", line 37, in fetch_all_sources
    tasks_response = await asyncio.gather(*fetch_tasks)
  File "C:/Users/***/***/***/Python/NamePicker/main.py", line 61, in fetch_result
    result = vdf.load(fp, mapper=vdf.VDFDict)
  File "C:\Users\***\***\***\Python\NamePicker\venv\lib\site-packages\vdf\__init__.py", line 191, in load
    return parse(fp, **kwargs)
  File "C:\Users\***\***\***\Python\NamePicker\venv\lib\site-packages\vdf\__init__.py", line 158, in parse
    stack[-1][key] = _unescape(val) if escaped else val
TypeError: 'str' object does not support item assignment

I've searched for the problem and found out that the error occurs on the 557707 line in this file. I think that error occurs because the value has become a dict (before that it is clear that value is a str)

Maybe the solution is not perfect, but for me - it completely solves the problem with parsing

@rossengeorgiev
Copy link
Contributor

@rossengeorgiev rossengeorgiev commented Jan 10, 2020

I guess that avoids the exception, but you should really be using VDFDict to handle this duplicates properly. The issue is these modifier structures in the file.

557689                 "asset_modifier"
557690                 {
557691                     "type"      "entity_clientside_model"
557692                     "asset"     "npc_dota_creep_badguys_melee_upgraded"
557693                     "modifier"      "models/creeps/lane_creeps/creep_bad_melee/creep_bad_melee_cavern.vmdl"
557694                 }
557695                 "asset_modifier"
557696                 {
557697                     "type"      "entity_clientside_model"
557698                     "asset"     "npc_dota_creep_badguys_melee_upgraded_mega"
557699                     "modifier"      "models/creeps/lane_creeps/creep_bad_melee/creep_bad_melee_cavern_mega.vmdl"
557700                 }
557701                 "asset_modifier"
557702                 {
557703                     "type"      "portrait_game"
557704                     "asset"     "npc_dota_creep_badguys_melee"
557705                     "modifier"
557706                     {
557707                         "PortraitLightPosition"     "29.379999 12.250000 162.360001"
557708                         "PortraitLightAngles"       "73.760002 10.190000 0.000000"
557709                         "PortraitLightFOV"      "75"
557710                         "PortraitLightDistance"     "115"
557711                         "PortraitLightColor"        "191 240 254"

I guess with merge_keys this will result in a mess :)

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

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.