Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Library for working with Valve Pak files

Project Description

VPK is Valve’s file format for storing game assets. Pythonic access to VPK files and their contents together with a cli tool.

Tested and works on python2.6, python2.7, python3.2+, pypy and pypy3.

Install

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

pip install vpk

Quick start

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

import vpk

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

for filepath in pak1:
    print filepath

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.

pakfile = pak1.get_file("scripts/emoticons.txt")
pakfile = pak1["scripts/emoticons.txt"]
print pakfile.read().decode('utf-16le')
-------------------------------------------------
"emoticons"
{
    // An ID of zero is invalid

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

Saving a file is just as easy.

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

The module supports creating basic VPKs. Multi archive paks are not yet supported.

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

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

CLI tool

A command line utility is also included

usage: vpk [-h] [--version] [-l] [-la] [-x OUT_LOCATION] [-nd] [-t] [-c DIR]
           [-f WILDCARD | -re REGEX | -name WILDCARD]
           file

Manage Valve Pak files

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit

Main:
  file                  Input VPK file
  -l, --list            List file paths
  -la                   List file paths, crc, size
  -x OUT_LOCATION, --extract OUT_LOCATION
                        Exctract files to directory
  -nd, --no-directories
                        Don't create directries during extraction
  -t, --test            Verify contents
  -c DIR, --create DIR  Create VPK file from directory

Filters:
  -f WILDCARD, --filter WILDCARD
                        Wildcard filter for file paths
  -re REGEX, --regex REGEX
                        Regular expression filter for file paths
  -name WILDCARD        Filename wildcard filter
Release History

Release History

This version
History Node

1.1

History Node

1.0

History Node

0.12

History Node

0.11

History Node

0.10

History Node

0.9

History Node

0.8

History Node

0.7

History Node

0.6

History Node

0.5

History Node

0.4

History Node

0.3

History Node

0.2

History Node

0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
vpk-1.1-py2.py3-none-any.whl (11.3 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Jan 4, 2017
vpk-1.1.tar.gz (9.8 kB) Copy SHA256 Checksum SHA256 Source Jan 4, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting