pitono-lang 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pitono_lang-0.1.2/PKG-INFO +232 -0
- pitono_lang-0.1.2/README.md +222 -0
- pitono_lang-0.1.2/pyproject.toml +25 -0
- pitono_lang-0.1.2/setup.cfg +4 -0
- pitono_lang-0.1.2/src/pitono_lang/__init__.py +17 -0
- pitono_lang-0.1.2/src/pitono_lang/main.py +194 -0
- pitono_lang-0.1.2/src/pitono_lang.egg-info/PKG-INFO +232 -0
- pitono_lang-0.1.2/src/pitono_lang.egg-info/SOURCES.txt +9 -0
- pitono_lang-0.1.2/src/pitono_lang.egg-info/dependency_links.txt +1 -0
- pitono_lang-0.1.2/src/pitono_lang.egg-info/entry_points.txt +2 -0
- pitono_lang-0.1.2/src/pitono_lang.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pitono-lang
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: A multilingual Python wrapper for the Pitono compiler, bridging localized programming dialects (Spanish, Chinese, Hindi, German, and more) with native cross-lingual text translation and runtime execution pipelines
|
|
5
|
+
Author-email: Matthew Mampuzha <mampuzha.matthew@outlook.com>
|
|
6
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
\# pitono-lang
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
A powerful, cross-lingual Python wrapper for the \*\*Pitono\*\* programming language compiler. This package bridges Python environments with the native Windows Pitono compilation engine, allowing you to execute, translate, and configure multi-language Python-based source scripts directly via Python or your Command Line Interface (CLI).
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
\## Features
|
|
20
|
+
|
|
21
|
+
\* 🚀 \*\*Seamless Command Line Call:\*\* Instantly runs `pitono` from anywhere in your Command Prompt once installed (no `.exe` extension required!).
|
|
22
|
+
|
|
23
|
+
\* 🌐 \*\*Multi-Language Translation Engine:\*\* Translate source code or compile it directly between Spanish, Chinese, Hindi, French, Russian, and more.
|
|
24
|
+
|
|
25
|
+
\* 📂 \*\*Localized File Support:\*\* Core C# parsing scales natively across Unicode extensions like `.蟒`, `.pitón`, and `.riesenschlange`.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
\---
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
\## Installation
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
This package requires a \*\*Windows 64-bit environment\*\* with Python 3.8 or higher installed.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
|
|
43
|
+
pip install pitono-lang
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
\---
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
\## Supported Languages \& File Extensions
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
Pitono detects which language your script is written in based entirely on the file extension. Below is the official mapping table:
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
| Language | File Extension | CLI Language Flag | Example Filename |
|
|
62
|
+
|
|
63
|
+
| :--- | :--- | :--- | :--- |
|
|
64
|
+
|
|
65
|
+
| \*\*English\*\* | `.py` | `-en` | `script.py` |
|
|
66
|
+
|
|
67
|
+
| \*\*Chinese\*\* | `.蟒` | `-zh-CN` | `script.蟒` |
|
|
68
|
+
|
|
69
|
+
| \*\*Hindi\*\* | `.अजगर` | `-hi` | `script.अजगर` |
|
|
70
|
+
|
|
71
|
+
| \*\*Spanish\*\* | `.pitón` | `-es` | `script.pitón` |
|
|
72
|
+
|
|
73
|
+
| \*\*French\*\* | `.lepython` | `-fr` | `script.lepython` |
|
|
74
|
+
|
|
75
|
+
| \*\*Bengali\*\* | `.পাইথন` | `-bn` | `script.পাইথন` |
|
|
76
|
+
|
|
77
|
+
| \*\*Portuguese\*\* | `.pitão` | `-pt` | `script.pitão` |
|
|
78
|
+
|
|
79
|
+
| \*\*Russian\*\* | `.питон` | `-ru` | `script.питон` |
|
|
80
|
+
|
|
81
|
+
| \*\*Indonesian\*\* | `.ularpiton` | `-id` | `script.ularpiton` |
|
|
82
|
+
|
|
83
|
+
| \*\*German\*\* | `.riesenschlange` | `-de` | `script.riesenschlange` |
|
|
84
|
+
|
|
85
|
+
| \*\*Japanese\*\* | `.パイソン` | `-ja` | `script.パイソン` |
|
|
86
|
+
|
|
87
|
+
| \*\*Dutch\*\* | `.depython` | `-nl` | `script.depython` |
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
\---
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
\## Command Line Interface (CLI) Usage
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
When you run `pip install pitono-lang`, the tool is automatically mapped directly to your Windows global paths. You can execute it natively by just typing \*\*`pitono`\*\* (omitting the `.exe` extension completely):
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
\### 1. Execute a Localized Script Natively
|
|
104
|
+
|
|
105
|
+
To compile and immediately execute any localized script program, pass the file path as the first argument:
|
|
106
|
+
|
|
107
|
+
```cmd
|
|
108
|
+
|
|
109
|
+
pitono slope-intercept.pitón
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
\### 2. Translate a Script to Another Dialect
|
|
116
|
+
|
|
117
|
+
To translate a file into another target dialect instead of executing it, add the destination language flag as an additional argument:
|
|
118
|
+
|
|
119
|
+
```cmd
|
|
120
|
+
|
|
121
|
+
:: Translates a Spanish file into Python (English) text
|
|
122
|
+
|
|
123
|
+
pitono slope-intercept.pitón -en
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
:: Translates a German file into a Chinese script
|
|
128
|
+
|
|
129
|
+
pitono algebra.riesenschlange -zh-CN
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
\---
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
\## Python API Usage
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
\### 1. Execute Code Blocks
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
|
|
147
|
+
import pitono\_lang
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
pitono\_code = r"""
|
|
152
|
+
|
|
153
|
+
imprimir("Hola me llamo Mateo")
|
|
154
|
+
|
|
155
|
+
nombre_ejemplo = entrada("Como te llamas? ")
|
|
156
|
+
|
|
157
|
+
imprimir("\\nHola, " + nombre_ejemplo)
|
|
158
|
+
|
|
159
|
+
"""
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
pitono\_lang.exec(pitono\_code, source\_lang="spanish")
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
\### 2. Translate Code Programmatically
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
|
|
173
|
+
import pitono\_lang
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
spanish\_code = r'imprimir("Hola Mundo")'
|
|
178
|
+
|
|
179
|
+
python\_code = pitono\_lang.translate(spanish\_code, source\_lang="spanish", dest\_lang="english")
|
|
180
|
+
|
|
181
|
+
print(python\_code) # Outputs: print("Hola Mundo")
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
\### 3. Manage Default Language Settings
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
|
|
191
|
+
import pitono\_lang
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
\# Set configuration defaults for system lookups
|
|
196
|
+
|
|
197
|
+
pitono\_lang.setDefaultLanguage("spanish")
|
|
198
|
+
|
|
199
|
+
print(pitono\_lang.getDefaultLanguage()) # Outputs: spanish
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
\---
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
\## Documentation
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
To view the full vocabulary lists, custom keywords, syntax structures, and built-in functions available for coding within each supported language, visit the official documentation page:
|
|
214
|
+
|
|
215
|
+
👉 \[https://mampuzha.org/projects/pitono/documentation](https://mampuzha.org/projects/pitono/documentation)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
\---
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
\## Contact \& Support
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
For bug reports, feature requests, or questions regarding the Pitono runtime framework, feel free to reach out via email:
|
|
228
|
+
|
|
229
|
+
✉️ \[mampuzha.matthew@outlook.com](mailto:mampuzha.matthew@outlook.com)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
\# pitono-lang
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
A powerful, cross-lingual Python wrapper for the \*\*Pitono\*\* programming language compiler. This package bridges Python environments with the native Windows Pitono compilation engine, allowing you to execute, translate, and configure multi-language Python-based source scripts directly via Python or your Command Line Interface (CLI).
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
\## Features
|
|
10
|
+
|
|
11
|
+
\* 🚀 \*\*Seamless Command Line Call:\*\* Instantly runs `pitono` from anywhere in your Command Prompt once installed (no `.exe` extension required!).
|
|
12
|
+
|
|
13
|
+
\* 🌐 \*\*Multi-Language Translation Engine:\*\* Translate source code or compile it directly between Spanish, Chinese, Hindi, French, Russian, and more.
|
|
14
|
+
|
|
15
|
+
\* 📂 \*\*Localized File Support:\*\* Core C# parsing scales natively across Unicode extensions like `.蟒`, `.pitón`, and `.riesenschlange`.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
\---
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
\## Installation
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
This package requires a \*\*Windows 64-bit environment\*\* with Python 3.8 or higher installed.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
|
|
33
|
+
pip install pitono-lang
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
\---
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
\## Supported Languages \& File Extensions
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
Pitono detects which language your script is written in based entirely on the file extension. Below is the official mapping table:
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
| Language | File Extension | CLI Language Flag | Example Filename |
|
|
52
|
+
|
|
53
|
+
| :--- | :--- | :--- | :--- |
|
|
54
|
+
|
|
55
|
+
| \*\*English\*\* | `.py` | `-en` | `script.py` |
|
|
56
|
+
|
|
57
|
+
| \*\*Chinese\*\* | `.蟒` | `-zh-CN` | `script.蟒` |
|
|
58
|
+
|
|
59
|
+
| \*\*Hindi\*\* | `.अजगर` | `-hi` | `script.अजगर` |
|
|
60
|
+
|
|
61
|
+
| \*\*Spanish\*\* | `.pitón` | `-es` | `script.pitón` |
|
|
62
|
+
|
|
63
|
+
| \*\*French\*\* | `.lepython` | `-fr` | `script.lepython` |
|
|
64
|
+
|
|
65
|
+
| \*\*Bengali\*\* | `.পাইথন` | `-bn` | `script.পাইথন` |
|
|
66
|
+
|
|
67
|
+
| \*\*Portuguese\*\* | `.pitão` | `-pt` | `script.pitão` |
|
|
68
|
+
|
|
69
|
+
| \*\*Russian\*\* | `.питон` | `-ru` | `script.питон` |
|
|
70
|
+
|
|
71
|
+
| \*\*Indonesian\*\* | `.ularpiton` | `-id` | `script.ularpiton` |
|
|
72
|
+
|
|
73
|
+
| \*\*German\*\* | `.riesenschlange` | `-de` | `script.riesenschlange` |
|
|
74
|
+
|
|
75
|
+
| \*\*Japanese\*\* | `.パイソン` | `-ja` | `script.パイソン` |
|
|
76
|
+
|
|
77
|
+
| \*\*Dutch\*\* | `.depython` | `-nl` | `script.depython` |
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
\---
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
\## Command Line Interface (CLI) Usage
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
When you run `pip install pitono-lang`, the tool is automatically mapped directly to your Windows global paths. You can execute it natively by just typing \*\*`pitono`\*\* (omitting the `.exe` extension completely):
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
\### 1. Execute a Localized Script Natively
|
|
94
|
+
|
|
95
|
+
To compile and immediately execute any localized script program, pass the file path as the first argument:
|
|
96
|
+
|
|
97
|
+
```cmd
|
|
98
|
+
|
|
99
|
+
pitono slope-intercept.pitón
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
\### 2. Translate a Script to Another Dialect
|
|
106
|
+
|
|
107
|
+
To translate a file into another target dialect instead of executing it, add the destination language flag as an additional argument:
|
|
108
|
+
|
|
109
|
+
```cmd
|
|
110
|
+
|
|
111
|
+
:: Translates a Spanish file into Python (English) text
|
|
112
|
+
|
|
113
|
+
pitono slope-intercept.pitón -en
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
:: Translates a German file into a Chinese script
|
|
118
|
+
|
|
119
|
+
pitono algebra.riesenschlange -zh-CN
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
\---
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
\## Python API Usage
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
\### 1. Execute Code Blocks
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
|
|
137
|
+
import pitono\_lang
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
pitono\_code = r"""
|
|
142
|
+
|
|
143
|
+
imprimir("Hola me llamo Mateo")
|
|
144
|
+
|
|
145
|
+
nombre_ejemplo = entrada("Como te llamas? ")
|
|
146
|
+
|
|
147
|
+
imprimir("\\nHola, " + nombre_ejemplo)
|
|
148
|
+
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
pitono\_lang.exec(pitono\_code, source\_lang="spanish")
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
\### 2. Translate Code Programmatically
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
|
|
163
|
+
import pitono\_lang
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
spanish\_code = r'imprimir("Hola Mundo")'
|
|
168
|
+
|
|
169
|
+
python\_code = pitono\_lang.translate(spanish\_code, source\_lang="spanish", dest\_lang="english")
|
|
170
|
+
|
|
171
|
+
print(python\_code) # Outputs: print("Hola Mundo")
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
\### 3. Manage Default Language Settings
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
|
|
181
|
+
import pitono\_lang
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
\# Set configuration defaults for system lookups
|
|
186
|
+
|
|
187
|
+
pitono\_lang.setDefaultLanguage("spanish")
|
|
188
|
+
|
|
189
|
+
print(pitono\_lang.getDefaultLanguage()) # Outputs: spanish
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
\---
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
\## Documentation
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
To view the full vocabulary lists, custom keywords, syntax structures, and built-in functions available for coding within each supported language, visit the official documentation page:
|
|
204
|
+
|
|
205
|
+
👉 \[https://mampuzha.org/projects/pitono/documentation](https://mampuzha.org/projects/pitono/documentation)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
\---
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
\## Contact \& Support
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
For bug reports, feature requests, or questions regarding the Pitono runtime framework, feel free to reach out via email:
|
|
218
|
+
|
|
219
|
+
✉️ \[mampuzha.matthew@outlook.com](mailto:mampuzha.matthew@outlook.com)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pitono-lang"
|
|
3
|
+
version = "0.1.2"
|
|
4
|
+
description = "A multilingual Python wrapper for the Pitono compiler, bridging localized programming dialects (Spanish, Chinese, Hindi, German, and more) with native cross-lingual text translation and runtime execution pipelines"
|
|
5
|
+
|
|
6
|
+
readme = { "file" = "README.md", "content-type" = "text/markdown" }
|
|
7
|
+
|
|
8
|
+
requires-python = ">=3.8"
|
|
9
|
+
|
|
10
|
+
authors = [
|
|
11
|
+
{ name = "Matthew Mampuzha", email = "mampuzha.matthew@outlook.com" }
|
|
12
|
+
]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Operating System :: Microsoft :: Windows",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.scripts]
|
|
19
|
+
pitono = "pitono_lang.main:cli_entry"
|
|
20
|
+
|
|
21
|
+
[tool.hatch.build.targets.wheel]
|
|
22
|
+
packages = ["src/pitono_lang"]
|
|
23
|
+
artifacts = ["*.exe", "*.txt", "*.dll", "*.json"]
|
|
24
|
+
|
|
25
|
+
[tool.hatch.build.targets.wheel.hooks.custom]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# src/pitono_lang/__init__.py
|
|
2
|
+
|
|
3
|
+
from .main import (
|
|
4
|
+
exec,
|
|
5
|
+
translate,
|
|
6
|
+
getDefaultLanguage,
|
|
7
|
+
setDefaultLanguage,
|
|
8
|
+
cli_entry
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"exec",
|
|
13
|
+
"translate",
|
|
14
|
+
"getDefaultLanguage",
|
|
15
|
+
"setDefaultLanguage",
|
|
16
|
+
"cli_entry"
|
|
17
|
+
]
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import subprocess
|
|
3
|
+
import os
|
|
4
|
+
import tempfile
|
|
5
|
+
import builtins
|
|
6
|
+
from importlib.resources import files
|
|
7
|
+
from typing import Union, Callable
|
|
8
|
+
|
|
9
|
+
LANG_FLAGS = {
|
|
10
|
+
"english": "-en", "chinese": "-zh-CN", "hindi": "-hi", "spanish": "-es",
|
|
11
|
+
"french": "-fr", "bengali": "-bn", "portuguese": "-pt", "russian": "-ru",
|
|
12
|
+
"indonesian": "-id", "german": "-de", "japanese": "-ja", "dutch": "-nl"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
LANG_EXTENSIONS = {
|
|
16
|
+
"english": ".py", "chinese": ".蟒", "hindi": ".अजगर", "spanish": ".pitón",
|
|
17
|
+
"french": ".lepython", "bengali": ".পাইথন", "portuguese": ".pitão",
|
|
18
|
+
"russian": ".питон", "indonesian": ".ularpiton", "german": ".riesenschlange",
|
|
19
|
+
"japanese": ".パイソン", "dutch": ".depython",
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
def _get_exe_path() -> str:
|
|
23
|
+
"""Helper to locate the bundled pitono compiler executable safely."""
|
|
24
|
+
local_path = os.path.join(os.path.dirname(__file__), "pitono.exe")
|
|
25
|
+
if os.path.exists(local_path):
|
|
26
|
+
return local_path
|
|
27
|
+
|
|
28
|
+
try:
|
|
29
|
+
exe_path = files("pitono_lang").joinpath("pitono.exe")
|
|
30
|
+
if not exe_path.exists():
|
|
31
|
+
raise FileNotFoundError(f"Compiler binary missing at {exe_path}")
|
|
32
|
+
return str(exe_path)
|
|
33
|
+
except Exception as e:
|
|
34
|
+
raise RuntimeError("Failed to resolve the pitono compiler executable path. Ensure the package is installed.") from e
|
|
35
|
+
|
|
36
|
+
def exec(code: str, source_lang: str = "english") -> None:
|
|
37
|
+
"""
|
|
38
|
+
Writes the script to a native extension temporary file right where it is called,
|
|
39
|
+
then launches Pitono.exe inside an isolated terminal window, blocking until closed
|
|
40
|
+
so files are not deleted prematurely.
|
|
41
|
+
"""
|
|
42
|
+
exe_path = _get_exe_path()
|
|
43
|
+
lang = source_lang.lower().strip()
|
|
44
|
+
|
|
45
|
+
if lang not in LANG_EXTENSIONS:
|
|
46
|
+
raise ValueError(f"Unsupported source language: '{source_lang}'")
|
|
47
|
+
|
|
48
|
+
ext = LANG_EXTENSIONS[lang]
|
|
49
|
+
|
|
50
|
+
with tempfile.NamedTemporaryFile(
|
|
51
|
+
mode="w",
|
|
52
|
+
suffix=ext,
|
|
53
|
+
dir=os.getcwd(),
|
|
54
|
+
delete=False,
|
|
55
|
+
encoding="utf-8",
|
|
56
|
+
newline=""
|
|
57
|
+
) as temp_file:
|
|
58
|
+
temp_file.write(code)
|
|
59
|
+
temp_file_path = temp_file.name
|
|
60
|
+
|
|
61
|
+
try:
|
|
62
|
+
raw_filename = os.path.splitext(os.path.basename(temp_file_path))[0]
|
|
63
|
+
|
|
64
|
+
command = f'start "" /wait cmd /c ""{exe_path}" "{temp_file_path}" && pause"'
|
|
65
|
+
|
|
66
|
+
print("[Pitono] Running execution loop in a new window...")
|
|
67
|
+
subprocess.run(command, shell=True, check=True)
|
|
68
|
+
|
|
69
|
+
finally:
|
|
70
|
+
if os.path.exists(temp_file_path):
|
|
71
|
+
os.remove(temp_file_path)
|
|
72
|
+
|
|
73
|
+
local_generated_py = os.path.join(os.getcwd(), f"{raw_filename}.py")
|
|
74
|
+
if os.path.exists(local_generated_py):
|
|
75
|
+
os.remove(local_generated_py)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def translate(
|
|
80
|
+
code: str,
|
|
81
|
+
source_lang: str,
|
|
82
|
+
dest_lang: str = "english",
|
|
83
|
+
return_as_function: bool = False
|
|
84
|
+
) -> Union[str, Callable[[], None]]:
|
|
85
|
+
"""
|
|
86
|
+
Translates source code string configurations to another supported target script syntax.
|
|
87
|
+
"""
|
|
88
|
+
s_lang = source_lang.lower().strip()
|
|
89
|
+
d_lang = dest_lang.lower().strip()
|
|
90
|
+
|
|
91
|
+
if s_lang not in LANG_EXTENSIONS:
|
|
92
|
+
raise ValueError(f"Unsupported source language: '{source_lang}'")
|
|
93
|
+
if d_lang not in LANG_EXTENSIONS:
|
|
94
|
+
raise ValueError(f"Unsupported destination language: '{dest_lang}'")
|
|
95
|
+
|
|
96
|
+
if return_as_function and d_lang != "english":
|
|
97
|
+
raise ValueError("Returning an executable function wrapper is strictly limited to 'english' destination engines.")
|
|
98
|
+
|
|
99
|
+
exe_path = _get_exe_path()
|
|
100
|
+
ext_from = LANG_EXTENSIONS[s_lang]
|
|
101
|
+
ext_to = LANG_EXTENSIONS[d_lang]
|
|
102
|
+
|
|
103
|
+
flags = []
|
|
104
|
+
if d_lang in LANG_FLAGS:
|
|
105
|
+
flags.append(LANG_FLAGS[d_lang])
|
|
106
|
+
|
|
107
|
+
with tempfile.NamedTemporaryFile(mode="w", suffix=ext_from, delete=False, encoding="utf-8", newline="") as temp_file:
|
|
108
|
+
temp_file.write(code)
|
|
109
|
+
temp_file_path = temp_file.name
|
|
110
|
+
|
|
111
|
+
base_name = os.path.splitext(temp_file_path)[0]
|
|
112
|
+
expected_output_path = base_name + ext_to
|
|
113
|
+
|
|
114
|
+
try:
|
|
115
|
+
subprocess.run(
|
|
116
|
+
[exe_path, temp_file_path] + flags,
|
|
117
|
+
capture_output=True,
|
|
118
|
+
check=True
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
if not os.path.exists(expected_output_path):
|
|
122
|
+
raise FileNotFoundError("The Pitono compilation runtime did not emit the expected translation file.")
|
|
123
|
+
|
|
124
|
+
with open(expected_output_path, "r", encoding="utf-8") as f:
|
|
125
|
+
translated_code = f.read()
|
|
126
|
+
|
|
127
|
+
finally:
|
|
128
|
+
if os.path.exists(temp_file_path):
|
|
129
|
+
os.remove(temp_file_path)
|
|
130
|
+
if os.path.exists(expected_output_path):
|
|
131
|
+
os.remove(expected_output_path)
|
|
132
|
+
|
|
133
|
+
if d_lang != "english":
|
|
134
|
+
fallback_py = base_name + ".py"
|
|
135
|
+
if os.path.exists(fallback_py):
|
|
136
|
+
os.remove(fallback_py)
|
|
137
|
+
|
|
138
|
+
if return_as_function:
|
|
139
|
+
def wrapper_function():
|
|
140
|
+
local_vars = {}
|
|
141
|
+
exec_scope = compile(translated_code, "<pitono-runtime>", "exec")
|
|
142
|
+
globals_dict = globals().copy()
|
|
143
|
+
builtins.exec(exec_scope, globals_dict, local_vars)
|
|
144
|
+
return wrapper_function
|
|
145
|
+
|
|
146
|
+
return translated_code
|
|
147
|
+
|
|
148
|
+
def cli_entry() -> None:
|
|
149
|
+
"""Standard systemic wrapper routing shell arguments straight to the direct compiler path."""
|
|
150
|
+
try:
|
|
151
|
+
exe_path = _get_exe_path()
|
|
152
|
+
|
|
153
|
+
args = sys.argv[1:]
|
|
154
|
+
|
|
155
|
+
process = subprocess.run(
|
|
156
|
+
[exe_path] + args,
|
|
157
|
+
stdin=sys.stdin,
|
|
158
|
+
stdout=sys.stdout,
|
|
159
|
+
stderr=sys.stderr
|
|
160
|
+
)
|
|
161
|
+
sys.exit(process.returncode)
|
|
162
|
+
except KeyboardInterrupt:
|
|
163
|
+
sys.exit(130)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def setDefaultLanguage(language: str) -> None:
|
|
167
|
+
"""
|
|
168
|
+
Writes the chosen default language string into the configuration file
|
|
169
|
+
located in the exact same folder as this source file.
|
|
170
|
+
"""
|
|
171
|
+
config_folder = os.path.dirname(os.path.abspath(__file__))
|
|
172
|
+
config_path = os.path.join(config_folder, "language.txt")
|
|
173
|
+
|
|
174
|
+
with open(config_path, "w", encoding="utf-8") as f:
|
|
175
|
+
f.write(language.lower().strip())
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def getDefaultLanguage() -> str:
|
|
179
|
+
"""
|
|
180
|
+
Reads the default language string from the configuration file.
|
|
181
|
+
Returns 'english' as a fallback if the file does not exist yet.
|
|
182
|
+
"""
|
|
183
|
+
config_folder = os.path.dirname(os.path.abspath(__file__))
|
|
184
|
+
config_path = os.path.join(config_folder, "language.txt")
|
|
185
|
+
|
|
186
|
+
if os.path.exists(config_path):
|
|
187
|
+
try:
|
|
188
|
+
with open(config_path, "r", encoding="utf-8") as f:
|
|
189
|
+
saved_lang = f.read().strip()
|
|
190
|
+
return saved_lang if saved_lang else "english"
|
|
191
|
+
except Exception:
|
|
192
|
+
return "english"
|
|
193
|
+
|
|
194
|
+
return "english"
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pitono-lang
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: A multilingual Python wrapper for the Pitono compiler, bridging localized programming dialects (Spanish, Chinese, Hindi, German, and more) with native cross-lingual text translation and runtime execution pipelines
|
|
5
|
+
Author-email: Matthew Mampuzha <mampuzha.matthew@outlook.com>
|
|
6
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
\# pitono-lang
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
A powerful, cross-lingual Python wrapper for the \*\*Pitono\*\* programming language compiler. This package bridges Python environments with the native Windows Pitono compilation engine, allowing you to execute, translate, and configure multi-language Python-based source scripts directly via Python or your Command Line Interface (CLI).
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
\## Features
|
|
20
|
+
|
|
21
|
+
\* 🚀 \*\*Seamless Command Line Call:\*\* Instantly runs `pitono` from anywhere in your Command Prompt once installed (no `.exe` extension required!).
|
|
22
|
+
|
|
23
|
+
\* 🌐 \*\*Multi-Language Translation Engine:\*\* Translate source code or compile it directly between Spanish, Chinese, Hindi, French, Russian, and more.
|
|
24
|
+
|
|
25
|
+
\* 📂 \*\*Localized File Support:\*\* Core C# parsing scales natively across Unicode extensions like `.蟒`, `.pitón`, and `.riesenschlange`.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
\---
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
\## Installation
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
This package requires a \*\*Windows 64-bit environment\*\* with Python 3.8 or higher installed.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
|
|
43
|
+
pip install pitono-lang
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
\---
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
\## Supported Languages \& File Extensions
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
Pitono detects which language your script is written in based entirely on the file extension. Below is the official mapping table:
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
| Language | File Extension | CLI Language Flag | Example Filename |
|
|
62
|
+
|
|
63
|
+
| :--- | :--- | :--- | :--- |
|
|
64
|
+
|
|
65
|
+
| \*\*English\*\* | `.py` | `-en` | `script.py` |
|
|
66
|
+
|
|
67
|
+
| \*\*Chinese\*\* | `.蟒` | `-zh-CN` | `script.蟒` |
|
|
68
|
+
|
|
69
|
+
| \*\*Hindi\*\* | `.अजगर` | `-hi` | `script.अजगर` |
|
|
70
|
+
|
|
71
|
+
| \*\*Spanish\*\* | `.pitón` | `-es` | `script.pitón` |
|
|
72
|
+
|
|
73
|
+
| \*\*French\*\* | `.lepython` | `-fr` | `script.lepython` |
|
|
74
|
+
|
|
75
|
+
| \*\*Bengali\*\* | `.পাইথন` | `-bn` | `script.পাইথন` |
|
|
76
|
+
|
|
77
|
+
| \*\*Portuguese\*\* | `.pitão` | `-pt` | `script.pitão` |
|
|
78
|
+
|
|
79
|
+
| \*\*Russian\*\* | `.питон` | `-ru` | `script.питон` |
|
|
80
|
+
|
|
81
|
+
| \*\*Indonesian\*\* | `.ularpiton` | `-id` | `script.ularpiton` |
|
|
82
|
+
|
|
83
|
+
| \*\*German\*\* | `.riesenschlange` | `-de` | `script.riesenschlange` |
|
|
84
|
+
|
|
85
|
+
| \*\*Japanese\*\* | `.パイソン` | `-ja` | `script.パイソン` |
|
|
86
|
+
|
|
87
|
+
| \*\*Dutch\*\* | `.depython` | `-nl` | `script.depython` |
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
\---
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
\## Command Line Interface (CLI) Usage
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
When you run `pip install pitono-lang`, the tool is automatically mapped directly to your Windows global paths. You can execute it natively by just typing \*\*`pitono`\*\* (omitting the `.exe` extension completely):
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
\### 1. Execute a Localized Script Natively
|
|
104
|
+
|
|
105
|
+
To compile and immediately execute any localized script program, pass the file path as the first argument:
|
|
106
|
+
|
|
107
|
+
```cmd
|
|
108
|
+
|
|
109
|
+
pitono slope-intercept.pitón
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
\### 2. Translate a Script to Another Dialect
|
|
116
|
+
|
|
117
|
+
To translate a file into another target dialect instead of executing it, add the destination language flag as an additional argument:
|
|
118
|
+
|
|
119
|
+
```cmd
|
|
120
|
+
|
|
121
|
+
:: Translates a Spanish file into Python (English) text
|
|
122
|
+
|
|
123
|
+
pitono slope-intercept.pitón -en
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
:: Translates a German file into a Chinese script
|
|
128
|
+
|
|
129
|
+
pitono algebra.riesenschlange -zh-CN
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
\---
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
\## Python API Usage
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
\### 1. Execute Code Blocks
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
|
|
147
|
+
import pitono\_lang
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
pitono\_code = r"""
|
|
152
|
+
|
|
153
|
+
imprimir("Hola me llamo Mateo")
|
|
154
|
+
|
|
155
|
+
nombre_ejemplo = entrada("Como te llamas? ")
|
|
156
|
+
|
|
157
|
+
imprimir("\\nHola, " + nombre_ejemplo)
|
|
158
|
+
|
|
159
|
+
"""
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
pitono\_lang.exec(pitono\_code, source\_lang="spanish")
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
\### 2. Translate Code Programmatically
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
|
|
173
|
+
import pitono\_lang
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
spanish\_code = r'imprimir("Hola Mundo")'
|
|
178
|
+
|
|
179
|
+
python\_code = pitono\_lang.translate(spanish\_code, source\_lang="spanish", dest\_lang="english")
|
|
180
|
+
|
|
181
|
+
print(python\_code) # Outputs: print("Hola Mundo")
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
\### 3. Manage Default Language Settings
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
|
|
191
|
+
import pitono\_lang
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
\# Set configuration defaults for system lookups
|
|
196
|
+
|
|
197
|
+
pitono\_lang.setDefaultLanguage("spanish")
|
|
198
|
+
|
|
199
|
+
print(pitono\_lang.getDefaultLanguage()) # Outputs: spanish
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
\---
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
\## Documentation
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
To view the full vocabulary lists, custom keywords, syntax structures, and built-in functions available for coding within each supported language, visit the official documentation page:
|
|
214
|
+
|
|
215
|
+
👉 \[https://mampuzha.org/projects/pitono/documentation](https://mampuzha.org/projects/pitono/documentation)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
\---
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
\## Contact \& Support
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
For bug reports, feature requests, or questions regarding the Pitono runtime framework, feel free to reach out via email:
|
|
228
|
+
|
|
229
|
+
✉️ \[mampuzha.matthew@outlook.com](mailto:mampuzha.matthew@outlook.com)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/pitono_lang/__init__.py
|
|
4
|
+
src/pitono_lang/main.py
|
|
5
|
+
src/pitono_lang.egg-info/PKG-INFO
|
|
6
|
+
src/pitono_lang.egg-info/SOURCES.txt
|
|
7
|
+
src/pitono_lang.egg-info/dependency_links.txt
|
|
8
|
+
src/pitono_lang.egg-info/entry_points.txt
|
|
9
|
+
src/pitono_lang.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pitono_lang
|