Library for working with Valve's VDF text format
Project description
VDF is Valve’s KeyValue text file format
https://developer.valvesoftware.com/wiki/KeyValues
The module works just like json for (de)serilization to and from VDF.
Problems & solutions
There are known files that contain duplicate keys. This can be solved by creating a class inheriting from dict and implementing a way to handle duplicate keys. See example implementation of DuplicateOrderedDict.
By default deserialization will return a dict, which doesn’t preserve nor guarantee key order due to hash randomization. If key order is important then I suggest using collections.OrderedDict as mapper. See example below.
Install
You can grab the latest release from https://pypi.python.org/pypi/vdf or via pip
pip install vdf
Example usage
import vdf
# parsing vdf from file or string
d = vdf.load(open('file.txt'))
d = vdf.loads(vdf_text)
d = vdf.parse(open('file.txt'))
d = vdf.parse(vdf_text)
# dumping dict as vdf to string
vdf_text = vdf.dumps(d)
indented_vdf = vdf.dumps(d, pretty=True)
# dumping dict as vdf to file
vdf.dump(d, open('file2.txt','w'), pretty=True)
Using OrderedDict to preserve key order.
import vdf
from collections import OrderedDict
# parsing vdf from file or string
d = vdf.load(open('file.txt'), mapper=OrderedDict)
d = vdf.loads(vdf_text, mapper=OrderedDict)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vdf-1.9.tar.gz.
File metadata
- Download URL: vdf-1.9.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e4cc283e989ebc8f4e7d10e065980520b3ecf1cff2dfe44cc82fc40b93e8ff3
|
|
| MD5 |
03c5e0ff5a3449446c922f475fed3970
|
|
| BLAKE2b-256 |
0904d22962f9753e17045a70e0f696a4ae54fe3cdd6f393ac6c26dde86a73021
|
File details
Details for the file vdf-1.9-py2.py3-none-any.whl.
File metadata
- Download URL: vdf-1.9-py2.py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7014f2197207619d0b6ba9e6a7e2d9764483dc99d8135ca8ef551478a51c559d
|
|
| MD5 |
2de295e655436483adf8fa0f8eadc07e
|
|
| BLAKE2b-256 |
a2b8e2452ec3b506278f2ce9420224a7be5c2900cbe3afc5a4a440cbe4db9a67
|