Git Product home page Git Product logo

pythra's Introduction

Pythra - Multi-language Python Translator

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.

Requirements

Installation using local distribution package

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

Usage

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.

Examples

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.

Pythra without argument

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

Supported Languages

Language Specific File Extension
Tagalog .ptg Documentation
Spanish .pes Documentaion

pythra's People

Contributors

johndev4 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.