{"id":19724886,"url":"https://github.com/valvepython/vdf","last_synced_at":"2025-04-04T09:08:39.141Z","repository":{"id":30663683,"uuid":"34219417","full_name":"ValvePython/vdf","owner":"ValvePython","description":"📜 Package for working with Valve's text and binary KeyValue format","archived":false,"fork":false,"pushed_at":"2024-06-30T21:49:30.000Z","size":119,"stargazers_count":177,"open_issues_count":23,"forks_count":36,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-28T08:05:33.907Z","etag":null,"topics":["hacktoberfest","keyvalue","parser","python","serializer","steam","valve","vdf"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/vdf/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"xMAnton/ADPassword","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ValvePython.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-04-19T18:47:22.000Z","updated_at":"2025-03-25T02:12:27.000Z","dependencies_parsed_at":"2024-01-03T06:52:08.039Z","dependency_job_id":"ef9b38af-e9dd-480b-85dc-5fcc852b658e","html_url":"https://github.com/ValvePython/vdf","commit_stats":{"total_commits":134,"total_committers":9,"mean_commits":14.88888888888889,"dds":0.5,"last_synced_commit":"d76292623e326fb165fe3bdb684832cdf30959d4"},"previous_names":["rossengeorgiev/vdf-python"],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValvePython%2Fvdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValvePython%2Fvdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValvePython%2Fvdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValvePython%2Fvdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ValvePython","download_url":"https://codeload.github.com/ValvePython/vdf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247149501,"owners_count":20891954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","keyvalue","parser","python","serializer","steam","valve","vdf"],"created_at":"2024-11-11T23:27:27.828Z","updated_at":"2025-04-04T09:08:39.118Z","avatar_url":"https://github.com/ValvePython.png","language":"Python","readme":"| |pypi| |license| |coverage| |master_build|\n| |sonar_maintainability| |sonar_reliability| |sonar_security|\n\nPure python module for (de)serialization to and from VDF that works just like ``json``.\n\nTested and works on ``py2.7``, ``py3.3+``, ``pypy`` and ``pypy3``.\n\nVDF is Valve's KeyValue text file format\n\nhttps://developer.valvesoftware.com/wiki/KeyValues\n\n| Supported versions: ``kv1``\n| Unsupported: ``kv2`` and ``kv3``\n\nInstall\n-------\n\nYou can grab the latest release from https://pypi.org/project/vdf/ or via ``pip``\n\n.. code:: bash\n\n    pip install vdf\n\nInstall the current dev version from ``github``\n\n.. code:: bash\n\n    pip install git+https://github.com/ValvePython/vdf\n\n\nProblems \u0026 solutions\n--------------------\n\n- There are known files that contain duplicate keys. This is supported the format and\n  makes mapping to ``dict`` impossible. For this case the module provides ``vdf.VDFDict``\n  that can be used as mapper instead of ``dict``. See the example section for details.\n\n- By default de-serialization will return a ``dict``, which doesn't preserve nor guarantee\n  key order on Python versions prior to 3.6, due to `hash randomization`_. If key order is\n  important on old Pythons, I suggest using ``collections.OrderedDict``, or ``vdf.VDFDict``.\n\nExample usage\n-------------\n\nFor text representation\n\n.. code:: python\n\n    import vdf\n\n    # parsing vdf from file or string\n    d = vdf.load(open('file.txt'))\n    d = vdf.loads(vdf_text)\n    d = vdf.parse(open('file.txt'))\n    d = vdf.parse(vdf_text)\n\n    # dumping dict as vdf to string\n    vdf_text = vdf.dumps(d)\n    indented_vdf = vdf.dumps(d, pretty=True)\n\n    # dumping dict as vdf to file\n    vdf.dump(d, open('file2.txt','w'), pretty=True)\n\n\nFor binary representation\n\n.. code:: python\n\n    d = vdf.binary_loads(vdf_bytes)\n    b = vdf.binary_dumps(d)\n\n    # alternative format - VBKV\n\n    d = vdf.binary_loads(vdf_bytes, alt_format=True)\n    b = vdf.binary_dumps(d, alt_format=True)\n\n    # VBKV with header and CRC checking\n\n    d = vdf.vbkv_loads(vbkv_bytes)\n    b = vdf.vbkv_dumps(d)\n\nUsing an alternative mapper\n\n.. code:: python\n\n  d = vdf.loads(vdf_string, mapper=collections.OrderedDict)\n  d = vdf.loads(vdf_string, mapper=vdf.VDFDict)\n\n``VDFDict`` works much like the regular ``dict``, except it handles duplicates and remembers\ninsert order. Additionally, keys can only be of type ``str``. The most important difference\nis that when trying to assigning a key that already exist it will create a duplicate instead\nof reassign the value to the existing key.\n\n.. code:: python\n\n  \u003e\u003e\u003e d = vdf.VDFDict()\n  \u003e\u003e\u003e d['key'] = 111\n  \u003e\u003e\u003e d['key'] = 222\n  \u003e\u003e\u003e d\n  VDFDict([('key', 111), ('key', 222)])\n  \u003e\u003e\u003e d.items()\n  [('key', 111), ('key', 222)]\n  \u003e\u003e\u003e d['key']\n  111\n  \u003e\u003e\u003e d[(0, 'key')]  # get the first duplicate\n  111\n  \u003e\u003e\u003e d[(1, 'key')]  # get the second duplicate\n  222\n  \u003e\u003e\u003e d.get_all_for('key')\n  [111, 222]\n\n  \u003e\u003e\u003e d[(1, 'key')] = 123  # reassign specific duplicate\n  \u003e\u003e\u003e d.get_all_for('key')\n  [111, 123]\n\n  \u003e\u003e\u003e d['key'] = 333\n  \u003e\u003e\u003e d.get_all_for('key')\n  [111, 123, 333]\n  \u003e\u003e\u003e del d[(1, 'key')]\n  \u003e\u003e\u003e d.get_all_for('key')\n  [111, 333]\n  \u003e\u003e\u003e d[(1, 'key')]\n  333\n\n  \u003e\u003e\u003e print vdf.dumps(d)\n  \"key\" \"111\"\n  \"key\" \"333\"\n\n  \u003e\u003e\u003e d.has_duplicates()\n  True\n  \u003e\u003e\u003e d.remove_all_for('key')\n  \u003e\u003e\u003e len(d)\n  0\n  \u003e\u003e\u003e d.has_duplicates()\n  False\n\n\n.. |pypi| image:: https://img.shields.io/pypi/v/vdf.svg?style=flat\u0026label=latest%20version\n    :target: https://pypi.org/project/vdf/\n    :alt: Latest version released on PyPi\n\n.. |license| image:: https://img.shields.io/pypi/l/vdf.svg?style=flat\u0026label=license\n    :target: https://pypi.org/project/vdf/\n    :alt: MIT License\n\n.. |coverage| image:: https://img.shields.io/coveralls/ValvePython/vdf/master.svg?style=flat\n    :target: https://coveralls.io/r/ValvePython/vdf?branch=master\n    :alt: Test coverage\n\n.. |sonar_maintainability| image:: https://sonarcloud.io/api/project_badges/measure?project=ValvePython_vdf\u0026metric=sqale_rating\n    :target: https://sonarcloud.io/dashboard?id=ValvePython_vdf\n    :alt: SonarCloud Rating\n\n.. |sonar_reliability| image:: https://sonarcloud.io/api/project_badges/measure?project=ValvePython_vdf\u0026metric=reliability_rating\n    :target: https://sonarcloud.io/dashboard?id=ValvePython_vdf\n    :alt: SonarCloud Rating\n\n.. |sonar_security| image:: https://sonarcloud.io/api/project_badges/measure?project=ValvePython_vdf\u0026metric=security_rating\n    :target: https://sonarcloud.io/dashboard?id=ValvePython_vdf\n    :alt: SonarCloud Rating\n\n.. |master_build| image:: https://github.com/ValvePython/vdf/workflows/Tests/badge.svg?branch=master\n    :target: https://github.com/ValvePython/vdf/actions?query=workflow%3A%22Tests%22+branch%3Amaster\n    :alt: Build status of master branch\n\n.. _DuplicateOrderedDict: https://github.com/rossengeorgiev/dota2_notebooks/blob/master/DuplicateOrderedDict_for_VDF.ipynb\n\n.. _hash randomization: https://docs.python.org/2/using/cmdline.html#envvar-PYTHONHASHSEED\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalvepython%2Fvdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvalvepython%2Fvdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalvepython%2Fvdf/lists"}