From ac8f6dfe20cbd59d6c6f5a187e430e16afaee9a8 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 28 May 2019 10:59:12 -0400 Subject: [PATCH] gcode_macro: Rename "status" helper to "printer" Signed-off-by: Kevin O'Connor --- docs/Config_Changes.md | 3 +++ klippy/extras/gcode_macro.py | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/Config_Changes.md b/docs/Config_Changes.md index 7ce25a1b..f317db5d 100644 --- a/docs/Config_Changes.md +++ b/docs/Config_Changes.md @@ -6,6 +6,9 @@ All dates in this document are approximate. # Changes +20190528: The magic "status" variable in gcode_macro template +evaluation has been renamed to "printer". + 20190520: The SET_GCODE_OFFSET command has changed; update any g-code macros accordingly. The command will no longer apply the requested offset to the next G1 command. The old behavior may be approximated by diff --git a/klippy/extras/gcode_macro.py b/klippy/extras/gcode_macro.py index ee28ccbd..57b2153d 100644 --- a/klippy/extras/gcode_macro.py +++ b/klippy/extras/gcode_macro.py @@ -11,8 +11,8 @@ import jinja2 # Template handling ###################################################################### -# Wrapper for "status" access to printer object get_status() methods -class StatusWrapper: +# Wrapper for access to printer object get_status() methods +class GetStatusWrapper: def __init__(self, printer, eventtime=None): self.printer = printer self.eventtime = eventtime @@ -43,10 +43,10 @@ class TemplateWrapper: logging.exception(msg) raise printer.config_error(msg) def create_status_wrapper(self, eventtime=None): - return StatusWrapper(self.printer, eventtime) + return GetStatusWrapper(self.printer, eventtime) def render(self, context=None): if context is None: - context = {'status': self.create_status_wrapper()} + context = {'printer': self.create_status_wrapper()} try: return str(self.template.render(context)) except Exception as e: @@ -95,7 +95,7 @@ class GCodeMacro: "Macro %s called recursively" % (self.alias,)) kwparams = dict(self.kwparams) kwparams.update(params) - kwparams['status'] = self.template.create_status_wrapper() + kwparams['printer'] = self.template.create_status_wrapper() kwparams['params'] = params self.in_script = True try: