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

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

Uploaded Source

Built Distribution

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

libxb-1.0.0-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for libxb-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2d547685255d8fead5be8bf5de1668dc48f758dda34f062fd41c1e7ef15bc33f
MD5 e481cae2460ac046b16ba5c9abf3d71e
BLAKE2b-256 059bfe92811e224a6c347997a2978b85a3e36dad7d95a51304143d05f3c7d19d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for libxb-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7fd93d78fec8744905287658a64f76f48d79f00c898ebe6f1015af5f1f06507
MD5 443ed99e22e4a3d0b9e8003be3143eb0
BLAKE2b-256 c05ab067a4717489773d27f66a710fcadf1f85fb7814bf598b6c71d363307208

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