From d065787afcc312fd5bee709a9b8cb15647f0ab08 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 4 Jun 2019 12:41:28 -0400 Subject: gcode_macro: Add support "x in printer" to templates Signed-off-by: Kevin O'Connor --- klippy/extras/gcode_macro.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'klippy/extras/gcode_macro.py') diff --git a/klippy/extras/gcode_macro.py b/klippy/extras/gcode_macro.py index a29e1248..0ad695b6 100644 --- a/klippy/extras/gcode_macro.py +++ b/klippy/extras/gcode_macro.py @@ -28,6 +28,12 @@ class GetStatusWrapper: self.eventtime = self.printer.get_reactor().monotonic() self.cache[sval] = res = dict(po.get_status(self.eventtime)) return res + def __contains__(self, val): + try: + self.__getitem__(val) + except KeyError as e: + return False + return True # Wrapper around a Jinja2 template class TemplateWrapper: -- cgit v1.2.3-70-g09d2