dbcpy


Namedbcpy JSON
Version 1.0.9 PyPI version JSON
download
home_pagehttps://github.com/jacadzaca/dbcpy
Summarysimple python library for reading WoW's DBC files
upload_time2024-08-18 21:21:56
maintainerNone
docs_urlNone
authorjacadzaca
requires_pythonNone
licenseLGPL3
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## About
This repository contains code for a python3 library that is capable of editing various [DBC](https://wowdev.wiki/DBC) files.
The library was only tested with 3.3.5a DBCs and a [TrinityCore](https://www.trinitycore.org) server.
If this library dose not fit your use case, please consider using [pywowlib](https://github.com/wowdev/pywowlib/). Although
pywowlib's README states that reading/writing DBCs is not possible, [the features seem to be already implemented](https://github.com/wowdev/pywowlib/blob/master/wdbx/wdbc.py).

## Instalation
```bash
pip install dbcpy
```

## Records
dbcpy dose NOT use [WoWDBDefs](https://github.com/wowdev/WoWDBDefs) to parse the DBCs.
DBC representations must be added manually, for a list of supported DBCs see [records](https://github.com/jacadzaca/dbcpy/tree/master/dbcpy/records)

##### Adding records
Adding a record is easy. Just pick a copy-paste the definition from [here](https://wowdev.wiki/Category:DBC_WotLK)
into a python dictionary and define a new dataclass. See [this](https://github.com/jacadzaca/dbcpy/blob/master/dbcpy/records/item_record.py) for a
reference implementation.

## Examples
##### Modifying an existing items' display_ids (will take ~1 second)

```python
#!/usr/bin/env python3
from dbcpy.dbc_file import DBCFile
from dbcpy.records.item_record import ItemRecord

def change_display_ids(item_record):
    # entry: new_display_id
    new_display_ids = {
        1501: 37388,
        15534: 27083,
    }
    try:
        item_record.display_id = new_display_ids[item_record.entry]
        return item_record
    except KeyError:
        return item_record

if __name__ == '__main__':
    with open('Item.dbc', 'r+b') as f:
        dbc_file = DBCFile.from_file(f, ItemRecord)
        some_item = dbc_file.records.find(873)
        some_item.entry = 56807
        some_item.display_id = 20300
        with open('Item.dbc.new', 'w+b') as ff:
            dbc_file.write_to_file(change_display_ids, ff)

    with open('Item.dbc.new', 'r+b') as f:
        dbc_file = DBCFile.from_file(f, ItemRecord)
        print(dbc_file.records.find(1501).display_id)
        print(dbc_file.records.find(15534).display_id)

```

##### Adding a Spell.dbc entry (will take >1 second):

```python
#!/usr/bin/env python3
from dbcpy.dbc_file import DBCFile
from dbcpy.records.spell_record import SpellRecord

if __name__ == '__main__':
    with open('Spell.dbc', 'r+b') as f:
        dbc_file = DBCFile.from_file(f, SpellRecord)
        some_spell = dbc_file.records.find(116)
        some_spell.name.en_us = 'New spell name'
        some_spell.entry = 80865
        dbc_file.records.append(some_spell)

    with open('Spell.dbc', 'r+b') as f:
        dbc_file = DBCFile.from_file(f, SpellRecord)
        the_spell = dbc_file.records.find(80865)
        print(the_spell.name.en_us)

```

##### Modyfing an existing spells' names (will take ~30 seconds)

```python
#!/usr/bin/env python3
from dbcpy.dbc_file import DBCFile
from dbcpy.records.spell_record import SpellRecord

def rename_spell(spell_record):
    new_names = {
        8716: 'i love',
        37263: 'long',
        37290: 'discussions',
    }
    try:
        spell_record.name.en_us = new_names[spell_record.entry]
        return spell_record
    except KeyError:
        return spell_record

if __name__ == '__main__':
    with open('Spell.dbc', 'r+b') as f:
        dbc_file = DBCFile.from_file(f, SpellRecord)
        with open('Spell.dbc.new', 'w+b') as ff:
            dbc_file.write_to_file(rename_spell, ff)

    with open('Spell.dbc.new', 'r+b') as f:
        dbc_file = DBCFile.from_file(f, SpellRecord)
        print(dbc_file.records.find(8716).name.en_us)
        print(dbc_file.records.find(37263).name.en_us)
        print(dbc_file.records.find(37290).name.en_us)

```

## Why dose modifying an existing record takes so long?
Well, not always. In order to modify an existing record, we must rewrite the whole DBC file, because of the string block.
The SpellRecord is especially *large* and the [RecordReader.read_record](https://github.com/jacadzaca/dbcpy/blob/master/dbcpy/records/record_reader.py)
method is not suited for reading *large* records like that. It handles smaller records (like ItemRecord) well enough (~1 second).
The simplest fix would be to implement a SpellRecord specific RecordReader.

## How to contribute?
1. Ensure that your commits have meaningful comments
2. If your contribution is small (e.g it fixes a minor bug) increment revision (the last digit of version) in [setup.py](https://github.com/jacadzaca/dbcpy/blob/master/setup.py)
3. Provide test-cases

## Legal Note
World of Warcraft is a registered trademark of Blizzard Entertainment and/or other respective owners.
This software is not created by Blizzard Entertainment or its affiliates, and is for purely educational and research purposes.
This software is not intended for the use and production of cheating (hacking) software or modifications that can disrupt World of Warcraft's gameplay.
It is your sole responsibility to follow copyright law, game's ToS and EULA.
The creators hold no responsibility for the consequences of use of this software.

The code is licensed under [LGPL 3.0](https://www.gnu.org/licenses/lgpl-3.0.txt).


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jacadzaca/dbcpy",
    "name": "dbcpy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "jacadzaca",
    "author_email": "vitouejj@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e7/b9/4e542e73a36ca05c2e05c358cce429a1888286a7a6c41534d9c8197b63f6/dbcpy-1.0.9.tar.gz",
    "platform": null,
    "description": "## About\nThis repository contains code for a python3 library that is capable of editing various [DBC](https://wowdev.wiki/DBC) files.\nThe library was only tested with 3.3.5a DBCs and a [TrinityCore](https://www.trinitycore.org) server.\nIf this library dose not fit your use case, please consider using [pywowlib](https://github.com/wowdev/pywowlib/). Although\npywowlib's README states that reading/writing DBCs is not possible, [the features seem to be already implemented](https://github.com/wowdev/pywowlib/blob/master/wdbx/wdbc.py).\n\n## Instalation\n```bash\npip install dbcpy\n```\n\n## Records\ndbcpy dose NOT use [WoWDBDefs](https://github.com/wowdev/WoWDBDefs) to parse the DBCs.\nDBC representations must be added manually, for a list of supported DBCs see [records](https://github.com/jacadzaca/dbcpy/tree/master/dbcpy/records)\n\n##### Adding records\nAdding a record is easy. Just pick a copy-paste the definition from [here](https://wowdev.wiki/Category:DBC_WotLK)\ninto a python dictionary and define a new dataclass. See [this](https://github.com/jacadzaca/dbcpy/blob/master/dbcpy/records/item_record.py) for a\nreference implementation.\n\n## Examples\n##### Modifying an existing items' display_ids (will take ~1 second)\n\n```python\n#!/usr/bin/env python3\nfrom dbcpy.dbc_file import DBCFile\nfrom dbcpy.records.item_record import ItemRecord\n\ndef change_display_ids(item_record):\n    # entry: new_display_id\n    new_display_ids = {\n        1501: 37388,\n        15534: 27083,\n    }\n    try:\n        item_record.display_id = new_display_ids[item_record.entry]\n        return item_record\n    except KeyError:\n        return item_record\n\nif __name__ == '__main__':\n    with open('Item.dbc', 'r+b') as f:\n        dbc_file = DBCFile.from_file(f, ItemRecord)\n        some_item = dbc_file.records.find(873)\n        some_item.entry = 56807\n        some_item.display_id = 20300\n        with open('Item.dbc.new', 'w+b') as ff:\n            dbc_file.write_to_file(change_display_ids, ff)\n\n    with open('Item.dbc.new', 'r+b') as f:\n        dbc_file = DBCFile.from_file(f, ItemRecord)\n        print(dbc_file.records.find(1501).display_id)\n        print(dbc_file.records.find(15534).display_id)\n\n```\n\n##### Adding a Spell.dbc entry (will take >1 second):\n\n```python\n#!/usr/bin/env python3\nfrom dbcpy.dbc_file import DBCFile\nfrom dbcpy.records.spell_record import SpellRecord\n\nif __name__ == '__main__':\n    with open('Spell.dbc', 'r+b') as f:\n        dbc_file = DBCFile.from_file(f, SpellRecord)\n        some_spell = dbc_file.records.find(116)\n        some_spell.name.en_us = 'New spell name'\n        some_spell.entry = 80865\n        dbc_file.records.append(some_spell)\n\n    with open('Spell.dbc', 'r+b') as f:\n        dbc_file = DBCFile.from_file(f, SpellRecord)\n        the_spell = dbc_file.records.find(80865)\n        print(the_spell.name.en_us)\n\n```\n\n##### Modyfing an existing spells' names (will take ~30 seconds)\n\n```python\n#!/usr/bin/env python3\nfrom dbcpy.dbc_file import DBCFile\nfrom dbcpy.records.spell_record import SpellRecord\n\ndef rename_spell(spell_record):\n    new_names = {\n        8716: 'i love',\n        37263: 'long',\n        37290: 'discussions',\n    }\n    try:\n        spell_record.name.en_us = new_names[spell_record.entry]\n        return spell_record\n    except KeyError:\n        return spell_record\n\nif __name__ == '__main__':\n    with open('Spell.dbc', 'r+b') as f:\n        dbc_file = DBCFile.from_file(f, SpellRecord)\n        with open('Spell.dbc.new', 'w+b') as ff:\n            dbc_file.write_to_file(rename_spell, ff)\n\n    with open('Spell.dbc.new', 'r+b') as f:\n        dbc_file = DBCFile.from_file(f, SpellRecord)\n        print(dbc_file.records.find(8716).name.en_us)\n        print(dbc_file.records.find(37263).name.en_us)\n        print(dbc_file.records.find(37290).name.en_us)\n\n```\n\n## Why dose modifying an existing record takes so long?\nWell, not always. In order to modify an existing record, we must rewrite the whole DBC file, because of the string block.\nThe SpellRecord is especially *large* and the [RecordReader.read_record](https://github.com/jacadzaca/dbcpy/blob/master/dbcpy/records/record_reader.py)\nmethod is not suited for reading *large* records like that. It handles smaller records (like ItemRecord) well enough (~1 second).\nThe simplest fix would be to implement a SpellRecord specific RecordReader.\n\n## How to contribute?\n1. Ensure that your commits have meaningful comments\n2. If your contribution is small (e.g it fixes a minor bug) increment revision (the last digit of version) in [setup.py](https://github.com/jacadzaca/dbcpy/blob/master/setup.py)\n3. Provide test-cases\n\n## Legal Note\nWorld of Warcraft is a registered trademark of Blizzard Entertainment and/or other respective owners.\nThis software is not created by Blizzard Entertainment or its affiliates, and is for purely educational and research purposes.\nThis software is not intended for the use and production of cheating (hacking) software or modifications that can disrupt World of Warcraft's gameplay.\nIt is your sole responsibility to follow copyright law, game's ToS and EULA.\nThe creators hold no responsibility for the consequences of use of this software.\n\nThe code is licensed under [LGPL 3.0](https://www.gnu.org/licenses/lgpl-3.0.txt).\n\n",
    "bugtrack_url": null,
    "license": "LGPL3",
    "summary": "simple python library for reading WoW's DBC files",
    "version": "1.0.9",
    "project_urls": {
        "Homepage": "https://github.com/jacadzaca/dbcpy"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b0b183d275a02cc8a15c82da1da652df45848adf921ede80831efb451c503a3a",
                "md5": "009a7f900b58d7b4589d4fadacb41191",
                "sha256": "333138aedf948d7ee0569ec6772a9fb5add99fb68cb1e8c0795151dd7cccef5f"
            },
            "downloads": -1,
            "filename": "dbcpy-1.0.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "009a7f900b58d7b4589d4fadacb41191",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 15204,
            "upload_time": "2024-08-18T21:21:52",
            "upload_time_iso_8601": "2024-08-18T21:21:52.205416Z",
            "url": "https://files.pythonhosted.org/packages/b0/b1/83d275a02cc8a15c82da1da652df45848adf921ede80831efb451c503a3a/dbcpy-1.0.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e7b94e542e73a36ca05c2e05c358cce429a1888286a7a6c41534d9c8197b63f6",
                "md5": "8905b8e0dcd5d4f5517fdd8083d1c356",
                "sha256": "860366474c74e6206725ba17da9643b0ab73f4998f8ca7d5253e6503458e375b"
            },
            "downloads": -1,
            "filename": "dbcpy-1.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "8905b8e0dcd5d4f5517fdd8083d1c356",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12567,
            "upload_time": "2024-08-18T21:21:56",
            "upload_time_iso_8601": "2024-08-18T21:21:56.177980Z",
            "url": "https://files.pythonhosted.org/packages/e7/b9/4e542e73a36ca05c2e05c358cce429a1888286a7a6c41534d9c8197b63f6/dbcpy-1.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-18 21:21:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jacadzaca",
    "github_project": "dbcpy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "dbcpy"
}
        
Elapsed time: 0.90611s