Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import inspect
- class InceptionExtension(Extension):
- def __init__(self):
- super().__init__("inception")
- self.ext = dict()
- def emake_command(self, args=""):
- """makes a new command group"""
- if not args:
- self.debugger.log("emake <name>")
- return
- if args in self.ext:
- self.debugger.log(f"command group '{args}' does already exist!")
- return
- if not args.isidentifier():
- self.debugger.log(f"command group '{args}' is not a valid python identifier")
- return
- code = """
- class {}(Extension):
- def __init__(self):
- super().__init__("cg {}")
- """.format(args, args)
- self.ext[args] = code
- print("ok")
- def eedit_command(self, args=""):
- """edit command group command"""
- if not args or not " " in args:
- self.debugger.log("eedit <group> <command>")
- return
- name = args.split(" ")[0]
- command = args.split(" ")[1]
- if not command.isidentifier():
- self.debugger.log(f"command name {command} is not a python identifier!")
- return
- if not name in self.ext:
- self.debugger.log(f"command group '{name}' does not exist. use 'emake {name}' to create it")
- return
- self.debugger.log("type code (quit to exit abort to abort)")
- code = self.ext[name] + "\n\n" + " def {}_command(self, arg=''):\n".format(command)
- while True:
- i = input("(code)")
- if i == "exit":
- break
- if i == "abort":
- self.debugger.log("aborted!")
- return
- code += " " + i + "\n"
- self.debugger.log(code)
- try:
- exec(code)
- self.debugger.extensions["cg " + name] = eval(f"{name}()")
- self.ext[name] = code
- self.debugger.log("ok")
- except Exception as e:
- self.debugger.log(f"Error: {e}")
- ext = InceptionExtension()
- debugger.extensions[ext.name] = ext
- ext.enable(debugger)
- debugger.log(f"[{ext.name}]: Extension loaded successfully!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement