Metadata-Version: 2.0
Name: vpk
Version: 0.11
Summary: Library for reading/extracting files from VPK
Home-page: https://github.com/ValvePython/vpk
Author: Rossen Georgiev
Author-email: hello@rgp.io
License: MIT
Keywords: valve vpk tf2 dota2 csgo dota
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.0
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4

|pypi| |license| |master_build|

VPK is Valve's file format for storing game assets.
This module is able to read the index and individual files.


Install
-------

You can grab the latest release from https://pypi.python.org/pypi/vpk or via ``pip``

.. code:: bash

    pip install vpk


Example usage
-------------

The VPK instance is iterable in the standard ways and produces paths to files

.. code:: python

    import vpk

    pak1 = vpk.open("/d/Steam/steamapps/common/dota 2 beta/dota/pak01_dir.vpk")

    for filepath in pak1:
        print filepath

.. code:: text

    -------------------------------------------------
    sound/half_sec_qd.wav
    sound/items/guardian_greaves.wav
    sound/items/urn_of_shadows.wav
    sound/items/rune_bounty.wav
    sound/items/refresher.wav
    sound/items/item_mael_lightning_04.wav
    sound/items/greevil_whistle.wav
    ...


Reading a specifc file is done by passing the file path to ``get_file()`` method, which
returns a ``VPKFile`` instance, which acts as a regular ``file`` instance. Writting is not
possible.

.. code:: python

    pakfile = pak1.get_file("scripts/emoticons.txt")
    pakfile = pak1["scripts/emoticons.txt"]
    print pakfile.read().decode('utf-16le')

.. code:: text

    -------------------------------------------------
    "emoticons"
    {
        // An ID of zero is invalid

        "1"
        {
            "image_name" "wink.png"
            "ms_per_frame" "100"
    ...

Or if you need to extract a file.

.. code:: python

    pakfile.save("./emoticons.txt")


The module supports creating a basic VPK.
Multi archive packs are not supported yet.

.. code:: python

    newpak = vpk.new("./some/directory")
    newpak.save("file.vpk")

    pak = newpak.save_and_open("file.vpk")


.. |pypi| image:: https://img.shields.io/pypi/v/vpk.svg?style=flat&label=latest%20version
    :target: https://pypi.python.org/pypi/vpk
    :alt: Latest version released on PyPi

.. |license| image:: https://img.shields.io/pypi/l/vpk.svg?style=flat&label=license
    :target: https://pypi.python.org/pypi/vpk
    :alt: MIT License

.. |master_build| image:: https://img.shields.io/travis/ValvePython/vpk/master.svg?style=flat&label=master%20build
    :target: http://travis-ci.org/ValvePython/vpk
    :alt: Build status of master branch


