Browse Source

Fix #53

error-handling
Jiří Kalvoda 1 year ago
parent
commit
f49e791807
  1. 6
      src/formatitko/command_util.py

6
src/formatitko/command_util.py

@ -16,9 +16,9 @@ def parse_command(code: str) -> CommandCallable:
for line in code_lines: for line in code_lines:
indented_code_lines.append(("\t" if tabs else " ")+line) indented_code_lines.append(("\t" if tabs else " ")+line)
code = "def command(element: Command, context: Context) -> list[Element]:\n"+"\n".join(indented_code_lines) code = "def command(element: Command, context: Context) -> list[Element]:\n"+"\n".join(indented_code_lines)
command_env = command_env.__dict__ env = {**command_env.__dict__}
exec(code, command_env) exec(code, env)
return command_env["command"] return env["command"]
# This function is called in trasform.py, defining a command which can be # This function is called in trasform.py, defining a command which can be
# called later # called later

Loading…
Cancel
Save