rpx-kit 0.1.0__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,4 @@
1
+ **/__pycache__/
2
+ **/*.py[cod]
3
+ .vscode/
4
+ .vs/
rpx_kit-0.1.0/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.1.0/PKG-INFO ADDED
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.5
2
+ Name: rpx-kit
3
+ Version: 0.1.0
4
+ Summary: Toolkit for Ren'Py RPA 3.0 archives
5
+ Project-URL: Homepage, https://github.com/Padorublad3/rpx-kit
6
+ Project-URL: Repository, https://github.com/Padorublad3/rpx-kit
7
+ Author: Padorublad3
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+
13
+ # RPX-KIT
14
+
15
+ ## Description
16
+ A toolkit for extracting or viewing only RPA-3.0 archives made with Renpy
17
+
18
+
19
+ ## Features
20
+ **Safe Unpickling**. Uses a custom SafeUnpickler that blocks all external imports during deserialization.
21
+
22
+ **Zero Dependencies**.
23
+
24
+ **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.
25
+
26
+ **Cross-Platform**. Works identically on Windows, Linux, and macOS. Path handling is abstracted via pathlib, so no slash-related issues.
27
+
28
+
29
+ ## Installation
30
+ > [!NOTE]
31
+ > **Python >= 3.9** is required
32
+
33
+ Via pip
34
+ ```bash
35
+ pip install git+https://github.com/Padorublad3/rpx-kit.git
36
+ ```
37
+
38
+
39
+ ## Usage
40
+ ```
41
+ rpx-kit [-l | -o DIR] [-m PATTERN]... INPUT_PATH
42
+
43
+ Arguments:
44
+ INPUT_PATH Input .rpa archive file
45
+
46
+ Options:
47
+ -l, --list Print list of files contained in the archive
48
+ -o, --output Target directory for extraction (creates if missing)
49
+ -m, --mask Filter by fnmatch pattern (repeatable, e.g., -m "*.png")
50
+ ```
51
+
52
+
53
+ ## Examples
54
+ List all PNG and JPG files:
55
+ ```bash
56
+ rpx-kit mygame/archive.rpa -m "*.png" -m "*.jpg" -l
57
+ ```
58
+ Save the list to a text file:
59
+ ```bash
60
+ rpx-kit mygame/archive.rpa -m "*.png" -m "*.jpg" -l > result.txt
61
+ ```
62
+ Extract only PNG and JPG files to a folder:
63
+ ```bash
64
+ rpx-kit mygame/archive.rpa -m "*.png" -m "*.jpg" -o destination_folder
65
+ ```
66
+ ## Mask Cheat Sheet
67
+
68
+ Masks use standard shell-style patterns (`fnmatch`). Remember to wrap them in quotes!
69
+
70
+ | Pattern | Meaning | Example Match |
71
+ | :--- | :--- | :--- |
72
+ | `*` | Matches **any sequence** of characters (including none) | `*.png` → `image.png`, `bg/day.png` |
73
+ | `?` | Matches exactly **one** character | `img?.png` → `img1.png`, but NOT `img10.png` |
74
+ | `[abc]` | Matches **one** char from the set | `file[123].txt` → `file1.txt`, `file2.txt` |
75
+ | `[a-z]` | Matches one char in a **range** | `letter[a-e].rpyc` → `lettera.rpyc` |
76
+ | `[!abc]` | Matches one char **NOT** in the set | `img[!0-9].png` → `imgA.png`, but NOT `img1.png` |
77
+
78
+ ## Tips:
79
+ 1. **Extensions:** Always start with `*.` for extensions.
80
+ ✅ `-m "*.jpg"`
81
+ ❌ `-m ".jpg"` (looks for a file literally named `.jpg`)
82
+ 2. **Paths vs Names:** Masks work on both full paths and filenames.
83
+ - `-m "images/*"` finds everything inside the `images/` folder.
84
+ - `-m "bg_*"` finds any file starting with `bg_`, regardless of its folder.
85
+ 3. **OR Logic:** Multiple `-m` flags are combined with OR.
@@ -0,0 +1,73 @@
1
+ # RPX-KIT
2
+
3
+ ## Description
4
+ A toolkit for extracting or viewing only RPA-3.0 archives made with Renpy
5
+
6
+
7
+ ## Features
8
+ **Safe Unpickling**. Uses a custom SafeUnpickler that blocks all external imports during deserialization.
9
+
10
+ **Zero Dependencies**.
11
+
12
+ **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.
13
+
14
+ **Cross-Platform**. Works identically on Windows, Linux, and macOS. Path handling is abstracted via pathlib, so no slash-related issues.
15
+
16
+
17
+ ## Installation
18
+ > [!NOTE]
19
+ > **Python >= 3.9** is required
20
+
21
+ Via pip
22
+ ```bash
23
+ pip install git+https://github.com/Padorublad3/rpx-kit.git
24
+ ```
25
+
26
+
27
+ ## Usage
28
+ ```
29
+ rpx-kit [-l | -o DIR] [-m PATTERN]... INPUT_PATH
30
+
31
+ Arguments:
32
+ INPUT_PATH Input .rpa archive file
33
+
34
+ Options:
35
+ -l, --list Print list of files contained in the archive
36
+ -o, --output Target directory for extraction (creates if missing)
37
+ -m, --mask Filter by fnmatch pattern (repeatable, e.g., -m "*.png")
38
+ ```
39
+
40
+
41
+ ## Examples
42
+ List all PNG and JPG files:
43
+ ```bash
44
+ rpx-kit mygame/archive.rpa -m "*.png" -m "*.jpg" -l
45
+ ```
46
+ Save the list to a text file:
47
+ ```bash
48
+ rpx-kit mygame/archive.rpa -m "*.png" -m "*.jpg" -l > result.txt
49
+ ```
50
+ Extract only PNG and JPG files to a folder:
51
+ ```bash
52
+ rpx-kit mygame/archive.rpa -m "*.png" -m "*.jpg" -o destination_folder
53
+ ```
54
+ ## Mask Cheat Sheet
55
+
56
+ Masks use standard shell-style patterns (`fnmatch`). Remember to wrap them in quotes!
57
+
58
+ | Pattern | Meaning | Example Match |
59
+ | :--- | :--- | :--- |
60
+ | `*` | Matches **any sequence** of characters (including none) | `*.png` → `image.png`, `bg/day.png` |
61
+ | `?` | Matches exactly **one** character | `img?.png` → `img1.png`, but NOT `img10.png` |
62
+ | `[abc]` | Matches **one** char from the set | `file[123].txt` → `file1.txt`, `file2.txt` |
63
+ | `[a-z]` | Matches one char in a **range** | `letter[a-e].rpyc` → `lettera.rpyc` |
64
+ | `[!abc]` | Matches one char **NOT** in the set | `img[!0-9].png` → `imgA.png`, but NOT `img1.png` |
65
+
66
+ ## Tips:
67
+ 1. **Extensions:** Always start with `*.` for extensions.
68
+ ✅ `-m "*.jpg"`
69
+ ❌ `-m ".jpg"` (looks for a file literally named `.jpg`)
70
+ 2. **Paths vs Names:** Masks work on both full paths and filenames.
71
+ - `-m "images/*"` finds everything inside the `images/` folder.
72
+ - `-m "bg_*"` finds any file starting with `bg_`, regardless of its folder.
73
+ 3. **OR Logic:** Multiple `-m` flags are combined with OR.
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "rpx-kit"
7
+ version = "0.1.0"
8
+ description = "Toolkit for Ren'Py RPA 3.0 archives"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ authors = [
12
+ { name = "Padorublad3"},
13
+ ]
14
+ requires-python = ">=3.9"
15
+ dependencies = []
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
+ [project.urls]
24
+ Homepage = "https://github.com/Padorublad3/rpx-kit"
25
+ Repository = "https://github.com/Padorublad3/rpx-kit"
File without changes
@@ -0,0 +1,87 @@
1
+ import argparse
2
+ from pathlib import Path
3
+ from .core import read_index,unpack_rpa,filter_index
4
+ from time import time
5
+ from sys import exit
6
+
7
+
8
+ def validate_input_path(path:str) -> Path:
9
+ path_obj = Path(path)
10
+ if path_obj.is_file() and path_obj.suffix.lower() == ".rpa":
11
+ return path_obj
12
+ else:
13
+ raise argparse.ArgumentTypeError("Invalid path")
14
+
15
+
16
+ def validate_output_path(path:str) -> Path:
17
+ path_obj = Path(path)
18
+ if path_obj.exists() and not path_obj.is_dir():
19
+ raise argparse.ArgumentTypeError(f"Output path exists but is not a directory: {path}")
20
+ else:
21
+ return path_obj
22
+
23
+
24
+ parser = argparse.ArgumentParser()
25
+
26
+
27
+ parser.add_argument(
28
+ "input_path",
29
+ type=validate_input_path,
30
+ help="Path to the RPA-3.0 archive"
31
+ )
32
+
33
+
34
+ parser.add_argument(
35
+ "-o",
36
+ "--output",
37
+ dest="output_path",
38
+ type=validate_output_path,
39
+ help="Output path"
40
+ )
41
+
42
+
43
+ parser.add_argument(
44
+ "-l",
45
+ "--list",
46
+ action="store_true",
47
+ help="Prints a list of files inside the archive"
48
+
49
+ )
50
+
51
+
52
+ parser.add_argument(
53
+ "-m",
54
+ "--mask",
55
+ action="append",
56
+ dest = "masks",
57
+ default=None,
58
+ help="Filter by mask, can be repeated: -m '*.rpyc' -m '*.png'"
59
+ )
60
+
61
+
62
+ def main():
63
+ args = parser.parse_args()
64
+ with open(args.input_path,"rb") as file:
65
+ index = read_index(file)
66
+ if args.masks:
67
+ index = filter_index(index,args.masks)
68
+ if not index:
69
+ print("No files match the given mask")
70
+ exit(0)
71
+ if args.list:
72
+ for filename in index:
73
+ print(filename)
74
+ else:
75
+ if args.output_path is None:
76
+ parser.error("-o/--output is required when unpacking")
77
+ start_time = time()
78
+ args.output_path.mkdir(parents=True,exist_ok=True)
79
+ total = unpack_rpa(file,index,args.output_path)
80
+ end_time = time()
81
+ print("Done")
82
+ print(f"Total files extracted: {total}")
83
+ print(f"Time taken: {end_time - start_time:.2f} seconds")
84
+
85
+
86
+ if __name__ == "__main__":
87
+ main()
@@ -0,0 +1,64 @@
1
+ import pickle
2
+ import zlib
3
+ from typing import BinaryIO
4
+ import io
5
+ from pathlib import Path
6
+ from fnmatch import fnmatch
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