aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-06-06 12:35:13 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-06-06 12:35:13 -0400
commit01ee9e16c5f7820b74d1018c130a842767edd44b (patch)
tree576b2cf5838812e13f410b3cde2bc5d216cb537a
parent38411fd2e7610eb8049645d4318bcec1f472218b (diff)
downloadkutter-01ee9e16c5f7820b74d1018c130a842767edd44b.tar.gz
kutter-01ee9e16c5f7820b74d1018c130a842767edd44b.tar.xz
kutter-01ee9e16c5f7820b74d1018c130a842767edd44b.zip
klippy: Prefer python dictionary comprehension to dict() call
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/gcode.py8
-rw-r--r--klippy/klippy.py2
-rw-r--r--klippy/serialhdl.py2
3 files changed, 6 insertions, 6 deletions
diff --git a/klippy/gcode.py b/klippy/gcode.py
index f2a66d88..96caacb7 100644
--- a/klippy/gcode.py
+++ b/klippy/gcode.py
@@ -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
diff --git a/klippy/klippy.py b/klippy/klippy.py
index 73819f62..58898374 100644
--- a/klippy/klippy.py
+++ b/klippy/klippy.py
@@ -182,7 +182,7 @@ class Printer:
self.objects['toolhead'] = toolhead.ToolHead(
self, ConfigWrapper(self, 'printer'))
# 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():
section = section.lower()
if section not in valid_sections:
diff --git a/klippy/serialhdl.py b/klippy/serialhdl.py
index 85e3b80e..d6179a4b 100644
--- a/klippy/serialhdl.py
+++ b/klippy/serialhdl.py
@@ -40,7 +40,7 @@ class SerialReader:
'#output': self.handle_output, 'status': self.handle_status,
'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):
response = self.ffi_main.new('struct pull_queue_message *')
while 1: