Skip to content
This repository was archived by the owner on Nov 16, 2021. It is now read-only.

Commit 2482dc5

Browse files
author
Glitch
committed
Added os.userinfo function
1 parent 76b644d commit 2482dc5

File tree

2 files changed

+56
-34
lines changed

2 files changed

+56
-34
lines changed

index.pys

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Note that this also belongs to static folder
22

3-
var jb = "eee";
3+
import("os");
4+
5+
var jb = os.userinfo();
46

57
// import("time");
68
// import("os");

main.py

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import time, os, sys, getpass, re, string
22

3-
#Note: Make modules to contribute to this language
4-
53
fp = input('FilePath: ')
64

75
if '.pys' in fp:#hmmmm
@@ -52,7 +50,7 @@ class TemplateError(Exception):
5250
input1 = "Undefined input"
5351
input2 = "Undefined input"
5452
input3 = "Undefined input"
55-
functions = ["time.time(", "os.system(", "os.userinfo(","time.sleep(","time.strftime(","window.alert(","console.print(","alert(","console.input(","window.prompt(","prompt(","if "]
53+
functions = ["os.userinfo(","time.strftime(","window.alert(","console.print(","alert(","console.input(","window.prompt(","prompt("]
5654

5755

5856
def timeTIME():
@@ -98,6 +96,30 @@ def osSYSTEM():
9896
else:
9997
raise InvalidModuleError("The 'os' module isn't imported or it doesn't exist!")
10098

99+
def osUSERINFO():
100+
if os_module == 1:
101+
wrd = "os.userinfo("
102+
global res
103+
res = lines.partition(wrd)[2]
104+
105+
if " " in res:
106+
raise InvalidSyntaxError("'os.userinfo' cannot include spaces!")
107+
else:
108+
if ");" in res:
109+
res = res.replace(");","")
110+
else:
111+
raise InvalidSyntaxError("'os.userinfo' must have ');'!")
112+
if res == "" or res == " ":
113+
try:
114+
print(os.environ["REPL_OWNER"])
115+
except:
116+
raise InvalidModuleError("This function does not exist on your device!")
117+
else:
118+
raise InvalidModuleError("'os.userinfo' must be empty!")
119+
else:
120+
raise InvalidModuleError("The 'os' module isn't imported or it doesn't exist!")
121+
122+
101123
'''
102124
Note that ascii characters are used like this in pyscript:
103125
/1234 or /u1243
@@ -404,14 +426,40 @@ def CONSOLEprint():
404426
idk = "".join(idk)
405427
newvar = newvar.replace(idk, "")
406428

407-
if "'" in newvar or "\"" in newvar or "`" in newvar:
429+
if "'" in newvar or "\"" in newvar or "`" in newvar or "os.userinfo(" in newvar:
408430
if newvar in functions:
409-
e
431+
if "console.print(" in newvar:
432+
CONSOLEprint()
433+
elif "window.alert(" in newvar:
434+
WINDOWalert()
435+
elif "alert(" in newvar:
436+
alert()
437+
438+
elif "window.prompt(" in newvar:
439+
e
440+
elif "prompt(" in newvar:
441+
e
442+
elif "console.input(" in newvar:
443+
e
444+
445+
elif "os.userinfo(" in newvar:
446+
osUSERINFO()
447+
allvars[res] = os.environ["REPL_OWNER"]
448+
449+
elif "time.strftime(" in newvar:
450+
if time_module == 1:
451+
timeSTRFTIME()
452+
#allvars[] = time.strftime()
453+
else:
454+
raise InvalidModuleError("The 'time' module isn't imported or it doesn't exist!")
455+
410456
else:
411457
newvar = str(newvar) # makes sure its a string
412458
if newvar[-1] == "'" and newvar[0] == "'" or newvar[-1] == "\"" and newvar[0] == "\"" or newvar[-1] == "`" and newvar[0] == "`":
413459
newvar = newvar.replace(newvar[-1], "")
414460
#newvar = newvar.replace(newvar[0], "")
461+
elif "os.userinfo(" in newvar:
462+
pass
415463
else:
416464
raise InvalidSyntaxError("Starting quotations and end quotations must be the same!")
417465
allvars[newvar] = newvar
@@ -426,34 +474,6 @@ def CONSOLEprint():
426474
raise InvalidSyntaxError("Variables cannot include spaces!")
427475
else:
428476
allvars[newvar] = 0
429-
430-
'''
431-
try:
432-
newvar2 = lines.partition(wrd)[3]
433-
split_string = newvar2.split("\")", -1)
434-
newvar2.replace(")","")
435-
newvar2.replace('\"', '')
436-
newvar2 = newvar2.replace("=",'')
437-
newvar2 = newvar2.replace(" ","")
438-
print(newvar2)
439-
newvar2 = split_string[0]
440-
if newvar2 == "=":
441-
pass
442-
else:
443-
newvar2 = lines.partition(wrd)[4]
444-
split_string = newvar2.split("\")", -1)
445-
newvar2.replace(")","")
446-
newvar2.replace('\"', '')
447-
newvar2 = split_string[0]
448-
449-
if newvar2 == "=":
450-
pass
451-
else:
452-
pass
453-
#raise InvalidSyntaxError("")
454-
except:
455-
pass
456-
'''
457477

458478

459479
elif "window.prompt(" in lines:

0 commit comments

Comments
 (0)