An open API service indexing awesome lists of open source software.

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

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