Skip to content

Commit 92d1016

Browse files
authored
Merge pull request pyserial#263 from BrendanSimon/list_port_name
list_ports: set default `name` attribute
2 parents fac1c13 + 48504f7 commit 92d1016

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

serial/tools/list_ports_common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import re
1111
import glob
1212
import os
13+
import os.path
1314

1415

1516
def numsplit(text):
@@ -33,7 +34,7 @@ class ListPortInfo(object):
3334

3435
def __init__(self, device=None):
3536
self.device = device
36-
self.name = None
37+
self.name = os.path.basename(device)
3738
self.description = 'n/a'
3839
self.hwid = 'n/a'
3940
# USB specific data

serial/tools/list_ports_linux.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def __init__(self, device):
2424
is_link = True
2525
else:
2626
is_link = False
27-
self.name = os.path.basename(device)
2827
self.usb_device_path = None
2928
if os.path.exists('/sys/class/tty/{}/device'.format(self.name)):
3029
self.device_path = os.path.realpath('/sys/class/tty/{}/device'.format(self.name))

0 commit comments

Comments
 (0)