PseuToPy is a package that transpiles pseudocode into its equivalent Python code
Project description
PseuToPy
PseuToPy is a Python library which defines a grammar for a pseudocode-based pseudocode. With this grammar, PseuToPy is then able to take instructions written in pseudocode and convert it into the equivalent Python instructions.
PseuToPy is designed for educational purposes. In that sense, PseuToPy is suited to anyone embarking in the journey of learning Python programming by offering a relaxed syntax and a grammar that very much resembles the grammar of a natural language.
Currently, PseuToPy only exists in English, but more languages (French, Italian, Spanish) will arrive soon.
Installation
Use the package manager pip to install PseuToPy.
pip install pseutopy
This will also install the following dependencies:
Usage
You can import PseuToPy and use it within your own project.
from pseutopy.pseutopy import PseuToPy
import astor
pseutopy = PseuToPy()
# These two lines generate the AST of the pseudocode instructions
convert_from_string = pseutopy.convert_from_string("declare a set a to 3 plus 1")
convert_from_file = pseutopy.convert_from_file("./path/to/file")
# You can then convert these AST into Python instructions with astor
print(astor.to_source(convert_from_string))
print(astor.to_source(convert_from_file))
Or you can use the CLI utility that ships with this repository.
python pseutopy.py --help
# This is the output of the help flag
usage: pseutopy.py [-h] [-f | -s] [-a] [-q] input
A pseudocode to Python converter written in Python using textX.
positional arguments:
input Pseudocode input and to be converted into Python
optional arguments:
-h, --help show this help message and exit
-f, --file Input is now expected to be a file
-s, --string Input is now expected to be a string (default)
-a, --ast Prints out the generated Python AST
-q, --quiet Don't print the generated Python code
Testing
To run unit tests, run pytest at the root of the project.
Authors and acknowledgment
I particularly wish to thank @Houguiram, @TheOnlyMrFlow, and @EricSombroek for their contributions which greatly helped in setting up the bases for this project.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file PseuToPy-1.0.1.post10.tar.gz.
File metadata
- Download URL: PseuToPy-1.0.1.post10.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b6563f7c3078ee79b5d735a70fd77e713b887b7755af7a91f581482ae2e03c8
|
|
| MD5 |
a713e4b5fe8110daccfb52ac45e59e69
|
|
| BLAKE2b-256 |
738d4a670ce6b79e6870764f21790ad357996084fa97e0355e7a829f0362b11a
|
File details
Details for the file PseuToPy-1.0.1.post10-py3-none-any.whl.
File metadata
- Download URL: PseuToPy-1.0.1.post10-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1254163ef75858fa23762423be6d72d7edfd7aa8f0fb529816be5d705f98ecc6
|
|
| MD5 |
ec398e426c9cf97dc3cbe3c06e72804b
|
|
| BLAKE2b-256 |
e6f8af45cfeb5af9a4105922b660934ffd2e6f02fbe4263d2410093a5df2521c
|