aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-09-02 12:51:37 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-09-02 12:53:34 -0400
commit18b04ffe6815987284130337e5eb4f46f3ba1c69 (patch)
treecbee425257e596423beae12bc2624bc7e1c603e8 /klippy
parent50196c7141d28622794b92c0b4445ad08f01262e (diff)
downloadkutter-18b04ffe6815987284130337e5eb4f46f3ba1c69.tar.gz
kutter-18b04ffe6815987284130337e5eb4f46f3ba1c69.tar.xz
kutter-18b04ffe6815987284130337e5eb4f46f3ba1c69.zip
klippy: Rename lookup_module_objects() to lookup_objects()
Rename the method and support returning all known objects. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/klippy.py15
-rw-r--r--klippy/toolhead.py3
2 files changed, 11 insertions, 7 deletions
diff --git a/klippy/klippy.py b/klippy/klippy.py
index d3fedf10..d5dc8dae 100644
--- a/klippy/klippy.py
+++ b/klippy/klippy.py
@@ -164,11 +164,14 @@ class Printer:
if default is ConfigWrapper.sentinel:
raise self.config_error("Unknown config object '%s'" % (name,))
return default
- def lookup_module_objects(self, module_name):
- prefix = module_name + ' '
- objs = [self.objects[n] for n in self.objects if n.startswith(prefix)]
- if module_name in self.objects:
- return [self.objects[module_name]] + objs
+ def lookup_objects(self, module=None):
+ if module is None:
+ return list(self.objects.items())
+ prefix = module + ' '
+ objs = [(n, self.objects[n])
+ for n in self.objects if n.startswith(prefix)]
+ if module in self.objects:
+ return [(module, self.objects[module])] + objs
return objs
def set_rollover_info(self, name, info):
logging.info(info)
@@ -280,7 +283,7 @@ class Printer:
try:
self._stats(self.reactor.monotonic(), force_output=True)
if run_result == 'firmware_restart':
- for m in self.lookup_module_objects('mcu'):
+ for n, m in self.lookup_objects(module='mcu'):
m.microcontroller_restart()
for cb in self.state_cb:
cb('disconnect')
diff --git a/klippy/toolhead.py b/klippy/toolhead.py
index abc0874a..71a2b7e6 100644
--- a/klippy/toolhead.py
+++ b/klippy/toolhead.py
@@ -196,7 +196,8 @@ class ToolHead:
def __init__(self, config):
self.printer = config.get_printer()
self.reactor = self.printer.get_reactor()
- self.all_mcus = self.printer.lookup_module_objects('mcu')
+ self.all_mcus = [
+ m for n, m in self.printer.lookup_objects(module='mcu')]
self.mcu = self.all_mcus[0]
self.move_queue = MoveQueue()
self.commanded_pos = [0., 0., 0., 0.]