All Projects → ValvePython → vdf

ValvePython / vdf

Licence: MIT license
📜 Package for working with Valve's text and binary KeyValue format

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to vdf

vdf-parser
📜 Libraries to (de)serialize Valve's KeyValue format (VDF) in various languages
Stars: ✭ 70 (-52.05%)
Mutual labels:  serializer, valve, vdf, keyvalue
Gameloop.Vdf
A fast, easy-to-use Valve Data Format parser for .NET
Stars: ✭ 60 (-58.9%)
Mutual labels:  steam, vdf, keyvalue
vdf
A Lexer and Parser for Valves Data Format (known as vdf) written in Go
Stars: ✭ 30 (-79.45%)
Mutual labels:  steam, valve, vdf
Vac Bypass
Valve Anti-Cheat bypass written in C.
Stars: ✭ 241 (+65.07%)
Mutual labels:  steam, valve
Valveresourceformat
🔬 Valve's Source 2 resource file format parser and decompiler
Stars: ✭ 638 (+336.99%)
Mutual labels:  steam, valve
Archisteamfarm
C# application with primary purpose of idling Steam cards from multiple accounts simultaneously.
Stars: ✭ 7,219 (+4844.52%)
Mutual labels:  steam, valve
HammerPatch
Modification of Source Valve Hammer Editor to fix some issues. Fixes brush vertex precision loss.
Stars: ✭ 49 (-66.44%)
Mutual labels:  steam, valve
Vpk
📦 Open, Search, Extract and Create VPKs in python
Stars: ✭ 79 (-45.89%)
Mutual labels:  steam, valve
Steamworks
Exposing SteamWorks functions to SourcePawn.
Stars: ✭ 70 (-52.05%)
Mutual labels:  steam, valve
Vac Bypass Loader
Loader for VAC Bypass written in C.
Stars: ✭ 204 (+39.73%)
Mutual labels:  steam, valve
Vac Hooks
Hook WinAPI functions used by Valve Anti-Cheat. Log calls and intercept arguments & return values. DLL written in C.
Stars: ✭ 103 (-29.45%)
Mutual labels:  steam, valve
Uwphook
🔗 Add your Windows Store or UWP games to Steam
Stars: ✭ 566 (+287.67%)
Mutual labels:  steam, valve
Steamtracking
🕵 Tracking things, so you don't have to
Stars: ✭ 542 (+271.23%)
Mutual labels:  steam, valve
Depressurizer
A Steam library categorizing tool.
Stars: ✭ 1,008 (+590.41%)
Mutual labels:  steam, valve
Steam
☁️ Python package for interacting with Steam
Stars: ✭ 489 (+234.93%)
Mutual labels:  steam, valve
Steamcmd Autoupdate Any Gameserver
Windows SteamCMD to autoupdate and install any game server steam cmd settings configurable lots of useful features. This batch script will keep your game servers automaticly updated updating intervals announce the server is shutting down for updates etc all configurable.
Stars: ✭ 77 (-47.26%)
Mutual labels:  steam, valve
Async Gamequery Lib
A high-performance java game query library designed for steam/source based games and others
Stars: ✭ 88 (-39.73%)
Mutual labels:  steam, valve
Dota2
🐸 Python package for interacting with Dota 2 Game Coordinator
Stars: ✭ 129 (-11.64%)
Mutual labels:  steam, valve
Steam-Apps-Management-API
A basic Steam Application Management API and Valve Data Format (VDF) reader/writer.
Stars: ✭ 24 (-83.56%)
Mutual labels:  steam, vdf
Steamid.php
🆔 PHP library to work with SteamIDs
Stars: ✭ 83 (-43.15%)
Mutual labels:  steam, valve
Latest version released on PyPi MIT License Test coverage Build status of master branch
SonarCloud Rating SonarCloud Rating SonarCloud Rating

Pure python module for (de)serialization to and from VDF that works just like json.

Tested and works on py2.7, py3.3+, pypy and pypy3.

VDF is Valve's KeyValue text file format

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

Supported versions: kv1
Unsupported: kv2 and kv3

Install

You can grab the latest release from https://pypi.org/project/vdf/ or via pip

pip install vdf

Install the current dev version from github

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

Problems & solutions

  • There are known files that contain duplicate keys. This is supported the format and makes mapping to dict impossible. For this case the module provides vdf.VDFDict that can be used as mapper instead of dict. See the example section for details.
  • By default de-serialization will return a dict, which doesn't preserve nor guarantee key order on Python versions prior to 3.6, due to hash randomization. If key order is important on old Pythons, I suggest using collections.OrderedDict, or vdf.VDFDict.

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

VDFDict works much like the regular dict, except it handles duplicates and remembers insert order. Additionally, keys can only be of type str. The most important difference is that when trying to assigning a key that already exist it will create a duplicate instead of reassign the value to the existing key.

>>> d = vdf.VDFDict()
>>> d['key'] = 111
>>> d['key'] = 222
>>> d
VDFDict([('key', 111), ('key', 222)])
>>> d.items()
[('key', 111), ('key', 222)]
>>> d['key']
111
>>> d[(0, 'key')]  # get the first duplicate
111
>>> d[(1, 'key')]  # get the second duplicate
222
>>> d.get_all_for('key')
[111, 222]

>>> d[(1, 'key')] = 123  # reassign specific duplicate
>>> d.get_all_for('key')
[111, 123]

>>> d['key'] = 333
>>> d.get_all_for('key')
[111, 123, 333]
>>> del d[(1, 'key')]
>>> d.get_all_for('key')
[111, 333]
>>> d[(1, 'key')]
333

>>> print vdf.dumps(d)
"key" "111"
"key" "333"

>>> d.has_duplicates()
True
>>> d.remove_all_for('key')
>>> len(d)
0
>>> d.has_duplicates()
False
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].