🎨 Get rid of py2 leftovers
This commit is contained in:
1 parent
11e30150b7
commit
bea7f34887
15 files changed
+44
-49
No files matched your search
@@ -34,7 +34,7 @@ class Printjob(ProtocolListener, ListenerAware, metaclass=ABCMeta):
|
||||
if event_data is None:
|
||||
event_data = {}
|
||||
|
||||
super(Printjob, self).__init__()
|
||||
super().__init__()
|
||||
self._logger = logging.getLogger(__name__)
|
||||
self._start = None
|
||||
self._protocol = None
|
||||
@@ -284,7 +284,7 @@ class LocalFilePrintjob(StoragePrintjob):
|
||||
|
||||
def cancel(self, error=False, user=None, tags=None, **kwargs):
|
||||
self._cancel_pos = self.pos
|
||||
super(LocalFilePrintjob, self).cancel(error=error, user=user, tags=tags, **kwargs)
|
||||
super().cancel(error=error, user=user, tags=tags, **kwargs)
|
||||
|
||||
def get_next(self):
|
||||
from octoprint.util import to_unicode
|
||||
@@ -339,11 +339,10 @@ class LocalFilePrintjob(StoragePrintjob):
|
||||
from octoprint.util import bom_aware_open
|
||||
|
||||
with bom_aware_open(self._path, encoding=self._encoding, error="replace") as f:
|
||||
for line in f.readline():
|
||||
yield line
|
||||
yield from f.readline()
|
||||
|
||||
def reset_job(self, success=True):
|
||||
super(LocalFilePrintjob, self).reset_job(success=success)
|
||||
super().reset_job(success=success)
|
||||
self.close()
|
||||
self._pos = self._read_lines = 0
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class LocalGcodeStreamjob(LocalGcodeFilePrintjob, CopyJobMixin):
|
||||
)
|
||||
|
||||
def __init__(self, remote, *args, **kwargs):
|
||||
super(LocalGcodeStreamjob, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self._remote = remote
|
||||
|
||||
@property
|
||||
@@ -62,25 +62,21 @@ class LocalGcodeStreamjob(LocalGcodeFilePrintjob, CopyJobMixin):
|
||||
return self._remote
|
||||
|
||||
def process(self, protocol, position=0, user=None, tags=None, **kwargs):
|
||||
super(LocalGcodeStreamjob, self).process(
|
||||
protocol, position=position, user=user, tags=tags, **kwargs
|
||||
)
|
||||
super().process(protocol, position=position, user=user, tags=tags, **kwargs)
|
||||
self._protocol.record_file(self._remote)
|
||||
|
||||
def process_job_done(self, user=None, tags=None, **kwargs):
|
||||
self._protocol.stop_recording_file()
|
||||
super(LocalGcodeStreamjob, self).process_job_done(user=user, tags=tags, **kwargs)
|
||||
super().process_job_done(user=user, tags=tags, **kwargs)
|
||||
|
||||
def process_job_failed(self, **kwargs):
|
||||
self._protocol.stop_recording_file()
|
||||
super(LocalGcodeStreamjob, self).process_job_failed(**kwargs)
|
||||
super().process_job_failed(**kwargs)
|
||||
|
||||
def process_job_cancelled(self, user=None, tags=None, **kwargs):
|
||||
self._protocol.stop_recording_file()
|
||||
self._protocol.delete_file(self.remote)
|
||||
super(LocalGcodeStreamjob, self).process_job_cancelled(
|
||||
user=user, tags=tags, **kwargs
|
||||
)
|
||||
super().process_job_cancelled(user=user, tags=tags, **kwargs)
|
||||
|
||||
def can_process(self, protocol):
|
||||
from octoprint.comm.protocol import (
|
||||
|
||||
@@ -74,11 +74,11 @@ class SDFilePrintjob(StoragePrintjob, FileAwareProtocolListener):
|
||||
self._protocol.start_file_print_status_monitor()
|
||||
|
||||
def pause(self, user=None, tags=None, **kwargs):
|
||||
super(SDFilePrintjob, self).pause(user=user, tags=tags, **kwargs)
|
||||
super().pause(user=user, tags=tags, **kwargs)
|
||||
self._protocol.pause_file_print(user=user, tags=tags, part_of_job=True, **kwargs)
|
||||
|
||||
def resume(self, user=None, tags=None, **kwargs):
|
||||
super(SDFilePrintjob, self).resume(user=user, tags=tags, **kwargs)
|
||||
super().resume(user=user, tags=tags, **kwargs)
|
||||
self._protocol.resume_file_print(user=user, tags=tags, part_of_job=True, **kwargs)
|
||||
|
||||
def on_protocol_sd_status(self, protocol, pos, total):
|
||||
@@ -103,7 +103,7 @@ class SDFilePrintjob(StoragePrintjob, FileAwareProtocolListener):
|
||||
self._protocol.resume_file_print(**kwargs)
|
||||
|
||||
def reset_job(self, success=True):
|
||||
super(SDFilePrintjob, self).reset_job(success=success)
|
||||
super().reset_job(success=success)
|
||||
self._active = False
|
||||
self._last_pos = None
|
||||
self._size = None
|
||||
|
||||
@@ -339,10 +339,10 @@ class ReprapGcodeProtocol(
|
||||
),
|
||||
advanced=True,
|
||||
),
|
||||
defaults=dict(
|
||||
(f.key, dict((key, getattr(f, key)) for key in f.overridable))
|
||||
defaults={
|
||||
f.key: {key: getattr(f, key) for key in f.overridable}
|
||||
for f in all_flavors()
|
||||
),
|
||||
},
|
||||
default="standard",
|
||||
),
|
||||
ParamGroup(
|
||||
@@ -688,7 +688,7 @@ class ReprapGcodeProtocol(
|
||||
|
||||
@classmethod
|
||||
def get_attributes_starting_with(cls, prefix):
|
||||
return dict((x, getattr(cls, x)) for x in dir(cls) if x.startswith(prefix))
|
||||
return {x: getattr(cls, x) for x in dir(cls) if x.startswith(prefix)}
|
||||
|
||||
def __init__(self, flavor=None, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
@@ -936,7 +936,7 @@ class ReprapGcodeProtocol(
|
||||
self._sending_thread.daemon = True
|
||||
self._sending_thread.start()
|
||||
|
||||
super(ReprapGcodeProtocol, self).connect(
|
||||
super().connect(
|
||||
transport, transport_args=transport_args, transport_kwargs=transport_kwargs
|
||||
)
|
||||
|
||||
@@ -1716,19 +1716,19 @@ class ReprapGcodeProtocol(
|
||||
##~~ Transport logging
|
||||
|
||||
def on_transport_log_message(self, transport, data):
|
||||
super(ReprapGcodeProtocol, self).on_transport_log_message(transport, data)
|
||||
super().on_transport_log_message(transport, data)
|
||||
self._terminal_log.append(
|
||||
self.LOG_PREFIX_MSG + to_unicode(data.strip(), errors="replace")
|
||||
)
|
||||
|
||||
def on_transport_log_received_data(self, transport, data):
|
||||
super(ReprapGcodeProtocol, self).on_transport_log_received_data(transport, data)
|
||||
super().on_transport_log_received_data(transport, data)
|
||||
self._terminal_log.append(
|
||||
self.LOG_PREFIX_RX + to_unicode(data.strip(), errors="replace")
|
||||
)
|
||||
|
||||
def on_transport_log_sent_data(self, transport, data):
|
||||
super(ReprapGcodeProtocol, self).on_transport_log_sent_data(transport, data)
|
||||
super().on_transport_log_sent_data(transport, data)
|
||||
self._terminal_log.append(
|
||||
self.LOG_PREFIX_TX + to_unicode(data.strip(), errors="replace")
|
||||
)
|
||||
|
||||
@@ -26,7 +26,7 @@ class AtCommand(Command):
|
||||
def __init__(self, line, atcommand, parameters, **kwargs):
|
||||
self.atcommand = atcommand
|
||||
self.parameters = parameters
|
||||
super(AtCommand, self).__init__(line, **kwargs)
|
||||
super().__init__(line, **kwargs)
|
||||
|
||||
def __repr__(self):
|
||||
return "AtCommand({!r},{!r},{!r},type={!r},tags={}".format(
|
||||
|
||||
@@ -108,7 +108,7 @@ class GcodeCommand(Command):
|
||||
else:
|
||||
line = self.original
|
||||
|
||||
super(GcodeCommand, self).__init__(line, type=command_type, tags=tags)
|
||||
super().__init__(line, type=command_type, tags=tags)
|
||||
|
||||
self._repr = self._to_repr()
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@ class GcodeScript(Script):
|
||||
raise UnknownScript(name)
|
||||
return lines
|
||||
|
||||
super(GcodeScript, self).__init__(name, renderer, context=context)
|
||||
super().__init__(name, renderer, context=context)
|
||||
|
||||
def render(self, context=None):
|
||||
script = super(GcodeScript, self).render(context)
|
||||
script = super().render(context)
|
||||
return list(
|
||||
filter(
|
||||
lambda x: x is not None and x.strip() != "",
|
||||
|
||||
@@ -284,7 +284,7 @@ class PositionRecord:
|
||||
attrs = self._standard_attrs | set(
|
||||
[key for key in dir(self) if self.valid_e(key)]
|
||||
)
|
||||
return dict((attr, getattr(self, attr)) for attr in attrs)
|
||||
return {attr: getattr(self, attr) for attr in attrs}
|
||||
|
||||
|
||||
class TemperatureRecord:
|
||||
|
||||
@@ -131,7 +131,7 @@ class Transport(ListenerAware):
|
||||
return []
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Transport, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
self._logger = logging.getLogger(__name__)
|
||||
self._state = TransportState.DISCONNECTED
|
||||
@@ -261,10 +261,10 @@ class TransportWrapper(ListenerAware):
|
||||
def f(*args, **kwargs):
|
||||
# replace references to self.transport with self
|
||||
args = [self if arg == self.transport else arg for arg in args]
|
||||
kwargs = dict(
|
||||
(key, self if value == self.transport else value)
|
||||
kwargs = {
|
||||
key: self if value == self.transport else value
|
||||
for key, value in kwargs.items()
|
||||
)
|
||||
}
|
||||
|
||||
# forward
|
||||
self.notify_listeners(name, *args, **kwargs)
|
||||
@@ -350,7 +350,7 @@ class PushingTransportWrapper(TransportWrapper):
|
||||
def __init__(
|
||||
self, transport, name=b"PushingTransportWrapper.receiver_loop", timeout=None
|
||||
):
|
||||
super(PushingTransportWrapper, self).__init__(transport)
|
||||
super().__init__(transport)
|
||||
self.name = name
|
||||
self.timeout = timeout
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ class SerialTransport(Transport):
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SerialTransport, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
self.serial_factory = kwargs.get("serial_factory", None)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class TcpTransport(Transport):
|
||||
return [TextType("host", "Host"), IntegerType("port", "Port", min=1, max=65535)]
|
||||
|
||||
def __init__(self):
|
||||
super(TcpTransport, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
self._socket = None
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ def get_param_defaults(options):
|
||||
|
||||
|
||||
def get_param_dict(data, options):
|
||||
options_by_name = dict((option.name, option) for option in options)
|
||||
options_by_name = {option.name: option for option in options}
|
||||
|
||||
result = {}
|
||||
for key, value in data.items():
|
||||
@@ -284,7 +284,7 @@ class ParamGroup(ParamType):
|
||||
def convert(self, value):
|
||||
if not isinstance(value, dict):
|
||||
raise ValueError("value {!r} must be a dict".format(value))
|
||||
return dict((k, v.convert()) for k, v in value.items())
|
||||
return {k: v.convert() for k, v in value.items()}
|
||||
|
||||
|
||||
class Value:
|
||||
|
||||
@@ -701,7 +701,7 @@ class Printer(
|
||||
if len(axes) != len(validated_axes):
|
||||
raise ValueError("axes contains invalid axes: {axes}".format(axes=axes))
|
||||
|
||||
kwargs = dict((axes, True) for axes in validated_axes)
|
||||
kwargs = {axes: True for axes in validated_axes}
|
||||
self._protocol.home(**kwargs)
|
||||
|
||||
def extrude(self, amount, speed=None, *args, **kwargs):
|
||||
|
||||
@@ -14,7 +14,7 @@ from octoprint.util import monotonic_time, to_bytes
|
||||
|
||||
class TestTransport(Transport):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(TestTransport, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.outgoing = bytearray()
|
||||
self.incoming = []
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ class SettingsTestCase(unittest.TestCase):
|
||||
],
|
||||
"some_value",
|
||||
),
|
||||
dict(),
|
||||
{},
|
||||
"set",
|
||||
),
|
||||
(
|
||||
@@ -153,7 +153,7 @@ class SettingsTestCase(unittest.TestCase):
|
||||
],
|
||||
"some_value",
|
||||
),
|
||||
dict(force=True),
|
||||
{"force": True},
|
||||
"set",
|
||||
),
|
||||
(
|
||||
@@ -164,7 +164,7 @@ class SettingsTestCase(unittest.TestCase):
|
||||
],
|
||||
23,
|
||||
),
|
||||
dict(),
|
||||
{},
|
||||
"setInt",
|
||||
),
|
||||
(
|
||||
@@ -175,7 +175,7 @@ class SettingsTestCase(unittest.TestCase):
|
||||
],
|
||||
23,
|
||||
),
|
||||
dict(force=True),
|
||||
{"force": True},
|
||||
"setInt",
|
||||
),
|
||||
(
|
||||
@@ -186,7 +186,7 @@ class SettingsTestCase(unittest.TestCase):
|
||||
],
|
||||
2.3,
|
||||
),
|
||||
dict(),
|
||||
{},
|
||||
"setFloat",
|
||||
),
|
||||
(
|
||||
@@ -197,7 +197,7 @@ class SettingsTestCase(unittest.TestCase):
|
||||
],
|
||||
2.3,
|
||||
),
|
||||
dict(force=True),
|
||||
{"force": True},
|
||||
"setFloat",
|
||||
),
|
||||
(
|
||||
@@ -208,7 +208,7 @@ class SettingsTestCase(unittest.TestCase):
|
||||
],
|
||||
True,
|
||||
),
|
||||
dict(),
|
||||
{},
|
||||
"setBoolean",
|
||||
),
|
||||
(
|
||||
@@ -219,7 +219,7 @@ class SettingsTestCase(unittest.TestCase):
|
||||
],
|
||||
True,
|
||||
),
|
||||
dict(force=True),
|
||||
{"force": True},
|
||||
"setBoolean",
|
||||
),
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user