Skip to main content

Library for working with Valve's VDF text format

Project description

VDF 3

Pure python module for (de)serialization to and from VDF that works just like json. VDF is Valve's KeyValue text file format

Supports:

  • kv1

Installation

Python 3.7 or higher is required

pip install git+https://github.com/ValvePython/vdf

Example usage

For text representation.

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)

For binary representation

d = vdf.binary_loads(vdf_bytes)
b = vdf.binary_dumps(d)

# alternative format - VBKV

d = vdf.binary_loads(vdf_bytes, alt_format=True)
b = vdf.binary_dumps(d, alt_format=True)

# VBKV with header and CRC checking

d = vdf.vbkv_loads(vbkv_bytes)
b = vdf.vbkv_dumps(d)

Using an alternative mapper

d = vdf.loads(vdf_string, mapper=collections.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

vdf3-3.1.1.1.tar.gz (98.3 kB view hashes)

Uploaded Source

Built Distribution

vdf3-3.1.1.1-cp39-cp39-macosx_10_9_x86_64.whl (187.5 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

Supported by

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