rpx-kit 0.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rpx-kit might be problematic. Click here for more details.

@@ -0,0 +1,25 @@
1
+ name: Pylint
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ python-version: ["3.11","3.12","3.13","3.14"]
11
+ steps:
12
+ - uses: actions/checkout@v7
13
+ - name: Set up Python ${{ matrix.python-version }}
14
+ uses: actions/setup-python@v7
15
+ with:
16
+ python-version: ${{ matrix.python-version }}
17
+ - name: Install dependencies
18
+ run: |
19
+ python -m pip install --upgrade pip
20
+ pip install pylint
21
+ - name: Analysing the code with pylint
22
+ run: |
23
+ pylint src/rpx_kit \
24
+ --disable=C0114,C0116,W0511,R0903 \
25
+ --fail-under=7.0
@@ -0,0 +1,49 @@
1
+ name: Upload Python Package
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ release-build:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v7
16
+
17
+ - uses: actions/setup-python@v7
18
+ with:
19
+ python-version: "3.x"
20
+
21
+ - name: Build release distributions
22
+ run: |
23
+ python -m pip install --upgrade pip
24
+ python -m pip install build
25
+ python -m build
26
+
27
+ - name: Upload distributions
28
+ uses: actions/upload-artifact@v7
29
+ with:
30
+ name: release-dists
31
+ path: dist/
32
+
33
+ pypi-publish:
34
+ runs-on: ubuntu-latest
35
+ needs: release-build
36
+
37
+ steps:
38
+ - name: Retrieve release distributions
39
+ uses: actions/download-artifact@v8
40
+ with:
41
+ name: release-dists
42
+ path: dist/
43
+
44
+ - name: Publish release distributions to PyPI
45
+ uses: pypa/gh-action-pypi-publish@release/v1
46
+ with:
47
+ packages-dir: dist/
48
+ password: ${{ secrets.PYPI_API_TOKEN }}
49
+ skip-existing: true
@@ -0,0 +1,4 @@
1
+ **/__pycache__/
2
+ **/*.py[cod]
3
+ .vscode/
4
+ .vs/
rpx_kit-0.2.3/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Padorublad3
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
rpx_kit-0.2.3/PKG-INFO ADDED
@@ -0,0 +1,109 @@
1
+ Metadata-Version: 2.5
2
+ Name: rpx-kit
3
+ Version: 0.2.3
4
+ Summary: Toolkit for Ren'Py RPA 3.0 archives
5
+ Author: Padorublad3
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.11
9
+ Description-Content-Type: text/markdown
10
+
11
+ # RPX-KIT
12
+ [![Pylint](https://github.com/Padorublad3/rpx-kit/actions/workflows/pylint.yml/badge.svg)](https://github.com/Padorublad3/rpx-kit/actions/workflows/pylint.yml)
13
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
14
+ [![Python >=3.11](https://img.shields.io/badge/python-≥3.11-blue.svg)](https://www.python.org/downloads/)
15
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
16
+ ## Description
17
+ A toolkit for extracting or viewing only RPA-3.0 archives made with Renpy
18
+
19
+
20
+ ## Features
21
+ **Safe Unpickling**. Uses a custom SafeUnpickler that blocks all external imports during deserialization.
22
+
23
+ **Zero Dependencies**.
24
+
25
+ **CLI Mask Filtering**. Filter files directly using shell-style patterns (e.g., -m "*.png"). Extract or list only what you need without dumping the entire archive to disk first.
26
+
27
+ **Cross-Platform**. Works identically on Windows, Linux, and macOS. Path handling is abstracted via pathlib, so no slash-related issues.
28
+
29
+
30
+ ## Installation
31
+ > [!NOTE]
32
+ > **Python >= 3.11** is required
33
+
34
+ Via pip
35
+ ```bash
36
+ pip install git+https://github.com/Padorublad3/rpx-kit.git
37
+ ```
38
+
39
+
40
+ ## Usage
41
+ ```
42
+ rpx-kit [-l | -o DIR] [-m PATTERN]... INPUT_PATH
43
+
44
+ Arguments:
45
+ INPUT_PATHS Input .rpa archive(s) files or directory
46
+
47
+ Options:
48
+ -l, --list Print list of files contained in the archive
49
+ -o, --output Target directory for extraction (creates if missing)
50
+ -m, --mask Filter by fnmatch pattern (repeatable, e.g., -m "*.png")
51
+ ```
52
+
53
+
54
+ ## Examples
55
+ List all PNG and JPG files:
56
+ ```bash
57
+ rpx-kit mygame/archive.rpa -m "*.png" -m "*.jpg" -l
58
+ ```
59
+ Save the list to a text file:
60
+ ```bash
61
+ rpx-kit mygame/archive.rpa -m "*.png" -m "*.jpg" -l > result.txt
62
+ ```
63
+ Extract only PNG and JPG files to a folder:
64
+ ```bash
65
+ rpx-kit mygame/archive.rpa -m "*.png" -m "*.jpg" -o destination_folder
66
+
67
+ rpx-kit mygame/archive.rpa mygame/archive2.rpa -m "*.png" -m "*.jpg" -o destination_folder
68
+
69
+ rpx-kit mygame -m "*.png" -m "*.jpg" -o destination_folder
70
+ ```
71
+ ## Mask Cheat Sheet
72
+
73
+ Masks use standard shell-style patterns (`fnmatch`). Remember to wrap them in quotes!
74
+
75
+ | Pattern | Meaning | Example Match |
76
+ | :--- | :--- | :--- |
77
+ | `*` | Matches **any sequence** of characters (including none) | `*.png` → `image.png`, `bg/day.png` |
78
+ | `?` | Matches exactly **one** character | `img?.png` → `img1.png`, but NOT `img10.png` |
79
+ | `[abc]` | Matches **one** char from the set | `file[123].txt` → `file1.txt`, `file2.txt` |
80
+ | `[a-z]` | Matches one char in a **range** | `letter[a-e].rpyc` → `lettera.rpyc` |
81
+ | `[!abc]` | Matches one char **NOT** in the set | `img[!0-9].png` → `imgA.png`, but NOT `img1.png` |
82
+
83
+ ## Tips:
84
+ 1. **Extensions:** Always start with `*.` for extensions.
85
+ ✅ `-m "*.jpg"`
86
+ ❌ `-m ".jpg"` (looks for a file literally named `.jpg`)
87
+ 2. **Paths vs Names:** Masks work on both full paths and filenames.
88
+ - `-m "images/*"` finds everything inside the `images/` folder.
89
+ - `-m "bg_*"` finds any file starting with `bg_`, regardless of its folder.
90
+ 3. **OR Logic:** Multiple `-m` flags are combined with OR.
91
+
92
+ ---
93
+
94
+ ## Disclaimer
95
+
96
+ This program is intended for people who have the legal rights or the consent of the target app authors to access or decompress the archive files. Any illegal or otherwise unintended usage of this software is discouraged and unsupported.
97
+
98
+ ## Credits
99
+
100
+ This software was developed with orientation on Ren'Py's source code for working with RPA files. Credits for the development of the Ren'Py archive format belong to the contributors of the [Ren'Py project](https://github.com/renpy/renpy).
101
+
102
+ ## Support
103
+
104
+ If this tool saved you time, consider supporting the developer:
105
+
106
+ **ERC-20** ```0x8BA3456DBf94891881204ECB7a0f2fbdb6228D8A```
107
+
108
+
109
+ **SOL** ```H93HCZ1KqvnmAgDh9Enyi2xgUnXXXA5yb7uDxeshQJq```
@@ -0,0 +1,99 @@
1
+ # RPX-KIT
2
+ [![Pylint](https://github.com/Padorublad3/rpx-kit/actions/workflows/pylint.yml/badge.svg)](https://github.com/Padorublad3/rpx-kit/actions/workflows/pylint.yml)
3
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
4
+ [![Python >=3.11](https://img.shields.io/badge/python-≥3.11-blue.svg)](https://www.python.org/downloads/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ ## Description
7
+ A toolkit for extracting or viewing only RPA-3.0 archives made with Renpy
8
+
9
+
10
+ ## Features
11
+ **Safe Unpickling**. Uses a custom SafeUnpickler that blocks all external imports during deserialization.
12
+
13
+ **Zero Dependencies**.
14
+
15
+ **CLI Mask Filtering**. Filter files directly using shell-style patterns (e.g., -m "*.png"). Extract or list only what you need without dumping the entire archive to disk first.
16
+
17
+ **Cross-Platform**. Works identically on Windows, Linux, and macOS. Path handling is abstracted via pathlib, so no slash-related issues.
18
+
19
+
20
+ ## Installation
21
+ > [!NOTE]
22
+ > **Python >= 3.11** is required
23
+
24
+ Via pip
25
+ ```bash
26
+ pip install git+https://github.com/Padorublad3/rpx-kit.git
27
+ ```
28
+
29
+
30
+ ## Usage
31
+ ```
32
+ rpx-kit [-l | -o DIR] [-m PATTERN]... INPUT_PATH
33
+
34
+ Arguments:
35
+ INPUT_PATHS Input .rpa archive(s) files or directory
36
+
37
+ Options:
38
+ -l, --list Print list of files contained in the archive
39
+ -o, --output Target directory for extraction (creates if missing)
40
+ -m, --mask Filter by fnmatch pattern (repeatable, e.g., -m "*.png")
41
+ ```
42
+
43
+
44
+ ## Examples
45
+ List all PNG and JPG files:
46
+ ```bash
47
+ rpx-kit mygame/archive.rpa -m "*.png" -m "*.jpg" -l
48
+ ```
49
+ Save the list to a text file:
50
+ ```bash
51
+ rpx-kit mygame/archive.rpa -m "*.png" -m "*.jpg" -l > result.txt
52
+ ```
53
+ Extract only PNG and JPG files to a folder:
54
+ ```bash
55
+ rpx-kit mygame/archive.rpa -m "*.png" -m "*.jpg" -o destination_folder
56
+
57
+ rpx-kit mygame/archive.rpa mygame/archive2.rpa -m "*.png" -m "*.jpg" -o destination_folder
58
+
59
+ rpx-kit mygame -m "*.png" -m "*.jpg" -o destination_folder
60
+ ```
61
+ ## Mask Cheat Sheet
62
+
63
+ Masks use standard shell-style patterns (`fnmatch`). Remember to wrap them in quotes!
64
+
65
+ | Pattern | Meaning | Example Match |
66
+ | :--- | :--- | :--- |
67
+ | `*` | Matches **any sequence** of characters (including none) | `*.png` → `image.png`, `bg/day.png` |
68
+ | `?` | Matches exactly **one** character | `img?.png` → `img1.png`, but NOT `img10.png` |
69
+ | `[abc]` | Matches **one** char from the set | `file[123].txt` → `file1.txt`, `file2.txt` |
70
+ | `[a-z]` | Matches one char in a **range** | `letter[a-e].rpyc` → `lettera.rpyc` |
71
+ | `[!abc]` | Matches one char **NOT** in the set | `img[!0-9].png` → `imgA.png`, but NOT `img1.png` |
72
+
73
+ ## Tips:
74
+ 1. **Extensions:** Always start with `*.` for extensions.
75
+ ✅ `-m "*.jpg"`
76
+ ❌ `-m ".jpg"` (looks for a file literally named `.jpg`)
77
+ 2. **Paths vs Names:** Masks work on both full paths and filenames.
78
+ - `-m "images/*"` finds everything inside the `images/` folder.
79
+ - `-m "bg_*"` finds any file starting with `bg_`, regardless of its folder.
80
+ 3. **OR Logic:** Multiple `-m` flags are combined with OR.
81
+
82
+ ---
83
+
84
+ ## Disclaimer
85
+
86
+ This program is intended for people who have the legal rights or the consent of the target app authors to access or decompress the archive files. Any illegal or otherwise unintended usage of this software is discouraged and unsupported.
87
+
88
+ ## Credits
89
+
90
+ This software was developed with orientation on Ren'Py's source code for working with RPA files. Credits for the development of the Ren'Py archive format belong to the contributors of the [Ren'Py project](https://github.com/renpy/renpy).
91
+
92
+ ## Support
93
+
94
+ If this tool saved you time, consider supporting the developer:
95
+
96
+ **ERC-20** ```0x8BA3456DBf94891881204ECB7a0f2fbdb6228D8A```
97
+
98
+
99
+ **SOL** ```H93HCZ1KqvnmAgDh9Enyi2xgUnXXXA5yb7uDxeshQJq```
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["hatchling","uv-dynamic-versioning"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "rpx-kit"
7
+ description = "Toolkit for Ren'Py RPA 3.0 archives"
8
+ readme = "README.md"
9
+ license = { text = "MIT" }
10
+ authors = [
11
+ { name = "Padorublad3"},
12
+ ]
13
+ requires-python = ">=3.11"
14
+ dependencies = []
15
+ dynamic = ["version"]
16
+
17
+ [project.scripts]
18
+ rpx-kit = "rpx_kit.cli:main"
19
+
20
+ [tool.hatch.build.targets.wheel]
21
+ packages = ["src/rpx_kit"]
22
+
23
+ [tool.hatch.version]
24
+ source = "uv-dynamic-versioning"
25
+
26
+ [tool.ruff]
27
+ line-length = 88
28
+
29
+ [tool.ruff.lint]
30
+ select = ["E", "W", "F", "I"]
31
+ ignore = []
32
+
33
+ [tool.ruff.lint.isort]
34
+ combine-as-imports = true
@@ -0,0 +1 @@
1
+ __version__ = "0.2.1"
@@ -0,0 +1,119 @@
1
+ import argparse
2
+ import sys
3
+ from pathlib import Path
4
+ from time import time
5
+
6
+ from rpx_kit import __version__
7
+
8
+ from .core import filter_index, read_index, unpack_rpa
9
+
10
+
11
+ def validate_input_path(path: str) -> list[Path]:
12
+ path_obj = Path(path)
13
+ if path_obj.is_file() and path_obj.suffix.lower() == ".rpa":
14
+ return [path_obj]
15
+ elif path_obj.exists() and path_obj.is_dir():
16
+ result = scan_folder(path_obj)
17
+ if not result:
18
+ print(f"Warning! No RPA archives found in {path}", file=sys.stderr)
19
+ return []
20
+ else:
21
+ return result
22
+ else:
23
+ print(f"Not a valid RPA file or directory: {path}", file=sys.stderr)
24
+ return []
25
+
26
+
27
+ def validate_output_path(path: str) -> Path:
28
+ path_obj = Path(path)
29
+ if path_obj.exists() and not path_obj.is_dir():
30
+ raise argparse.ArgumentTypeError(
31
+ f"Output path exists but is not a directory: {path}"
32
+ )
33
+ else:
34
+ return path_obj
35
+
36
+
37
+ def scan_folder(path_obj: Path) -> list[Path]:
38
+ scan = list(path_obj.rglob("*.rpa"))
39
+ return scan
40
+
41
+
42
+ parser = argparse.ArgumentParser(prog="rpx-kit")
43
+
44
+
45
+ parser.add_argument("input_paths", nargs="*", help="Path to the RPA-3.0 archive")
46
+
47
+
48
+ parser.add_argument(
49
+ "-o", "--output", dest="output_path", type=validate_output_path, help="Output path"
50
+ )
51
+
52
+
53
+ parser.add_argument(
54
+ "-l",
55
+ "--list",
56
+ action="store_true",
57
+ help="Prints a list of files inside the archive",
58
+ )
59
+
60
+
61
+ parser.add_argument(
62
+ "-m",
63
+ "--mask",
64
+ action="append",
65
+ dest="masks",
66
+ default=None,
67
+ help="Filter by mask, can be repeated: -m '*.rpyc' -m '*.png'",
68
+ )
69
+
70
+
71
+ parser.add_argument(
72
+ "-v", "--version", action="version", version=f"%(prog)s {__version__}"
73
+ )
74
+
75
+
76
+ def main():
77
+ args = parser.parse_args()
78
+ if not args.input_paths:
79
+ raise argparse.ArgumentTypeError("No paths provided")
80
+ input_paths = [validate_input_path(path) for path in args.input_paths]
81
+ if input_paths:
82
+ archives = [path for paths in input_paths for path in paths]
83
+ print(f"{len(archives)} archives found")
84
+ else:
85
+ raise argparse.ArgumentTypeError("No valid paths provided")
86
+ start_time = time()
87
+ for archive in archives:
88
+ print(
89
+ f"Processing {archive}, total size = {round(archive.stat().st_size / (1024 * 1024), 2)} MB"
90
+ )
91
+ with open(archive, "rb") as file:
92
+ try:
93
+ index = read_index(file)
94
+ except Exception as e:
95
+ print(f"Skip {archive}, error: {e}", file=sys.stderr)
96
+ continue
97
+ if args.masks:
98
+ index = filter_index(index, args.masks)
99
+ if not index:
100
+ print(f"No files match the given mask in {archive}")
101
+ continue
102
+ if args.list:
103
+ for filename in sorted(index.keys()):
104
+ print(f"{filename}")
105
+ else:
106
+ if args.output_path is None:
107
+ parser.error("-o/--output is required when unpacking")
108
+ output_dir = args.output_path / archive.stem
109
+ output_dir.mkdir(parents=True, exist_ok=True)
110
+ total = unpack_rpa(file, index, output_dir)
111
+
112
+ print(f"Done, {archive} processed")
113
+ print(f"Total files extracted: {total}")
114
+ end_time = time()
115
+ print(f"Time taken: {end_time - start_time:.2f} seconds")
116
+
117
+
118
+ if __name__ == "__main__":
119
+ main()
@@ -0,0 +1,64 @@
1
+ import io
2
+ import pickle
3
+ import zlib
4
+ from fnmatch import fnmatch
5
+ from pathlib import Path
6
+ from typing import BinaryIO
7
+
8
+
9
+ class SafeUnpickler(pickle.Unpickler):
10
+ def find_class(self, module_name, global_name):
11
+ raise pickle.UnpicklingError("Import is prohibited")
12
+
13
+
14
+ def read_index(infile: BinaryIO) -> dict:
15
+ header = infile.read(33)
16
+ if not header.startswith(b"RPA-3.0 "):
17
+ raise ValueError("Unsupported format")
18
+ offset, key = int(header[8:24], 16), int(header[25:33], 16)
19
+ infile.seek(offset)
20
+ virtual_file = io.BytesIO(zlib.decompress(infile.read()))
21
+ index = SafeUnpickler(virtual_file).load()
22
+
23
+ for filename in index:
24
+ # index = Dict[str, List[Tuple[int, int, bytes]]]
25
+ # Key = filename
26
+ # Values = list of chunks (offset, length, bytes)
27
+ # Bytes never used in RPA 3.0
28
+ offset, length = index[filename][0][0], index[filename][0][1]
29
+ index[filename] = (offset ^ key, length ^ key)
30
+ return index
31
+
32
+
33
+ def filter_index(index: dict, masks: list):
34
+ if not masks:
35
+ return index
36
+ return {
37
+ filename: data
38
+ for filename, data in index.items()
39
+ if any(_match(filename, mask) for mask in masks)
40
+ }
41
+
42
+
43
+ def _match(filename: str, mask: str) -> bool:
44
+ return fnmatch(filename, mask) or fnmatch(Path(filename).name, mask)
45
+
46
+
47
+ def extract_file(infile: BinaryIO, output_path: Path, file_data: tuple) -> None:
48
+ offset, length = file_data
49
+ with open(output_path, "wb") as out_file:
50
+ infile.seek(offset)
51
+ data = infile.read(length)
52
+ out_file.write(data)
53
+
54
+
55
+ def unpack_rpa(infile: BinaryIO, index: dict, target_path: Path) -> int:
56
+ total = 0
57
+ unique_dirs = {target_path / Path(filename).parent for filename in index}
58
+ for directory in unique_dirs:
59
+ directory.mkdir(parents=True, exist_ok=True)
60
+ for filename, file_data in index.items():
61
+ output_file = target_path / filename
62
+ extract_file(infile, output_file, file_data)
63
+ total += 1
64
+ return total