klippy: Add ConfigWrapper.getchoice method

Add helper function that ensures a config option is one of several
choices.  This helps ensure that a proper error is raised if an
invalid choice is made.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2016-11-30 15:50:28 -05:00
parent 57244de37d
commit 2f97b2d7c2
3 changed files with 10 additions and 5 deletions

View file

@ -161,8 +161,7 @@ class ToolHead:
self.extruder = printer.objects.get('extruder')
kintypes = {'cartesian': cartesian.CartKinematics,
'delta': delta.DeltaKinematics}
kin = config.get('kinematics', 'cartesian')
self.kin = kintypes[kin](printer, config)
self.kin = config.getchoice('kinematics', kintypes)(printer, config)
self.max_speed, self.max_accel = self.kin.get_max_speed()
self.junction_deviation = config.getfloat('junction_deviation', 0.02)
self.move_queue = MoveQueue()