Skip to main content

Library for working with Valve's VDF text format

Project description

Latest version released on PyPi MIT License Test coverage Build status of master branch

VDF is Valve’s KeyValue text file format

https://developer.valvesoftware.com/wiki/KeyValues

The module works just like json to convert VDF to a dict, and vise-versa.

Poblems & solutions

  • There are known files that contain duplicate keys. This can be solved by creating a class inherating from dict and implementing a way to handle duplicate keys.

  • By default the module uses dict, so key order is preserved. If key order is important then I suggest using collections.OrderedDict. See example.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vdf-1.4.tar.gz (3.9 kB view details)

Uploaded Source

File details

Details for the file vdf-1.4.tar.gz.

File metadata

  • Download URL: vdf-1.4.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for vdf-1.4.tar.gz
Algorithm Hash digest
SHA256 4fedf967496542ebc043c3a581f570eee001cba22e225aca8a4dbf47dafce3bb
MD5 7ed666a355e6a50bc1209de18c6074c3
BLAKE2b-256 07a710827a733614cefffd8fcb3798cdc3afcc1402ea01c246338207c8bdbb2e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page