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.7.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: ra2mix-0.0.7.tar.gz
  • Upload date:
  • Size: 17.0 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.7.tar.gz
Algorithm Hash digest
SHA256 61f8b6b345941b636627a78d06c91737974edb0cdec30991955c058e9c0d0d90
MD5 1b5ca21abaa3dc49b39c2e0e5a910197
BLAKE2b-256 840f9c21399ca0addd57114d99ed04f237a19f0e36af8533d80c5732ead48adf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ra2mix-0.0.7-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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 4d3732541a21ed2d95993be158001ebc955ceb731e60b83d42f926a1f42f7b61
MD5 02980448cc9b2676cf67dfd136e92a9c
BLAKE2b-256 28de68de210819706e0efdbd38830324b957e50965d1d6b838c9d7d0ccaf2e4d

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