Skip to content

Commit 01508f6

Browse files
committed
Fix python 3.8 compatibility.
1 parent 2cac292 commit 01508f6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

inkcut/device/transports/serialport/plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def make_filter(self, port_info: SerialPortInfo):
106106
if port_info.description:
107107
text = port_info.description
108108
text = text.replace(port_info.device_path, '').strip()
109-
text = text.removeprefix('-').removeprefix(':').strip()
109+
text = text.strip('-: ')
110110
if text:
111111
self.port_filter_name = re.escape(text)
112112

tests/transport/test_serial_config.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,10 @@ def test_make_filter():
7878
config = SerialConfigBase()
7979
config.make_filter(info)
8080
assert config.port_matches(info)
81-
assert not config.port_matches(SerialPortInfo(description='a', usb_vid=123, usb_pid=321))
81+
assert not config.port_matches(SerialPortInfo(description='a', usb_vid=123, usb_pid=321))
82+
83+
info = SerialPortInfo(device_path='/dev/someport1', description=r" /dev/someport1: description",
84+
usb_vid=123, usb_pid=321)
85+
config = SerialConfigBase()
86+
config.make_filter(info)
87+
assert config.port_filter_name == "description"

0 commit comments

Comments
 (0)