This may be of use to people who want to write .py files while developing, documenting, and testing, but ultimately want the finished product to be available in Ren'Py without the use of imports.
Download at: https://github.com/jsfehler/py_to_rpy
.rpy files generated by this script are identical to the .py files, except for all the code being placed inside a Ren'Py "init python" block.
Usage
From the command line
When called from the command line, multiple files can be specified at once, each separated by a space. The file extension should be omitted.
Code: Select all
python py_to_rpy.py file1 file2 file3
By default, new .rpy files are created next to the .py files. However, the --dest argument can be used to place them into a new folder.
Code: Select all
python py_to_rpy.py file1 file2 file3 --dest=my_folder
By default, new .rpy files will preserve renpy imports that were in the .py file. However, these imports are normally unnecessary in .rpy files. To strip them out, use the --strict flag.
Code: Select all
python py_to_rpy.py file1 file2 file3 --strict
import renpy.exports as renpy
from renpy.{module} import {class}