Skip to main content

ra2mix is a python library for working with Red Alert 2 / Yuri's Revenge *.mix files

Project description

ra2mix

PyPI - Version PyPI - Python Version PyPI - License

A python library for working with Red Alert 2 / Yuri's Revenge *.mix files

Mix files are archive files used to store most game files from the games Command And Conquer Red Alert 2 and its expansion pack Yuri's Revenge.

This library allows you to interact with the mix files much like you'd interact with zip files using a program like 7-zip -- except programmatically, of course 😎. You can create mix files by archiving a list of several files, or read existing mix files and do something with the archived files contained within it.

Table of Contents

Installation

pip install ra2mix

Usage

Import the package

import ra2mix

Reading a *.mix file

  • Read:

    The ra2mix.read function can take a *.mix filepath and return a dict[str, bytes] object. The keys are filenames and the values are file data as bytes.

    import ra2mix
    mix_filepath = "path/to/mixfile.mix"
    
    filemap = ra2mix.read(mix_filepath)
    print(f"filenames: {list(filemap.keys())}")
    
    for filename, file_data in filemap.items():
        # do something with the file data
    
  • Extract:

    The ra2mix.extract function takes a *.mix filepath and an extraction folder path. The files contained in the mix file will be written to the folder.

    import ra2mix
    mix_filepath = "path/to/mixfile.mix"
    extract_folder = "extract/to/folder"
    
    ra2mix.extract(mix_filepath, extract_folder)
    

Creating a *.mix file

The ra2mix.write function supports three methods for specifying files to include in a new *.mix file:

  • filemap: A dict[str, bytes] object consisting of filenames and file data
  • folder_path: A path to a folder; all files in the folder are added to the mix
  • filepaths: A list[str] containing exact filepaths to include in the mix
import ra2mix
mix_filepath = "path/to/mixfile.mix"

target_folder = "read/from/folder"

mix_data = ra2mix.write(mix_filepath, folder_path=target_folder)

# Optionally do something with mix_data if you want; file is already written to
# `mix_filepath`

Project details


Download files

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

Source Distribution

ra2mix-1.0.3.tar.gz (137.1 kB view details)

Uploaded Source

Built Distribution

ra2mix-1.0.3-py3-none-any.whl (138.9 kB view details)

Uploaded Python 3

File details

Details for the file ra2mix-1.0.3.tar.gz.

File metadata

  • Download URL: ra2mix-1.0.3.tar.gz
  • Upload date:
  • Size: 137.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for ra2mix-1.0.3.tar.gz
Algorithm Hash digest
SHA256 10c1c91ad9150d882430caf6d1ada0cfc26f7e8ec5fa495727874494da2a2b12
MD5 0a785ad00ca745c3c091dc88d708f330
BLAKE2b-256 d31be0f21e342f047f9bfcdcba00642aab302d157df144aa26acf8b9b77148ff

See more details on using hashes here.

File details

Details for the file ra2mix-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: ra2mix-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 138.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for ra2mix-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 31a0a87a4bbf8dd37aa9fab0d94693b2f1af2c42df0d7399e2bfcfc28e7735a3
MD5 80d5f00cde04adbc3d0e71e65c099d44
BLAKE2b-256 5adf9097d32a0bf9b3763699dd11fd7201777d8c32646b6725c5427b596acefe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page