-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
58 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .decompile import decompile | ||
from .translate import translate | ||
from .cli import main | ||
from .rpa import extract_rpa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,55 @@ | ||
import argparse | ||
import logging | ||
from rpycdec.decompile import decompile | ||
from rpycdec.rpa import extract_rpa | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def decompile_files(srcs: list[str]): | ||
""" | ||
decompile rpyc file or directory. | ||
""" | ||
for src in srcs: | ||
decompile(src) | ||
|
||
|
||
def extract_rpa_files(srcs: list[str]): | ||
""" | ||
extract rpa archive. | ||
""" | ||
for src in srcs: | ||
with open(src, "rb") as f: | ||
extract_rpa(f) | ||
|
||
|
||
def main(): | ||
""" | ||
command line tool entry. | ||
""" | ||
logging.basicConfig(level=logging.INFO) | ||
|
||
argparser = argparse.ArgumentParser() | ||
argparser.add_argument( | ||
"--verbose", "-v", action="store_true", help="verbose output" | ||
) | ||
argparser.add_argument("src", nargs=1, help="rpyc file or directory") | ||
subparsers = argparser.add_subparsers( | ||
title="subcommands", dest="command", help="subcommand help" | ||
) | ||
|
||
decompile_parser = subparsers.add_parser("decompile", help="decompile rpyc file") | ||
decompile_parser.add_argument("src", nargs=1, help="rpyc file or directory") | ||
decompile_parser.set_defaults(func=decompile_files) | ||
|
||
unrpa_parser = subparsers.add_parser("unrpa", help="extract rpa archive") | ||
unrpa_parser.add_argument("src", nargs=1, help="rpa archive") | ||
unrpa_parser.set_defaults(func=extract_rpa_files) | ||
|
||
args = argparser.parse_args() | ||
if args.verbose: | ||
logger.setLevel(logging.DEBUG) | ||
for src in args.src: | ||
decompile(src) | ||
if not args.command: | ||
argparser.print_help() | ||
return | ||
args.func(args.src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters