Pythra is designed to translate python keywords in any language to their English equivalent. This can be useful for programmers who are learning a new language or are working with code written in a different language. The program uses a dictionary of keywords and their translations, and will output the English equivalent of any python keyword inputted.
NOTE:
The program currently only supports a limited number of languages and keywords, and may not accurately translate all input. It is recommended to double check the translation with a reliable source before using in production code.
- Install Python 3.10 which includes Pip
- Its only dependency is Typer 0.7.0
Install wheel using pip.
$ pip install wheel
In the terminal, navigate to the root of your project directory and run the following command to create a distribution package:
$ python setup.py sdist bdist_wheel
Then you can install it with pip.
$ pip install dist/pythra-0.2.1.tar.gz
To use the Pythra, simply run the pythra or python script using the pythra
keyword. The program will then translate scripts' keywords into Python's English equivalent and compile them as Python files inside the compiled directory. If no provided file argument, Pythra will only compile the scripts without executing any script. You can use either ".puta", ".py" or specific language extension to run your script.
$ pythra [OPTIONS] [FILE_PATH]
Arguments | Description | Default | Optional |
---|---|---|---|
file_path | File path of pythra file. | None | Yes |
Options | Description |
---|---|
--version, -v | Display the current version of pythra. |
--language, -l | Override the foreign language. |
--no-run | Force not to run the script. |
--install-completion | Install completion for the current shell. |
--show-completion | Show completion for the current shell, to copy it or customize the installation. |
--help | Show this message and exit. |
Project structure
It is optional to have __pythraconfig__.json to compile and run the Pythra file, but it is recommended to have it in your directory to organize your Pythra project.
myproject/
README.md
LICENSE.txt
myproject/
__pythraconfig__.jsonc
module.puta
package_1/
package/
module.puta
module_1.puta
module_2.puta
package_2/
module.puta
Pythra Configuration
The default foreign language of Pythra is Tagalog. If you did not put a Pythra configuration in your project, Pythra will compile your script in Tagalog. These are the following properties of __pythraconfig__.jsonc
and its default value:
{
"rootDir": ".", // The directory where the compiler starts to find the pythra script.
"compiledDir": "__compiled__", // The directory where the compiled python script stored.
"language": "spanish", // Foreign language of pythra script.
"runOnCompile": "true" // If true, pythra will execute the translated python script.
}
TAGALOG:
Create a file kumusta_mundo.ptg
with the following tagalog script.
dep kumustaMundo():
mag_print("Kumusta mundo!")
kumustaMundo()
Run the file in CLI using the command:
$ pythra kumusta_mundo.ptg
# Output: Kumusta mundo!
SPANISH:
Create a file hola_mundo.puta
with the following spanish script
def holaMundo():
imprimo("Hola, mundo!")
holaMundo()
Run the file in CLI using the command:
$ pythra -l spanish hola_mundo.puta
# Output: Hola, mundo!
For more examples, see the examples folder.
It will just compile all the files under the current directory if you execute the pythra
keyword without the argument or the "runOnCompile" property of the __pythraconfig__.jsonc
is set to false. By default "runOnCompile" is set to true.
$ pythra
Language | Specific File Extension | |
---|---|---|
Tagalog | .ptg | Documentation |
Spanish | .pes | Documentaion |