noriah / PyVDF

Python Library for Reading and Writing VDFs (Valve Data File)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested groups with duplicate keys trivially do not work

GiovanH opened this issue · comments

Input file demo.vdf:

"controller_mappings"
{
	"group"
	{
		"id"		"0"
	}
	"group"
	{
		"id"		"1"
	}
}

Test script:

import PyVDF
with open("demo.vdf") as fp:
    v = PyVDF.PyVDF(data=fp.read())
    print(type(v))
    print(type(v['controller_mappings']))
    print(v.toString())

Expected output:
(demo.vdf)

Actual output:

<class 'PyVDF.PyVDF'>
<class 'dict'>
"controller_mappings"
{
        "group"
        {
                "id"            "1"
        }
}

Not only is this incorrect, but no error is thrown: the resulting data structure is silently malformed and passed along.

Thanks for leaving a bug report. I won't have bandwidth to work on this for the foreseeable future. If you wish to submit a PR, I'd gladly review it.

If you need this to work now, I'd recommend you make use of a more recently maintained library, like https://github.com/ValvePython/vdf

Thanks!