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

Table of Contents

Installation

pip install ra2mix

Usage

Import the package

import ra2mix

Reading a *.mix file

The ra2mix.read function will 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())}")

extract_folder = "extract/to/folder"

for filename, file_data in filemap.items():
    print(f"Creating {filename}")
    with open(os.path.join(extract_folder, filename), "wb") as fp:
        fp.write(file_data)

Creating a *.mix file

The ra2mix.write 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-0.0.8.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

ra2mix-0.0.8-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ra2mix-0.0.8.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for ra2mix-0.0.8.tar.gz
Algorithm Hash digest
SHA256 b06ee06fd57438701af16894ca2856b6309d80aea34bb4efa75340e64b36f76f
MD5 207bcfbb171692dd8b09a17aec82e4fd
BLAKE2b-256 bbe055b16c5887cbc5ef363ec8c939c8ac1fc45f0fc787b0d382818391dc14dd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ra2mix-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for ra2mix-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 670d1481bac6a2abd29cce4112f5fe753950bd296fe3539175cda47e9dc01d7e
MD5 7941e900cbb115e9d0f0cd65b44670e1
BLAKE2b-256 0335ced5fd86edfae3f64ac3c8e8baf8b83f27761eb278dc739c6b8c11f17418

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