49 lines
971 B
Python
Executable file
49 lines
971 B
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import subprocess
|
|
import re
|
|
|
|
def echo (bstr):
|
|
print (bstr.decode(), end='')
|
|
|
|
def script (*args):
|
|
args = ('./script.sh',) + args
|
|
p = subprocess.run (args, stdout=subprocess.PIPE)
|
|
p = p.stdout
|
|
return p
|
|
|
|
def scriptLines (*args):
|
|
p = script (*args)
|
|
p = p.split (b'\n')
|
|
del p[-1]
|
|
return p
|
|
|
|
def unescape (bstr):
|
|
subs = (
|
|
('<','\033[32m/*'),
|
|
('>','*/\033[0m'),
|
|
('\1','\n'),
|
|
('\2','<'),
|
|
('\3','>'))
|
|
for a,b in subs:
|
|
a = a.encode()
|
|
b = b.encode()
|
|
bstr = bstr.replace (a, b)
|
|
return bstr
|
|
|
|
def isIdent (bstr):
|
|
if len (bstr) < 3:
|
|
return False
|
|
elif re.search (b'_', bstr):
|
|
return True
|
|
elif re.search (b'^[A-Z0-9]*$', bstr):
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
def autoBytes (arg):
|
|
if type (arg) is str:
|
|
arg = arg.encode()
|
|
elif type (arg) is int:
|
|
arg = str(arg).encode()
|
|
return arg
|