-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
51 lines (42 loc) · 1.1 KB
/
utils.py
File metadata and controls
51 lines (42 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import sys
def expect(arg1,arg2):
if not len(arg1):
Value(f"{arg2} が存在しません")
token = arg1.pop(0)
if token == arg2:
return token
else:
Value(f"{token} が間違っています")
def accept(arg1,arg2):
if len(arg1) > 0:
if arg1[0] == arg2:
return True
return False
def flat(arg):
_list = []
for i in arg:
if type(i) == list:
for j in flat(i):
_list.append(j)
else:
_list.append(i)
return _list
def execute(fun,args):
result = fun(*args)
return result
def using_module(lib,func):
ldict = {}
exec(f"from {lib} import {func}; function = {func}", globals(), ldict)
return ldict['function']
def NotFindFunc(arg1=None):
print(f"NotFoundError --> {arg1}は存在しません")
sys.exit()
def ReferenceError(message):
print(f"ReferenceError --> {message}")
sys.exit()
def ZeroDivision(message):
print(f"ZeroDivisionError --> {message}")
sys.exit()
def Value(message):
print(f"ValueError --> {message}")
sys.exit()