Skip to main content

A library for the ClapHanz XB archive format

Project description

libxb

Python library for the ClapHanz XB archive format

python Code style: black License: GPLv3 PyPI version

libxb is available for installation via the pip package manager:

python3 -m pip install libxb

User Interface

libxb provides a command-line interface for those who wish to use it as a tool.

Once you install the package via pip, it can be accessed via the main module (python -m libxb ...), or via its entrypoint script (libxb ...).

Usage

usage: libxb [-h] [-o <path>] -g <name> (-x <archive> | -c <path> [<path> ...]) [-r <path>] [-v]

libxb command line interface

options:
  -h, --help            show this help message and exit
  -o <path>, --output <path>
                        (optional) Output path for extraction/creation result
  -g <name>, --game <name>
                        Target game for the XB archive
  -x <archive>, --extract <archive>
                        Extract an XB archive to the specified output path. If no output path is specified, a directory
                        with the same name as the archive will be created (*.xb.d)
  -c <path> [<path> ...], --create <path> [<path> ...]
                        Create an XB archive from the specified files and/or directories. If no output path is
                        specified, and only a single input path is specified, an archive with the same name as the
                        input path will be created (*.xb.d -> *.xb, otherwise: *.* -> *.*.xb)
  -r <path>, --root <path>
                        (optional) Root path/prefix for files in the XB archive (i.e. ../ for MNGP)
  -v, --verbose         (optional) Enable verbose log output

Examples

# Extract mRoomSel.xb as MNGP archive (creates "mRoomSel.xb.d" directory)
libxb -g mngp -x mRoomSel.xb
# Extract mRoomSel.xb as MNGP archive (creates "my_cool_path" directory)
libxb -g mngp -o my_cool_path -x mRoomSel.xb

# Create a MNGP archive from files in mRoomSel.xb.d directory (creates "mRoomSel.xb" file)
libxb -g mngp -c mRoomSel.xb.d
# Create a MNGP archive from files in mRoomSel.xb.d directory (creates "mRoomSelNew.xb" file)
libxb -g mngp -o mRoomSelNew.xb -c mRoomSel.xb.d

# Create a MNGP archive from three specified files (creates "ss.xb" file)
# Root directory is specified as "../data/", so all files in the archive get that prefix.
libxb -g mngp -o ss.xb -c config.dat ss.info sponsor.dat -r ../data/

Developer Interface

libxb provides a simple interface for XB files which resembles that of Python's tarfile:

Example Usage

import libxb

###############################################################################
## Extract archive
###############################################################################
with libxb.XBArchive("my-file.xb", XBOpenMode.READ, XBEndian.LITTLE) as arc:
    arc.extract_all(path="output-path/")

###############################################################################
## Create archive
###############################################################################
with libxb.XBArchive("my-file.xb", XBOpenMode.WRITE, XBEndian.LITTLE) as arc:
    arc.add(path="all-these-files/",
            xb_path="actually-go-here/",      # optional
            compression=XBCompression.DEFLATE # optional
            recursive=True)                   # optional

###############################################################################
## Modify archive
###############################################################################
with libxb.XBArchive("my-file.xb", XBOpenMode.RW, XBEndian.LITTLE) as arc:
    arc.add(path="just-one-file.XB",
            xb_path="/data/config.dat",  # optional
            compression=XBCompression.LZ # optional
            recursive=True)              # optional

###############################################################################
## Process files
###############################################################################
with libxb.XBArchive("my-file.xb", XBOpenMode.READ, XBEndian.LITTLE) as arc:
    for file in arc:
        ... # do whatever

Helper Classes

Additionally, subclasses are provided for each title to remove the need to specify byteorder/endianness, and to allow shorthand strings for the access modes ('r'/'w'/'+'/'x'):

Title Class
Minna no Golf 3 MNG3Archive
Minna no Golf Online MNGOArchive
Minna no Golf 4 MNG4Archive
Minna no Golf Portable MNGPArchive
Minna no Golf 5 MNG5Archive
Minna no Golf 6 Not yet supported
Minna no Tennis MNTArchive
Minna no Tennis Portable MNTPArchive
from libxb import MNGPArchive

###############################################################################
## Create archive for Minna no Golf Portable
###############################################################################
with MNGPArchive("config.dat", "w") as arc:
    arc.add(path="config.txt",
            xb_path="/data/config.dat") # optional

API Documentation

See the XBArchive implementation for more information about the methods and members provided.

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

libxb-0.2.0.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

libxb-0.2.0-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file libxb-0.2.0.tar.gz.

File metadata

  • Download URL: libxb-0.2.0.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for libxb-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2d0cacd9363358cfaaec31b6db5eb5c25ea410b77dfac7d01255e7305c546371
MD5 17e0b20a3182d3fded904ee272921d24
BLAKE2b-256 459d0cdfb091f722e15a2b5506d8d9d26bb9af894e5e36e981baecca48c32fd9

See more details on using hashes here.

File details

Details for the file libxb-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: libxb-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for libxb-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90414b4b3205e199b86d5f736342b84c886de68a31e91f95b10e89438b4e4524
MD5 17eff3073fcb7d4afc04670f0b9392d6
BLAKE2b-256 dd47721d9d33ef00e472481e5846bd4f1b4ccea7a954e65b71a1e6cd2e93ff66

See more details on using hashes here.

Supported by

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