isau 1.0.0__py3-none-any.whl
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.
- isau/__init__.py +1 -0
- isau/core.py +853 -0
- isau-1.0.0.dist-info/METADATA +46 -0
- isau-1.0.0.dist-info/RECORD +6 -0
- isau-1.0.0.dist-info/WHEEL +5 -0
- isau-1.0.0.dist-info/top_level.txt +1 -0
isau/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .core import *
|
isau/core.py
ADDED
|
@@ -0,0 +1,853 @@
|
|
|
1
|
+
"""
|
|
2
|
+
# Isa Utilities (or isau)
|
|
3
|
+
|
|
4
|
+
The Isa Utilities is a import for the python that does you create codes in any language that you want (almost languages):
|
|
5
|
+
|
|
6
|
+
The languages are:
|
|
7
|
+
|
|
8
|
+
1. Batch
|
|
9
|
+
2. VBS (Visual Basic Script)
|
|
10
|
+
3. SQL
|
|
11
|
+
4. C (Using MYSYS2 compiler)
|
|
12
|
+
5. C++ (Using MYSYS2 compiler)
|
|
13
|
+
6. C# (Uning dotnet)
|
|
14
|
+
7. Java Script (Node JS)
|
|
15
|
+
8. React (Creates the project, you edit the code in the python folder)
|
|
16
|
+
9. CSS (to integrate in HTML Script)
|
|
17
|
+
10. Html
|
|
18
|
+
11. Type Script
|
|
19
|
+
12. Ruby
|
|
20
|
+
13. Rust
|
|
21
|
+
14. PHP (Run in PHP CLI)
|
|
22
|
+
15. Lua (raw)
|
|
23
|
+
16. R
|
|
24
|
+
17. Go
|
|
25
|
+
18. Nim
|
|
26
|
+
19. Java
|
|
27
|
+
20. Assembly (NASM Syntax)
|
|
28
|
+
|
|
29
|
+
All languages (or part of they) is runned with a file in the Temp folder with the tempfile import
|
|
30
|
+
|
|
31
|
+
And there was a 2 functions that I had forgotten:
|
|
32
|
+
- Terminal Title
|
|
33
|
+
- Color Initialize
|
|
34
|
+
|
|
35
|
+
# That is it!!!
|
|
36
|
+
To know more, visit the wiki, and I explain each function
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
# IsaUtilities (or isau)
|
|
40
|
+
# Imports
|
|
41
|
+
lazy import sys
|
|
42
|
+
lazy from colorama import init, Fore, Style
|
|
43
|
+
lazy import shutil
|
|
44
|
+
lazy import os
|
|
45
|
+
lazy import subprocess
|
|
46
|
+
lazy import tempfile
|
|
47
|
+
lazy import webbrowser
|
|
48
|
+
lazy import pandas as pd
|
|
49
|
+
lazy import sqlalchemy as sa
|
|
50
|
+
lazy import pyodbc
|
|
51
|
+
lazy import re
|
|
52
|
+
lazy import urllib.parse
|
|
53
|
+
|
|
54
|
+
# To don't create a __cache__ folder
|
|
55
|
+
sys.dont_write_bytecode = True
|
|
56
|
+
|
|
57
|
+
# Author, me :)
|
|
58
|
+
__author__ = "Isaac Martins Brito Sousa (IsaacLindo123 GitHub) <isaac.legalzim10@gmail.com>"
|
|
59
|
+
|
|
60
|
+
# All functions in IsaUtilities (or isau)
|
|
61
|
+
__all__ = ["colorinicialize", "terminaltitle", "sqlsender", "sqlconnectunencrypted", "sqlconnectencrypted", "sqlquery", "cmd", "vbs", "c", "cpp", "cs", "nodejs", "react", "css", "html", "ts", "ruby", "rust", "php", "lua", "r", "go", "nim", "java", "asm"]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# Hello
|
|
65
|
+
print("Hello form Two Points Community!!! IsaUtilities [1.0] imported (obs: no run the colorinitialize() & react(appname, appcode) in module (F5))")
|
|
66
|
+
|
|
67
|
+
# Global variables
|
|
68
|
+
_cfgconnect = None
|
|
69
|
+
|
|
70
|
+
# Defines codes
|
|
71
|
+
def colorinicialize():
|
|
72
|
+
try:
|
|
73
|
+
init(autoreset=True)
|
|
74
|
+
sys.stdout.reconfigure(line_buffering=True)
|
|
75
|
+
print(f"{Fore.GREEN}Colors inicialized...")
|
|
76
|
+
|
|
77
|
+
except AttributeError:
|
|
78
|
+
print("TBMRCL [Cod 002] Don't run this function in module (F5)")
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def terminaltitle(title):
|
|
82
|
+
if not terminaltitle:
|
|
83
|
+
print("TBMRCL [Cod 001] Not defined title")
|
|
84
|
+
return
|
|
85
|
+
sys.stdout.write(f"\x1b]2;{title}\x07")
|
|
86
|
+
sys.stdout.flush()
|
|
87
|
+
|
|
88
|
+
def sqlsender(localdir, filetable):
|
|
89
|
+
try:
|
|
90
|
+
shutil.copy(localdir, filetable)
|
|
91
|
+
|
|
92
|
+
except Exception as e:
|
|
93
|
+
print(f"TBMRCL [Cod 003] Error in archive copy with details: {e}")
|
|
94
|
+
|
|
95
|
+
def sqlconnectencrypted(drv, srv, db, tc, tsc):
|
|
96
|
+
global _cfgconnect
|
|
97
|
+
raw_odbc = (
|
|
98
|
+
f"DRIVER={{{drv}}};"
|
|
99
|
+
f"SERVER={srv};"
|
|
100
|
+
f"DATABASE={db};"
|
|
101
|
+
f"Trusted_Connection={tc};"
|
|
102
|
+
f"Encrypt=yes;"
|
|
103
|
+
f"TrustServerCertificate={tsc}"
|
|
104
|
+
)
|
|
105
|
+
params = urllib.parse.quote_plus(raw_odbc)
|
|
106
|
+
_cfgconnect = f"mssql+pyodbc:///?odbc_connect={params}"
|
|
107
|
+
return _cfgconnect
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def sqlconnectunencrypted(drv, srv, db, tc):
|
|
111
|
+
global _cfgconnect
|
|
112
|
+
raw_odbc = (
|
|
113
|
+
f"DRIVER={{{drv}}};"
|
|
114
|
+
f"SERVER={srv};"
|
|
115
|
+
f"DATABASE={db};"
|
|
116
|
+
f"Trusted_Connection={tc};"
|
|
117
|
+
f"Encrypt=no;"
|
|
118
|
+
f"TrustServerCertificate=yes"
|
|
119
|
+
)
|
|
120
|
+
params = urllib.parse.quote_plus(raw_odbc)
|
|
121
|
+
_cfgconnect = f"mssql+pyodbc:///?odbc_connect={params}"
|
|
122
|
+
return _cfgconnect
|
|
123
|
+
|
|
124
|
+
def sqlquery(qry):
|
|
125
|
+
global _cfgconnect
|
|
126
|
+
if _cfgconnect == None:
|
|
127
|
+
print("TBMRCL [Cod 004] Error in query: You don't defined the sql connect (variable _cfgconnect)")
|
|
128
|
+
return
|
|
129
|
+
try:
|
|
130
|
+
engine = sa.create_engine(_cfgconnect)
|
|
131
|
+
with engine.connect() as conexao:
|
|
132
|
+
df = pd.read_sql(qry, conexao)
|
|
133
|
+
return df
|
|
134
|
+
|
|
135
|
+
except Exception as e:
|
|
136
|
+
print(f"TBMRCL [Cod 005] Error in query: {e}")
|
|
137
|
+
|
|
138
|
+
def cmd(command):
|
|
139
|
+
result = subprocess.run(command, shell=True, capture_output=True, text=True, encoding="cp850")
|
|
140
|
+
print(result.stdout)
|
|
141
|
+
|
|
142
|
+
if result.stderr:
|
|
143
|
+
print(f"TBMRCL [Cod: 010] Error in results \n{result.stderr}")
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def vbs(vbscommand):
|
|
147
|
+
vbscode = f"""{vbscommand}"""
|
|
148
|
+
|
|
149
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".vbs", mode="w", encoding="latin1") as f:
|
|
150
|
+
f.write(vbscode)
|
|
151
|
+
vbsdir = f.name
|
|
152
|
+
|
|
153
|
+
try:
|
|
154
|
+
subprocess.run(["wscript.exe", vbsdir], check=True)
|
|
155
|
+
|
|
156
|
+
except subprocess.CalledProcessError as e:
|
|
157
|
+
print("TBMRCL [Cod 006] Internal Error in VBscript: {e}")
|
|
158
|
+
|
|
159
|
+
except FileNotFoundError:
|
|
160
|
+
so = sys.platform
|
|
161
|
+
print(f"TBMRCL [Cod 007] The 'wscript.exe' is not found in your system, (perhaps your system is a Linux, MacOs or other) (SYSTEM:{so})")
|
|
162
|
+
|
|
163
|
+
except Exception as e:
|
|
164
|
+
print(f"TBMRCL [Cod UNKNW] Unexcepted error: {e}")
|
|
165
|
+
|
|
166
|
+
finally:
|
|
167
|
+
if os.path.exists(vbsdir):
|
|
168
|
+
os.remove(vbsdir)
|
|
169
|
+
|
|
170
|
+
def c(ccode):
|
|
171
|
+
ccode_str = f"{ccode}"
|
|
172
|
+
|
|
173
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".c", mode="w", encoding="utf-8") as f_c:
|
|
174
|
+
f_c.write(ccode_str)
|
|
175
|
+
c_dir = f_c.name
|
|
176
|
+
|
|
177
|
+
exe_dir = c_dir.replace(".c", ".exe")
|
|
178
|
+
|
|
179
|
+
try:
|
|
180
|
+
compile_result = subprocess.run(["gcc", c_dir, "-o", exe_dir], capture_output=True, text=True)
|
|
181
|
+
|
|
182
|
+
if compile_result.returncode != 0:
|
|
183
|
+
print("TBMRCL [Cod 045] Compilation Error in C:")
|
|
184
|
+
print(compile_result.stderr)
|
|
185
|
+
return
|
|
186
|
+
|
|
187
|
+
run_result = subprocess.run([exe_dir], capture_output=True, text=True)
|
|
188
|
+
|
|
189
|
+
if run_result.returncode != 0:
|
|
190
|
+
print("TBMRCL [Cod 046] Execution Error in C:")
|
|
191
|
+
print(run_result.stderr)
|
|
192
|
+
else:
|
|
193
|
+
print(run_result.stdout)
|
|
194
|
+
|
|
195
|
+
except FileNotFoundError:
|
|
196
|
+
print("TBMRCL [Cod 047] GCC compiler not found. Make sure gcc is installed and added to your PATH.")
|
|
197
|
+
|
|
198
|
+
except Exception as e:
|
|
199
|
+
print(f"TBMRCL [Cod UNKNW] Unexpected error: {e}")
|
|
200
|
+
|
|
201
|
+
finally:
|
|
202
|
+
if os.path.exists(c_dir):
|
|
203
|
+
os.remove(c_dir)
|
|
204
|
+
if os.path.exists(exe_dir):
|
|
205
|
+
os.remove(exe_dir)
|
|
206
|
+
|
|
207
|
+
def cpp(cppcode):
|
|
208
|
+
cppcd = f"""{cppcode}"""
|
|
209
|
+
|
|
210
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".cpp", mode="w", encoding="utf8") as f_cpp:
|
|
211
|
+
f_cpp.write(cppcd)
|
|
212
|
+
cppdir = f_cpp.name
|
|
213
|
+
|
|
214
|
+
exedir = cppdir.replace(".cpp", ".exe")
|
|
215
|
+
|
|
216
|
+
try:
|
|
217
|
+
compprocess = subprocess.run(
|
|
218
|
+
["g++", cppdir, "-o", exedir],
|
|
219
|
+
capture_output=True,
|
|
220
|
+
text=True
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
if compprocess.returncode != 0:
|
|
224
|
+
print("TBMRCL [Cod 008] Compilation Error in C++:")
|
|
225
|
+
print(compprocess.stderr)
|
|
226
|
+
|
|
227
|
+
else:
|
|
228
|
+
result = subprocess.run([exedir], capture_output=True, text=True, check=True)
|
|
229
|
+
print(result.stdout)
|
|
230
|
+
|
|
231
|
+
except FileNotFoundError:
|
|
232
|
+
print("TBMRCL [Cod 009] Compilator 'g++' not found, try to install here --> https://www.msys2.org/")
|
|
233
|
+
|
|
234
|
+
except Exception as e:
|
|
235
|
+
print(f"[Cod UNKNW] Unexcepted error: {e}")
|
|
236
|
+
|
|
237
|
+
finally:
|
|
238
|
+
try:
|
|
239
|
+
if os.path.exists(cppdir):
|
|
240
|
+
os.remove(cppdir)
|
|
241
|
+
except Exception:
|
|
242
|
+
pass
|
|
243
|
+
|
|
244
|
+
try:
|
|
245
|
+
if os.path.exists(exedir):
|
|
246
|
+
os.remove(exedir)
|
|
247
|
+
except PermissionError:
|
|
248
|
+
pass
|
|
249
|
+
|
|
250
|
+
def cs(cscode):
|
|
251
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
|
252
|
+
csproj_path = os.path.join(temp_dir, "App.csproj")
|
|
253
|
+
program_path = os.path.join(temp_dir, "Program.cs")
|
|
254
|
+
|
|
255
|
+
csproj_content = """<Project Sdk="Microsoft.NET.Sdk">
|
|
256
|
+
<PropertyGroup>
|
|
257
|
+
<OutputType>Exe</OutputType>
|
|
258
|
+
<TargetFramework>net8.0</TargetFramework>
|
|
259
|
+
<ImplicitUsings>enable</ImplicitUsings>
|
|
260
|
+
<Nullable>enable</Nullable>
|
|
261
|
+
</PropertyGroup>
|
|
262
|
+
</Project>
|
|
263
|
+
"""
|
|
264
|
+
with open(csproj_path, "w", encoding="utf-8") as f:
|
|
265
|
+
f.write(csproj_content)
|
|
266
|
+
|
|
267
|
+
with open(program_path, "w", encoding="utf-8") as f:
|
|
268
|
+
f.write(cscode)
|
|
269
|
+
|
|
270
|
+
try:
|
|
271
|
+
run_result = subprocess.run(
|
|
272
|
+
["dotnet", "run", "--project", csproj_path],
|
|
273
|
+
capture_output=True,
|
|
274
|
+
text=True
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
if run_result.returncode != 0:
|
|
278
|
+
print("TBMRCL [Cod 048] Execution Error in C# (.NET):")
|
|
279
|
+
print(run_result.stderr)
|
|
280
|
+
print(run_result.stdout)
|
|
281
|
+
else:
|
|
282
|
+
print(run_result.stdout.strip())
|
|
283
|
+
|
|
284
|
+
except FileNotFoundError:
|
|
285
|
+
print("TBMRCL [Cod 049] 'dotnet' command not found. Make sure the .NET SDK is installed and added to your PATH.")
|
|
286
|
+
except Exception as e:
|
|
287
|
+
print(f"TBMRCL [Cod UNKNW] Unexpected error in C# execution: {e}")
|
|
288
|
+
|
|
289
|
+
finally:
|
|
290
|
+
if os.path.exists(csproj_path):
|
|
291
|
+
os.remove(csproj_path)
|
|
292
|
+
|
|
293
|
+
if os.path.exists(program_path):
|
|
294
|
+
os.remove(program_path)
|
|
295
|
+
|
|
296
|
+
def nodejs(javascriptcode):
|
|
297
|
+
jscd = f"""{javascriptcode}"""
|
|
298
|
+
|
|
299
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".js", mode="w", encoding="utf-8") as f_js:
|
|
300
|
+
f_js.write(jscd)
|
|
301
|
+
jsdir = f_js.name
|
|
302
|
+
|
|
303
|
+
try:
|
|
304
|
+
result = subprocess.run(["node", jsdir], capture_output=True, text=True)
|
|
305
|
+
|
|
306
|
+
if result.returncode != 0:
|
|
307
|
+
print("TBMRCL [Cod 013] Execution Error in JavaScript (node.js)")
|
|
308
|
+
|
|
309
|
+
else:
|
|
310
|
+
print(result.stdout)
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
except FileNotFoundError:
|
|
314
|
+
print("TBMRCL [Cod 014] 'Node.js' not found, install in this link: https://nodejs.org/en")
|
|
315
|
+
|
|
316
|
+
except Exception as e:
|
|
317
|
+
print(f"TBMRCL [Cod UNKNW] Unexcepted error: {e}")
|
|
318
|
+
|
|
319
|
+
finally:
|
|
320
|
+
if os.path.exists(jsdir):
|
|
321
|
+
os.remove(jsdir)
|
|
322
|
+
|
|
323
|
+
def react(app_name="myreactproject"):
|
|
324
|
+
if app_name is None:
|
|
325
|
+
print("TBMRCL [Cod 016] Define a name to app")
|
|
326
|
+
return
|
|
327
|
+
|
|
328
|
+
try:
|
|
329
|
+
subprocess.run(["npm.cmd", "--version"], capture_output=True, text=True, check=True)
|
|
330
|
+
|
|
331
|
+
prjdir = os.path.join(os.getcwd(), app_name)
|
|
332
|
+
srcdir = os.path.join(prjdir, "src")
|
|
333
|
+
|
|
334
|
+
if not os.path.exists(prjdir):
|
|
335
|
+
|
|
336
|
+
subprocess.run(
|
|
337
|
+
f"npm.cmd create vite@latest {app_name} -- --template react",
|
|
338
|
+
shell=True,
|
|
339
|
+
check=True
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
if os.path.exists(prjdir):
|
|
343
|
+
subprocess.run(["npm.cmd", "install"], cwd=prjdir, shell=True, check=True)
|
|
344
|
+
|
|
345
|
+
else:
|
|
346
|
+
print("TBMRCL [Cod 017] Failed to generate project folder structure...")
|
|
347
|
+
return
|
|
348
|
+
else:
|
|
349
|
+
print(f"Project '{app_name}' is existent, opening the dev server")
|
|
350
|
+
|
|
351
|
+
subprocess.run(f'start cmd /k "cd /d {prjdir} && npm run dev"', shell=True)
|
|
352
|
+
|
|
353
|
+
except FileNotFoundError:
|
|
354
|
+
print("TBMRCL [Cod 018] Error in 'npm.cmd': Not Found")
|
|
355
|
+
print("To run React codes, install Node.js here --> https://nodejs.org/en")
|
|
356
|
+
|
|
357
|
+
except subprocess.CalledProcessError as e:
|
|
358
|
+
print(f"TBMRCL [Cod 019] Error during React setup: {e}")
|
|
359
|
+
|
|
360
|
+
except Exception as e:
|
|
361
|
+
print(f"TBMRCL [Cod UNKNW] Unexcepted Error: {e}")
|
|
362
|
+
|
|
363
|
+
def css(csscode):
|
|
364
|
+
if csscode is None:
|
|
365
|
+
print("TBMRCL [Cod 020] Define a css code")
|
|
366
|
+
|
|
367
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".css", mode="w", encoding="utf8") as f_css:
|
|
368
|
+
f_css.write(csscode)
|
|
369
|
+
cssdir = f_css.name
|
|
370
|
+
|
|
371
|
+
return cssdir
|
|
372
|
+
|
|
373
|
+
def html(htmlcode, stylesheet=None):
|
|
374
|
+
|
|
375
|
+
if stylesheet and os.path.exists(stylesheet):
|
|
376
|
+
tag_css = f'href="file:///{stylesheet}"'
|
|
377
|
+
htmlcode = htmlcode.replace("{stylesheet}", tag_css)
|
|
378
|
+
|
|
379
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".html", mode="w", encoding="utf-8") as f_html:
|
|
380
|
+
f_html.write(htmlcode)
|
|
381
|
+
htmldir = f_html.name
|
|
382
|
+
|
|
383
|
+
try:
|
|
384
|
+
webbrowser.open(f"file://{htmldir}")
|
|
385
|
+
|
|
386
|
+
except Exception as e:
|
|
387
|
+
print("TBMRCL [Code 021] Error to open brownser with HTML, check if you have internet or if you have a brownser: {e}")
|
|
388
|
+
|
|
389
|
+
def ts(tscode):
|
|
390
|
+
tscd = f"{tscode}"
|
|
391
|
+
|
|
392
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".ts", mode="w", encoding="utf-8") as f_ts:
|
|
393
|
+
f_ts.write(tscd)
|
|
394
|
+
tsdir = f_ts.name
|
|
395
|
+
|
|
396
|
+
try:
|
|
397
|
+
command = f'npx --yes tsx "{tsdir}"'
|
|
398
|
+
result = subprocess.run(command, capture_output=True, text=True, shell=True)
|
|
399
|
+
|
|
400
|
+
if result.returncode != 0:
|
|
401
|
+
print("TBMRCL [Cod 022] Execution Error in TypeScript:")
|
|
402
|
+
print(result.stderr)
|
|
403
|
+
|
|
404
|
+
else:
|
|
405
|
+
print(result.stdout)
|
|
406
|
+
|
|
407
|
+
except FileNotFoundError:
|
|
408
|
+
print("TBMRCL [Cod 023] Node.js or npx not found, to run, install node.js here --> https://nodejs.org/en")
|
|
409
|
+
|
|
410
|
+
except Exception as e:
|
|
411
|
+
print(f"TBMRCL [Cod UNKNW] Unexcepted Error: {e}")
|
|
412
|
+
|
|
413
|
+
finally:
|
|
414
|
+
if os.path.exists(tsdir):
|
|
415
|
+
os.remove(tsdir)
|
|
416
|
+
|
|
417
|
+
def ruby(rubycode):
|
|
418
|
+
rbcd = f"{rubycode}"
|
|
419
|
+
|
|
420
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".rb", mode="w", encoding="utf-8") as f_rb:
|
|
421
|
+
f_rb.write(rbcd)
|
|
422
|
+
rbdir = f_rb.name
|
|
423
|
+
|
|
424
|
+
try:
|
|
425
|
+
result = subprocess.run(["ruby", rbdir], capture_output=True, text=True)
|
|
426
|
+
|
|
427
|
+
if result.returncode != 0:
|
|
428
|
+
print("TBMRCL [Cod 024] Excecution Error in Ruby:")
|
|
429
|
+
print(result.stderr)
|
|
430
|
+
|
|
431
|
+
else:
|
|
432
|
+
print(result.stdout)
|
|
433
|
+
|
|
434
|
+
except FileNotFoundError:
|
|
435
|
+
print("TBMRCL [Code 025] Ruby interpreter not found, to run, install here --> https://ruby-lang.org/en")
|
|
436
|
+
|
|
437
|
+
except Exception as e:
|
|
438
|
+
print(f"TBMRCL [Code UNKNW] Unexcepted Error: {e}")
|
|
439
|
+
|
|
440
|
+
finally:
|
|
441
|
+
if os.path.exists(rbdir):
|
|
442
|
+
os.remove(rbdir)
|
|
443
|
+
|
|
444
|
+
def rust(rustcode):
|
|
445
|
+
rustcd = f"{rustcode}"
|
|
446
|
+
|
|
447
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".rs", mode="w", encoding="utf-8") as f_rs:
|
|
448
|
+
f_rs.write(rustcd)
|
|
449
|
+
rustdir = f_rs.name
|
|
450
|
+
|
|
451
|
+
exedir = rustdir.replace(".rs", ".exe")
|
|
452
|
+
|
|
453
|
+
try:
|
|
454
|
+
|
|
455
|
+
compprocess = subprocess.run(
|
|
456
|
+
["rustc", rustdir, "-o", exedir],
|
|
457
|
+
capture_output=True,
|
|
458
|
+
text=True
|
|
459
|
+
)
|
|
460
|
+
|
|
461
|
+
if compprocess.returncode != 0:
|
|
462
|
+
print("TBMRCL [Cod 026] Compilation Error in Rust:")
|
|
463
|
+
print(compprocess.stderr)
|
|
464
|
+
|
|
465
|
+
else:
|
|
466
|
+
result = subprocess.run([exedir], capture_output=True, text=True, check=True)
|
|
467
|
+
print(result.stdout)
|
|
468
|
+
|
|
469
|
+
except FileNotFoundError:
|
|
470
|
+
print("TBMRCL [Cod 027] Rust compile 'rustc' not found, try to download here: https://rust-lang.org")
|
|
471
|
+
|
|
472
|
+
except Exception as e:
|
|
473
|
+
print(f"TBMRCL [Cod UNKNW] Unexcepted Error: {e}")
|
|
474
|
+
|
|
475
|
+
finally:
|
|
476
|
+
if os.path.exists(rustdir):
|
|
477
|
+
os.remove(rustdir)
|
|
478
|
+
|
|
479
|
+
if os.path.exists(exedir):
|
|
480
|
+
try:
|
|
481
|
+
os.remove(exedir)
|
|
482
|
+
|
|
483
|
+
except Exception:
|
|
484
|
+
pass
|
|
485
|
+
|
|
486
|
+
def php(phpcode):
|
|
487
|
+
phpcd = phpcode.strip()
|
|
488
|
+
if not phpcd.startswith("<?php"):
|
|
489
|
+
phpcd = f"<?php\n{phpcd}"
|
|
490
|
+
|
|
491
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".php", mode="w", encoding="utf-8") as f_php:
|
|
492
|
+
f_php.write(phpcd)
|
|
493
|
+
phpdir = f_php.name
|
|
494
|
+
|
|
495
|
+
try:
|
|
496
|
+
result = subprocess.run(["php", phpdir], capture_output=True, text=True)
|
|
497
|
+
|
|
498
|
+
if result.returncode != 0:
|
|
499
|
+
print("TBMRCL [Cod 028] Execution Error in PHP:")
|
|
500
|
+
print(result.stderr)
|
|
501
|
+
|
|
502
|
+
else:
|
|
503
|
+
print(result.stdout)
|
|
504
|
+
|
|
505
|
+
except FileNotFoundError:
|
|
506
|
+
print("TBMRCL [Cod 029] PHP CLI interpreter not found, try to install php cli and add in your PATH --> https://php.net")
|
|
507
|
+
|
|
508
|
+
except Exception as e:
|
|
509
|
+
print(f"TBMRCL [Cod UNKNW] Unexcepted Error: {e}")
|
|
510
|
+
|
|
511
|
+
finally:
|
|
512
|
+
if os.path.exists(phpdir):
|
|
513
|
+
os.remove(phpdir)
|
|
514
|
+
|
|
515
|
+
def lua(luacode):
|
|
516
|
+
luacd = f"{luacode}"
|
|
517
|
+
|
|
518
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".lua", mode="w", encoding="utf-8") as f_lua:
|
|
519
|
+
f_lua.write(luacd)
|
|
520
|
+
luadir = f_lua.name
|
|
521
|
+
|
|
522
|
+
try:
|
|
523
|
+
result = subprocess.run(["lua", luadir], capture_output=True, text=True)
|
|
524
|
+
|
|
525
|
+
if result.returncode != 0:
|
|
526
|
+
print("TBMRCL [Cod 030] Execution Error in Lua:")
|
|
527
|
+
print(result.stderr)
|
|
528
|
+
else:
|
|
529
|
+
print(result.stdout)
|
|
530
|
+
|
|
531
|
+
except FileNotFoundError:
|
|
532
|
+
print("TBMRCL [Cod 031] Lua interpreter not found, try to install and add in your PATH here --> https://lua.org")
|
|
533
|
+
|
|
534
|
+
except Exception as e:
|
|
535
|
+
print(f"TBMRCL [Cod UNKNW] Unexcepted error: {e}")
|
|
536
|
+
|
|
537
|
+
finally:
|
|
538
|
+
if os.path.exists(luadir):
|
|
539
|
+
os.remove(luadir)
|
|
540
|
+
|
|
541
|
+
def r(rcode):
|
|
542
|
+
rcd = f"{rcode}"
|
|
543
|
+
|
|
544
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".R", mode="w", encoding="utf-8") as f_r:
|
|
545
|
+
f_r.write(rcd)
|
|
546
|
+
rdir = f_r.name
|
|
547
|
+
|
|
548
|
+
rscript_exec = shutil.which("Rscript")
|
|
549
|
+
|
|
550
|
+
if not rscript_exec and sys.platform == "win32":
|
|
551
|
+
r_base_dir = r"C:\Program Files\R"
|
|
552
|
+
if os.path.exists(r_base_dir):
|
|
553
|
+
subdirs = os.listdir(r_base_dir)
|
|
554
|
+
for sub in subdirs:
|
|
555
|
+
potential_path = os.path.join(r_base_dir, sub, "bin", "x64", "Rscript.exe")
|
|
556
|
+
if os.path.exists(potential_path):
|
|
557
|
+
rscript_exec = potential_path
|
|
558
|
+
break
|
|
559
|
+
|
|
560
|
+
if not rscript_exec:
|
|
561
|
+
rscript_exec = "Rscript"
|
|
562
|
+
|
|
563
|
+
try:
|
|
564
|
+
result = subprocess.run([rscript_exec, rdir], capture_output=True, text=True)
|
|
565
|
+
|
|
566
|
+
if result.returncode != 0:
|
|
567
|
+
print("TBMRCL [Cod 032] Execution Error in R:")
|
|
568
|
+
print(result.stderr)
|
|
569
|
+
else:
|
|
570
|
+
print(result.stdout)
|
|
571
|
+
|
|
572
|
+
except FileNotFoundError:
|
|
573
|
+
print("TBMRCL [Cod 033] R interpreter / 'Rscript' not found, install R and add to your PATH --> https://www.r-project.org/")
|
|
574
|
+
|
|
575
|
+
except Exception as e:
|
|
576
|
+
print(f"TBMRCL [Cod UNKNW] Unexcepted error: {e}")
|
|
577
|
+
|
|
578
|
+
finally:
|
|
579
|
+
if os.path.exists(rdir):
|
|
580
|
+
os.remove(rdir)
|
|
581
|
+
|
|
582
|
+
def go(gocode):
|
|
583
|
+
gocd = f"{gocode}"
|
|
584
|
+
|
|
585
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".go", mode="w", encoding="utf-8") as f_go:
|
|
586
|
+
f_go.write(gocd)
|
|
587
|
+
godir = f_go.name
|
|
588
|
+
|
|
589
|
+
go_exec = shutil.which("go")
|
|
590
|
+
|
|
591
|
+
if not go_exec and sys.platform == "win32":
|
|
592
|
+
default_go_path = r"C:\Program Files\Go\bin\go.exe"
|
|
593
|
+
if os.path.exists(default_go_path):
|
|
594
|
+
go_exec = default_go_path
|
|
595
|
+
|
|
596
|
+
if not go_exec:
|
|
597
|
+
go_exec = "go"
|
|
598
|
+
|
|
599
|
+
try:
|
|
600
|
+
result = subprocess.run([go_exec, "run", godir], capture_output=True, text=True)
|
|
601
|
+
|
|
602
|
+
if result.returncode != 0:
|
|
603
|
+
print("TBMRCL [Cod 034] Execution Error in Go:")
|
|
604
|
+
print(result.stderr)
|
|
605
|
+
|
|
606
|
+
else:
|
|
607
|
+
print(result.stdout)
|
|
608
|
+
|
|
609
|
+
except FileNotFoundError:
|
|
610
|
+
print("TBMRCL [Cod 035] Go compiler not found, try to install here --> https://golang.org/dl/")
|
|
611
|
+
|
|
612
|
+
except Exception as e:
|
|
613
|
+
print(f"TBMRCL [Cod UNKNW] Unexcepted Error: {e}")
|
|
614
|
+
|
|
615
|
+
finally:
|
|
616
|
+
if os.path.exists(godir):
|
|
617
|
+
os.remove(godir)
|
|
618
|
+
|
|
619
|
+
def nim(nimcode):
|
|
620
|
+
nimcd = f"{nimcode}"
|
|
621
|
+
|
|
622
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".nim", mode="w", encoding="utf-8") as f_nim:
|
|
623
|
+
f_nim.write(nimcd)
|
|
624
|
+
nimdir = f_nim.name
|
|
625
|
+
|
|
626
|
+
exedir = nimdir.replace(".nim", ".exe" if sys.platform == "win32" else "")
|
|
627
|
+
|
|
628
|
+
try:
|
|
629
|
+
comp_result = subprocess.run(["nim", "c", "-d:release", "--verbosity:0", "--hints:off", nimdir], capture_output=True, text=True)
|
|
630
|
+
|
|
631
|
+
if comp_result.returncode != 0:
|
|
632
|
+
print("TBMRCL [Cod 053] Compilation Error in Nim:")
|
|
633
|
+
print(comp_result.stderr)
|
|
634
|
+
else:
|
|
635
|
+
run_result = subprocess.run([exedir], capture_output=True, text=True)
|
|
636
|
+
print(run_result.stdout)
|
|
637
|
+
if run_result.stderr:
|
|
638
|
+
print(run_result.stderr)
|
|
639
|
+
|
|
640
|
+
except FileNotFoundError:
|
|
641
|
+
print("TBMRCL [Cod 054] Nim compiler not found, install Nim and add to your PATH --> https://nim-lang.org/")
|
|
642
|
+
|
|
643
|
+
except Exception as e:
|
|
644
|
+
print(f"TBMRCL [Cod UNKNW] Unexpected Error: {e}")
|
|
645
|
+
|
|
646
|
+
finally:
|
|
647
|
+
for path in [nimdir, exedir]:
|
|
648
|
+
if path and os.path.exists(path):
|
|
649
|
+
try:
|
|
650
|
+
os.remove(path)
|
|
651
|
+
except:
|
|
652
|
+
pass
|
|
653
|
+
|
|
654
|
+
def java(javacode):
|
|
655
|
+
if "public class" not in javacode:
|
|
656
|
+
javacode = f"""
|
|
657
|
+
public class Main {{
|
|
658
|
+
public static void main(String[] args) {{
|
|
659
|
+
{javacode}
|
|
660
|
+
}}
|
|
661
|
+
}}
|
|
662
|
+
"""
|
|
663
|
+
|
|
664
|
+
match_var = re.search(r"public\s+class\s+(\w+)", javacode)
|
|
665
|
+
class_name = match_var.group(1) if match_var else "Main"
|
|
666
|
+
|
|
667
|
+
tmp_dir = tempfile.mkdtemp()
|
|
668
|
+
javadir = os.path.join(tmp_dir, f"{class_name}.java")
|
|
669
|
+
|
|
670
|
+
try:
|
|
671
|
+
with open(javadir, "w", encoding="utf-8") as f_java:
|
|
672
|
+
f_java.write(javacode)
|
|
673
|
+
|
|
674
|
+
compprocess = subprocess.run(["javac", "-d", tmp_dir, javadir], capture_output=True, text=True)
|
|
675
|
+
|
|
676
|
+
if compprocess.returncode != 0:
|
|
677
|
+
print("TBMRCL [Cod 038] Compilation Error in Java:")
|
|
678
|
+
print(compprocess.stderr)
|
|
679
|
+
|
|
680
|
+
else:
|
|
681
|
+
runprocess = subprocess.run(
|
|
682
|
+
["java", "-cp", tmp_dir, class_name],
|
|
683
|
+
capture_output=True, text=True
|
|
684
|
+
)
|
|
685
|
+
|
|
686
|
+
if runprocess.returncode != 0:
|
|
687
|
+
print("TBMRCL [Cod 039] Execution Error in Java:")
|
|
688
|
+
print(runprocess.stderr)
|
|
689
|
+
|
|
690
|
+
else:
|
|
691
|
+
print(runprocess.stdout)
|
|
692
|
+
|
|
693
|
+
except FileNotFoundError:
|
|
694
|
+
print("TBMRCL [Cod 040] Java JDK ('javac' / 'java') not found, install Java JDK and add to your PATH --> https://adoptium.net/")
|
|
695
|
+
|
|
696
|
+
except Exception as e:
|
|
697
|
+
print(f"TBMRCL [Cod UNKNW] Unexcepted Error {e}")
|
|
698
|
+
|
|
699
|
+
finally:
|
|
700
|
+
if os.path.exists(tmp_dir):
|
|
701
|
+
shutil.rmtree(tmp_dir, ignore_errors=True)
|
|
702
|
+
|
|
703
|
+
def asm(asmcode):
|
|
704
|
+
asmcd = f"{asmcode}"
|
|
705
|
+
|
|
706
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".asm", mode="w", encoding="utf-8") as f_asm:
|
|
707
|
+
f_asm.write(asmcd)
|
|
708
|
+
asmdir = f_asm.name
|
|
709
|
+
|
|
710
|
+
objdir = asmdir.replace(".asm", ".obj" if sys.platform == "win32" else ".o")
|
|
711
|
+
exedir = asmdir.replace(".asm", ".exe" if sys.platform == "win32" else "")
|
|
712
|
+
|
|
713
|
+
try:
|
|
714
|
+
format_flag = "win64" if sys.platform == "win32" else "elf64"
|
|
715
|
+
|
|
716
|
+
nasm_process = subprocess.run(
|
|
717
|
+
["nasm", "-f", format_flag, asmdir, "-o", objdir],
|
|
718
|
+
capture_output=True,
|
|
719
|
+
text=True
|
|
720
|
+
)
|
|
721
|
+
|
|
722
|
+
if nasm_process.returncode != 0:
|
|
723
|
+
print("TBMRCL [Cod 041] Assembly Error (NASM):")
|
|
724
|
+
print(nasm_process.stderr)
|
|
725
|
+
else:
|
|
726
|
+
link_process = subprocess.run(
|
|
727
|
+
["gcc", objdir, "-o", exedir],
|
|
728
|
+
capture_output=True,
|
|
729
|
+
text=True
|
|
730
|
+
)
|
|
731
|
+
|
|
732
|
+
if link_process.returncode != 0:
|
|
733
|
+
print("TBMRCL [Cod 042] Linking Error in Assembly:")
|
|
734
|
+
print(link_process.stderr)
|
|
735
|
+
else:
|
|
736
|
+
run_cmd = [exedir] if sys.platform == "win32" else [f"./{os.path.basename(exedir)}"]
|
|
737
|
+
result = subprocess.run(run_cmd, capture_output=True, text=True, check=True, cwd=os.path.dirname(asmdir))
|
|
738
|
+
print(result.stdout)
|
|
739
|
+
|
|
740
|
+
except FileNotFoundError:
|
|
741
|
+
print("TBMRCL [Cod 043] Assembler 'nasm' or linker 'gcc' not found. Install NASM and GCC/MinGW -> https://www.nasm.us/")
|
|
742
|
+
|
|
743
|
+
except Exception as e:
|
|
744
|
+
print(f"TBMRCL [Cod UNKNW] Unexpected error: {e}")
|
|
745
|
+
|
|
746
|
+
finally:
|
|
747
|
+
for path in [asmdir, objdir, exedir]:
|
|
748
|
+
if path and os.path.exists(path):
|
|
749
|
+
try:
|
|
750
|
+
os.remove(path)
|
|
751
|
+
except:
|
|
752
|
+
pass
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
|
|
853
|
+
# By IsaacLindo123 (github)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: isau
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A toolkit that do you to program in almost all languages
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/Isaaclindo123/my-imports
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
9
|
+
Requires-Python: >=3.15
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# Isa Utilities (or isau)
|
|
13
|
+
|
|
14
|
+
The Isa Utilities is a import for the python that does you create codes in any language that you want (almost languages):
|
|
15
|
+
|
|
16
|
+
The languages are:
|
|
17
|
+
|
|
18
|
+
1. Batch
|
|
19
|
+
2. VBS (Visual Basic Script)
|
|
20
|
+
3. SQL
|
|
21
|
+
4. C (Using MYSYS2 compiler)
|
|
22
|
+
5. C++ (Using MYSYS2 compiler)
|
|
23
|
+
6. C# (Uning dotnet)
|
|
24
|
+
7. Java Script (Node JS)
|
|
25
|
+
8. React (Creates the project, you edit the code in the python folder)
|
|
26
|
+
9. CSS (to integrate in HTML Script)
|
|
27
|
+
10. Html
|
|
28
|
+
11. Type Script
|
|
29
|
+
12. Ruby
|
|
30
|
+
13. Rust
|
|
31
|
+
14. PHP (Run in PHP CLI)
|
|
32
|
+
15. Lua (raw)
|
|
33
|
+
16. R
|
|
34
|
+
17. Go
|
|
35
|
+
18. Nim
|
|
36
|
+
19. Java
|
|
37
|
+
20. Assembly (NASM Syntax)
|
|
38
|
+
|
|
39
|
+
All languages (or part of they) is runned with a file in the Temp folder with the tempfile import
|
|
40
|
+
|
|
41
|
+
And there was a 2 functions that I had forgotten:
|
|
42
|
+
- Terminal Title
|
|
43
|
+
- Color Initialize
|
|
44
|
+
|
|
45
|
+
# That is it!!!
|
|
46
|
+
To know more, visit the [wiki](https://github.com/Isaaclindo123/My-Imports/wiki), and I explain each function
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
isau/__init__.py,sha256=79Ih1151rfcqZdr7F8HSZSTs_iT2SKd1xCkehMsXeXs,19
|
|
2
|
+
isau/core.py,sha256=OuK8At6pRxAhk6HD2spOmaSbq7b53zQut5KnJHbtMvM,24430
|
|
3
|
+
isau-1.0.0.dist-info/METADATA,sha256=Xjkq9XD0icNrkT9xMe3qj61SO60MfyvWUJrFBjpU3ac,1298
|
|
4
|
+
isau-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
5
|
+
isau-1.0.0.dist-info/top_level.txt,sha256=PaWgrDrXbPIX0CALp4Uv2FVk5tILm5SRxpQSoudfkbs,5
|
|
6
|
+
isau-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
isau
|