mirror of https://github.com/Desuuuu/klipper.git
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
|
@ -38,10 +38,10 @@ class GCodeParser:
|
||||||
if not is_ready:
|
if not is_ready:
|
||||||
handlers = [h for h in handlers
|
handlers = [h for h in handlers
|
||||||
if getattr(self, 'cmd_'+h+'_when_not_ready', False)]
|
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():
|
for h, f in gcode_handlers.items():
|
||||||
aliases = getattr(self, 'cmd_'+h+'_aliases', [])
|
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
|
return gcode_handlers
|
||||||
def stats(self, eventtime):
|
def stats(self, eventtime):
|
||||||
return "gcodein=%d" % (self.bytes_read,)
|
return "gcodein=%d" % (self.bytes_read,)
|
||||||
|
@ -91,8 +91,8 @@ class GCodeParser:
|
||||||
line = line[:cpos]
|
line = line[:cpos]
|
||||||
# Break command into parts
|
# Break command into parts
|
||||||
parts = self.args_r.split(line)[1:]
|
parts = self.args_r.split(line)[1:]
|
||||||
params = dict((parts[i].upper(), parts[i+1].strip())
|
params = { parts[i].upper(): parts[i+1].strip()
|
||||||
for i in range(0, len(parts), 2))
|
for i in range(0, len(parts), 2) }
|
||||||
params['#original'] = origline
|
params['#original'] = origline
|
||||||
if parts and parts[0].upper() == 'N':
|
if parts and parts[0].upper() == 'N':
|
||||||
# Skip line number at start of command
|
# Skip line number at start of command
|
||||||
|
|
|
@ -182,7 +182,7 @@ class Printer:
|
||||||
self.objects['toolhead'] = toolhead.ToolHead(
|
self.objects['toolhead'] = toolhead.ToolHead(
|
||||||
self, ConfigWrapper(self, 'printer'))
|
self, ConfigWrapper(self, 'printer'))
|
||||||
# Validate that there are no undefined parameters in the config file
|
# Validate that there are no undefined parameters in the config file
|
||||||
valid_sections = dict([(s, 1) for s, o in self.all_config_options])
|
valid_sections = { s: 1 for s, o in self.all_config_options }
|
||||||
for section in self.fileconfig.sections():
|
for section in self.fileconfig.sections():
|
||||||
section = section.lower()
|
section = section.lower()
|
||||||
if section not in valid_sections:
|
if section not in valid_sections:
|
||||||
|
|
|
@ -40,7 +40,7 @@ class SerialReader:
|
||||||
'#output': self.handle_output, 'status': self.handle_status,
|
'#output': self.handle_output, 'status': self.handle_status,
|
||||||
'shutdown': self.handle_output, 'is_shutdown': self.handle_output
|
'shutdown': self.handle_output, 'is_shutdown': self.handle_output
|
||||||
}
|
}
|
||||||
self.handlers = dict(((k, None), v) for k, v in handlers.items())
|
self.handlers = { (k, None): v for k, v in handlers.items() }
|
||||||
def _bg_thread(self):
|
def _bg_thread(self):
|
||||||
response = self.ffi_main.new('struct pull_queue_message *')
|
response = self.ffi_main.new('struct pull_queue_message *')
|
||||||
while 1:
|
while 1:
|
||||||
|
|
Loading…
Reference in New Issue