Fix recursion, if module requires itself
This commit is contained in:
parent
b3853e5157
commit
17009172b7
|
@ -24,9 +24,9 @@ g = Bunch()
|
|||
paths = []
|
||||
loaded = Bunch()
|
||||
|
||||
def docode(st,name = "Unknown"):
|
||||
def docode(st,name = "Unknown",glb = False):
|
||||
code = compile(st,name,"exec")
|
||||
glb = Bunch()
|
||||
if glb == False: glb = Bunch()
|
||||
glb[distro] = me
|
||||
glb[distro + "l"] = Bunch()
|
||||
glb[distro + "l"].s = name
|
||||
|
@ -38,8 +38,8 @@ def docode(st,name = "Unknown"):
|
|||
exec(code,glb)
|
||||
return glb
|
||||
|
||||
def dofile(path):
|
||||
return docode(open(path,"rb").read(),path)
|
||||
def dofile(path,*args,**kwargs):
|
||||
return docode(open(path,"rb").read(),path,*args,**kwargs)
|
||||
|
||||
def dorequire(name,*args,**kwargs):
|
||||
name = name.replace("/",".").replace("\\",".")
|
||||
|
@ -53,7 +53,8 @@ def require(name,env=False,*args,**kwargs):
|
|||
if env == False: env = loaded
|
||||
if type(env) != Bunch: raise Exception("require: env is not of type " +distro+ ".Bunch")
|
||||
if not name in env:
|
||||
env[name] = dorequire(name,*args,**kwargs)
|
||||
env[name] = Bunch()
|
||||
env[name] = dorequire(name,*args,glb=env[name],**kwargs)
|
||||
return env[name]
|
||||
|
||||
# PROGRAM
|
||||
|
|
Loading…
Reference in New Issue