def sevalcall(text, localenv, userspaces, message): ret = {} retenv = localenv.copy() try: env = localenv.copy() for user, userenv in userspaces[message.server].items(): env.update(**{user: ReadOnlyNameSpace(userenv, all=True)}) env.update(servers=ReadOnlyNameSpace(userspaces, all=True)) env.update( users=ReadOnlyNameSpace(userspaces[message.server], all=True)) env.update(self=MutableNameSpace( userspaces[message.server][message.nick], all=True)) env.update(globalenv) env.update(message=message) env.update(seval=seval_) #env.update(env=env) responses, retenv = seval(text, env) for key, item in retenv.items(): if key not in globalenv and key not in [ "self", "users", "servers", "seval", "message" ]: ret[key] = item return responses, ret, retenv.setdefault("self", {}) except Exception as e: exc_type, exc_value, exc_traceback = sys.exc_info() print("*** print_tb:") traceback.print_tb(exc_traceback, file=sys.stdout) return e, ret, retenv.setdefault("self", {})
def sevalcall(text, localenv, userspaces, message): ret = {} retenv = localenv.copy() try: env = MutableNameSpace(localenv.copy(), all=True) for user, userenv in userspaces[message.server].items(): env.update(**{user: ReadOnlyNameSpace(userenv, all=True)}) env.update(servers=ReadOnlyNameSpace(userspaces, all=True)) env.update(users=ReadOnlyNameSpace(userspaces[message.server], all=True)) env.update(self=MutableNameSpace(userspaces[message.server][message.nick], all=True)) env.update(globalenv) env.update(message=message) env.update(seval=seval_) #env.update(env=env) responses, retenv = seval(text, env) for key, item in retenv.items(): if key not in globalenv and key not in ["self", "users", "servers", "seval", "message"]: ret[key] = item return responses, ret, retenv.setdefault("self", {}) except Exception as e: exc_type, exc_value, exc_traceback = sys.exc_info() print("*** print_tb:") traceback.print_tb(exc_traceback, file=sys.stdout) return e, ret, retenv.setdefault("self", {})
def seval_(text, env={}): tempenv = dict(globalenv) tempenv.update(env) tempenv.update(seval=seval_) return seval(text, tempenv)[0]
def seval_(text, env={}): tempenv = globalenv.copy() tempenv.update(env) return seval(text, tempenv)