mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-07 23:17:37 -06:00
klippy: Prefer python dictionary comprehension to dict() call
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
38411fd2e7
commit
01ee9e16c5
3 changed files with 6 additions and 6 deletions
|
@ -38,10 +38,10 @@ class GCodeParser:
|
|||
if not is_ready:
|
||||
handlers = [h for h in handlers
|
||||
if getattr(self, 'cmd_'+h+'_when_not_ready', False)]
|
||||
gcode_handlers = dict((h, getattr(self, 'cmd_'+h)) for h in handlers)
|
||||
gcode_handlers = { h: getattr(self, 'cmd_'+h) for h in handlers }
|
||||
for h, f in gcode_handlers.items():
|
||||
aliases = getattr(self, 'cmd_'+h+'_aliases', [])
|
||||
gcode_handlers.update(dict([(a, f) for a in aliases]))
|
||||
gcode_handlers.update({ a: f for a in aliases })
|
||||
return gcode_handlers
|
||||
def stats(self, eventtime):
|
||||
return "gcodein=%d" % (self.bytes_read,)
|
||||
|
@ -91,8 +91,8 @@ class GCodeParser:
|
|||
line = line[:cpos]
|
||||
# Break command into parts
|
||||
parts = self.args_r.split(line)[1:]
|
||||
params = dict((parts[i].upper(), parts[i+1].strip())
|
||||
for i in range(0, len(parts), 2))
|
||||
params = { parts[i].upper(): parts[i+1].strip()
|
||||
for i in range(0, len(parts), 2) }
|
||||
params['#original'] = origline
|
||||
if parts and parts[0].upper() == 'N':
|
||||
# Skip line number at start of command
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue