https://github.com/jsfehler/py_to_rpy
Convert Python files to Ren'Py files
https://github.com/jsfehler/py_to_rpy
python renpy
Last synced: 8 months ago
JSON representation
Convert Python files to Ren'Py files
- Host: GitHub
- URL: https://github.com/jsfehler/py_to_rpy
- Owner: jsfehler
- License: mit
- Created: 2017-11-12T23:06:37.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-18T00:32:28.000Z (about 3 years ago)
- Last Synced: 2025-04-03T21:35:08.298Z (about 1 year ago)
- Topics: python, renpy
- Language: Python
- Size: 22.5 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
py_to_rpy
=========
.. image:: https://api.travis-ci.org/jsfehler/py_to_rpy.svg?branch=master
:target: https://travis-ci.org/jsfehler/py_to_rpy
:alt: See Build Status on Travis CI
Converts Python files(.py) to Ren'Py files(.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.
Installation
------------
py_to_rpy can be installed via pip:
.. code-block:: console
pip install git+https://github.com/jsfehler/py_to_rpy.git
Usage
-----
From the command line
^^^^^^^^^^^^^^^^^^^^^
When called from the command line, multiple paths can be specified at once, each separated by a space.
.. code-block:: console
py_to_rpy file1.py file2.py file3.py
File parsing uses `glob patterns `_, on each path, meaning:
.. code-block:: console
py_to_rpy my_folder/*.py
is a valid statement, and will select all the .py files in that folder.
Into a specific destination
~~~~~~~~~~~~~~~~~~~~~~~~~~~
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-block:: console
py_to_rpy file1.py file2.py file3.py --dest=my_folder
Strict Mode
~~~~~~~~~~~
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-block:: console
py_to_rpy file1.py file2.py file3.py --strict
The lines that are stripped are defined in py_to_rpy.json under "remove".
.. code-block:: console
"remove": [
"import renpy.exports as renpy",
"from renpy."
]
By default, the following lines are included under remove:
`import renpy.exports as renpy`
`from renpy.`
The lines that are removed do not have to match exactly, they only need to start with the declared line.
Ignoring specific lines
~~~~~~~~~~~~~~~~~~~~~~~
If there are specific lines you want strict mode to ignore, they can be specified in py_to_rpy.json.
.. code-block:: console
"ignore": ["from renpy.python import RevertableList"]
Combining generated rpy files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Instead of keeping multiple generated files, the --minify argument can used to instead generate one combined file.
--minify requires one parameter; the name desired for the combined file.
.. code-block:: console
py_to_rpy file1.py file2.py file3.py --minify=filename