Name | keyvalues3 JSON |
Version |
0.2
JSON |
| download |
home_page | None |
Summary | Read and write Valve's KeyValues3 format |
upload_time | 2025-01-18 16:03:38 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.11 |
license | None |
keywords |
parser
kv3
keyvalues
keyvalues3
valve
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
## keyvalues3
KeyValues3 is a Valve developed data format. It is similar in structure to JSON, but supports binary encodings, versioning, and data annotations. The text syntax also has some minor ergonomic improvements (support for single- and multi-line comments, trailing commas, and multi-line strings.)
## Usage
```py
import keyvalues3 as kv3
bt_config = kv3.read("tests/documents/bt_config.kv3")
>>> bt_config.keys()
dict_keys(['default', 'low', 'fair', 'normal', 'tough', 'hard', 'very_hard', 'expert', 'elite'])
>>> bt_config["elite"]["reaction_time"]
0.12
```
```py
# The root value is most of the time a dict
>>> type(bt_config.value)
<class 'dict'>
>>> bt_config.original_encoding
Encoding(name='text', version=UUID('e21c7f3c-8a33-41c5-9977-a76d3a32aa0d'))
>>> bt_config.format
Format(name='generic', version=UUID('7412167c-06e9-4698-aff2-e63eb59037e7'))
# To write it back
>>> kv3.write(bt_config, "tests/documents/bt_config.kv3", use_original_encoding=True)
# Write to a stream
>>> import sys
>>> kv3.write({"key": [1,2,3]}, sys.stdout)
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
key = [1, 2, 3]
}
```
## Install [![PyPI version](https://badge.fury.io/py/keyvalues3.svg)](https://badge.fury.io/py/keyvalues3)
```bash
pip install keyvalues3
```
## Supported encodings
| Encoding 👩💻 | Read 📖 | Write ✍️ |
| ----------- | :-----: | :-------: |
| Text UTF-8 | Yes ✔️ | Yes ✔️ |
| Text UTF-8 Headerless | Yes ✔️ | Yes ✔️ |
| Binary Uncompressed | No ⛔ | Yes ✔️ |
| Binary LZ4 | No ⛔ | Yes ✔️ |
| Binary (Other newer) | No ⛔ | No ⛔ |
## Using dataclasses
Dataclasses (marked with `@dataclass`) are also supported for serialization (uses `asdict()`)
```py
@dataclass
class RenderMeshFile(_Node): # _Node defines _class, name, notes, and children (+ helper methods)
filename: resourcepath = ""
import_translation: list[float] = field(default_factory=lambda: [0, 0, 0])
import_rotation: list[float] = field(default_factory=lambda: [0, 0, 0])
import_scale: float = 1.0
align_origin_x_type: str = "None"
align_origin_y_type: str = "None"
align_origin_z_type: str = "None"
parent_bone: namelink = ""
import_filter: dict = field(
default_factory=lambda:dict(
exclude_by_default = False,
exception_list = [ ]
)
)
```
You can find more ModelDoc dataclasses [here](https://github.com/kristiker/source1import/blob/6644b3133cc79b3c455cc91ab4259f3f0e27d797/utils/shared/modeldoc.py#L61-L88).
## Credits
Valve Corporation® for making KeyValues3.
[ValveResourceFormat](https://github.com/ValveResourceFormat/ValveResourceFormat/blob/master/ValveResourceFormat/Resource/ResourceTypes/BinaryKV3.cs) for reverse engineering the binary formats.
Raw data
{
"_id": null,
"home_page": null,
"name": "keyvalues3",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "parser, kv3, keyvalues, keyvalues3, valve",
"author": null,
"author_email": "kristiker <kristik06@outlook.com>",
"download_url": "https://files.pythonhosted.org/packages/c6/81/26374f2539e2857ca6cda4d16be98e61e8144c2f9bda092d7955943edd6a/keyvalues3-0.2.tar.gz",
"platform": null,
"description": "## keyvalues3\nKeyValues3 is a Valve developed data format. It is similar in structure to JSON, but supports binary encodings, versioning, and data annotations. The text syntax also has some minor ergonomic improvements (support for single- and multi-line comments, trailing commas, and multi-line strings.)\n\n## Usage\n```py\nimport keyvalues3 as kv3\nbt_config = kv3.read(\"tests/documents/bt_config.kv3\")\n\n>>> bt_config.keys()\ndict_keys(['default', 'low', 'fair', 'normal', 'tough', 'hard', 'very_hard', 'expert', 'elite'])\n\n>>> bt_config[\"elite\"][\"reaction_time\"]\n0.12\n```\n\n```py\n# The root value is most of the time a dict\n>>> type(bt_config.value)\n<class 'dict'>\n\n>>> bt_config.original_encoding\nEncoding(name='text', version=UUID('e21c7f3c-8a33-41c5-9977-a76d3a32aa0d'))\n\n>>> bt_config.format\nFormat(name='generic', version=UUID('7412167c-06e9-4698-aff2-e63eb59037e7'))\n\n# To write it back\n>>> kv3.write(bt_config, \"tests/documents/bt_config.kv3\", use_original_encoding=True)\n\n# Write to a stream\n>>> import sys\n>>> kv3.write({\"key\": [1,2,3]}, sys.stdout)\n<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->\n{\n key = [1, 2, 3]\n}\n```\n\n## Install [![PyPI version](https://badge.fury.io/py/keyvalues3.svg)](https://badge.fury.io/py/keyvalues3)\n```bash\npip install keyvalues3\n```\n\n## Supported encodings\n| Encoding \ud83d\udc69\u200d\ud83d\udcbb | Read \ud83d\udcd6 | Write \u270d\ufe0f |\n| ----------- | :-----: | :-------: |\n| Text UTF-8 | Yes \u2714\ufe0f | Yes \u2714\ufe0f |\n| Text UTF-8 Headerless | Yes \u2714\ufe0f | Yes \u2714\ufe0f |\n| Binary Uncompressed | No \u26d4 | Yes \u2714\ufe0f |\n| Binary LZ4 | No \u26d4 | Yes \u2714\ufe0f |\n| Binary (Other newer) | No \u26d4 | No \u26d4 |\n\n## Using dataclasses\nDataclasses (marked with `@dataclass`) are also supported for serialization (uses `asdict()`)\n```py\n@dataclass\nclass RenderMeshFile(_Node): # _Node defines _class, name, notes, and children (+ helper methods)\n filename: resourcepath = \"\"\n import_translation: list[float] = field(default_factory=lambda: [0, 0, 0])\n import_rotation: list[float] = field(default_factory=lambda: [0, 0, 0])\n import_scale: float = 1.0\n align_origin_x_type: str = \"None\"\n align_origin_y_type: str = \"None\"\n align_origin_z_type: str = \"None\"\n parent_bone: namelink = \"\"\n import_filter: dict = field(\n default_factory=lambda:dict(\n exclude_by_default = False,\n exception_list = [ ]\n )\n )\n```\nYou can find more ModelDoc dataclasses [here](https://github.com/kristiker/source1import/blob/6644b3133cc79b3c455cc91ab4259f3f0e27d797/utils/shared/modeldoc.py#L61-L88).\n\n\n## Credits\nValve Corporation\u00ae for making KeyValues3. \n[ValveResourceFormat](https://github.com/ValveResourceFormat/ValveResourceFormat/blob/master/ValveResourceFormat/Resource/ResourceTypes/BinaryKV3.cs) for reverse engineering the binary formats.\n",
"bugtrack_url": null,
"license": null,
"summary": "Read and write Valve's KeyValues3 format",
"version": "0.2",
"project_urls": {
"Source": "https://github.com/kristiker/keyvalues3"
},
"split_keywords": [
"parser",
" kv3",
" keyvalues",
" keyvalues3",
" valve"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "7adc1e8bdb78723ffb85f19a46e9cf1f0c7bba06da90121daf427c7934321206",
"md5": "fbd193865534e8ff48175748784095cc",
"sha256": "1404c55b8a46f16d7081063bdeda573ba2424a4e3eb8db0a4da198cdb0e3ca5a"
},
"downloads": -1,
"filename": "keyvalues3-0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fbd193865534e8ff48175748784095cc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 12723,
"upload_time": "2025-01-18T16:03:37",
"upload_time_iso_8601": "2025-01-18T16:03:37.560275Z",
"url": "https://files.pythonhosted.org/packages/7a/dc/1e8bdb78723ffb85f19a46e9cf1f0c7bba06da90121daf427c7934321206/keyvalues3-0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "c68126374f2539e2857ca6cda4d16be98e61e8144c2f9bda092d7955943edd6a",
"md5": "f9121d5659c704bf9b82b60db965c2fa",
"sha256": "df207f16c0b782930180221436b1243590473df0be785cdf19e102a744365888"
},
"downloads": -1,
"filename": "keyvalues3-0.2.tar.gz",
"has_sig": false,
"md5_digest": "f9121d5659c704bf9b82b60db965c2fa",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 57286,
"upload_time": "2025-01-18T16:03:38",
"upload_time_iso_8601": "2025-01-18T16:03:38.558424Z",
"url": "https://files.pythonhosted.org/packages/c6/81/26374f2539e2857ca6cda4d16be98e61e8144c2f9bda092d7955943edd6a/keyvalues3-0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-18 16:03:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kristiker",
"github_project": "keyvalues3",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "keyvalues3"
}