Skip to content

Commit 9f47b08

Browse files
committed
run 2to3 and cleanup afterwards
1 parent e35fc3d commit 9f47b08

File tree

9 files changed

+13
-19
lines changed

9 files changed

+13
-19
lines changed

can/bus.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class BusState(Enum):
2424
ERROR = auto()
2525

2626

27-
class BusABC(object):
27+
class BusABC(metaclass=ABCMeta):
2828
"""The CAN Bus Abstract Base Class that serves as the basis
2929
for all concrete interfaces.
3030
@@ -401,5 +401,3 @@ def _detect_available_configs():
401401
for usage in the interface's bus constructor.
402402
"""
403403
raise NotImplementedError()
404-
405-
__metaclass__ = ABCMeta

can/interface.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,9 @@ def detect_available_configs(interfaces=None):
144144

145145
# Figure out where to search
146146
if interfaces is None:
147-
# use an iterator over the keys so we do not have to copy it
148-
interfaces = BACKENDS.keys()
147+
interfaces = BACKENDS
149148
elif isinstance(interfaces, str):
150-
interfaces = [interfaces, ]
149+
interfaces = (interfaces, )
151150
# else it is supposed to be an iterable of strings
152151

153152
result = []

can/interfaces/socketcan/socketcan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ def receiver(event):
659659
bind_socket(receiver_socket, 'vcan0')
660660
print("Receiver is waiting for a message...")
661661
event.set()
662-
print("Receiver got: ", capture_message(receiver_socket))
662+
print(f"Receiver got: {capture_message(receiver_socket)}")
663663

664664
def sender(event):
665665
event.wait()

can/interfaces/socketcan/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def find_available_interfaces():
6767
log.debug("find_available_interfaces(): detected: %s", interface_names)
6868
return filter(_PATTERN_CAN_INTERFACE.match, interface_names)
6969

70+
7071
def error_code_to_str(code):
7172
"""
7273
Converts a given error code (errno) to a useful and human readable string.

can/io/generic.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from can import Listener
1010

1111

12-
class BaseIOHandler:
12+
class BaseIOHandler(metaclass=ABCMeta):
1313
"""A generic file handler that can be used for reading and writing.
1414
1515
Can be used as a context manager.
@@ -19,8 +19,6 @@ class BaseIOHandler:
1919
was opened
2020
"""
2121

22-
__metaclass__ = ABCMeta
23-
2422
def __init__(self, file, mode='rt'):
2523
"""
2624
:param file: a path-like object to open a file, a file-like object

can/listener.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import asyncio
1717

1818

19-
class Listener:
19+
class Listener(metaclass=ABCMeta):
2020
"""The basic listener that can be called directly to handle some
2121
CAN message::
2222
@@ -32,8 +32,6 @@ class Listener:
3232
listener.stop()
3333
"""
3434

35-
__metaclass__ = ABCMeta
36-
3735
@abstractmethod
3836
def on_message_received(self, msg):
3937
"""This method is called to handle the given message.

can/logger.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def main():
7676

7777
can_filters = []
7878
if len(results.filter) > 0:
79-
print('Adding filter/s', results.filter)
79+
print(f"Adding filter(s): {results.filter}")
8080
for filt in results.filter:
8181
if ':' in filt:
8282
_ = filt.split(":")
@@ -99,8 +99,8 @@ def main():
9999
elif results.passive:
100100
bus.state = BusState.PASSIVE
101101

102-
print('Connected to {}: {}'.format(bus.__class__.__name__, bus.channel_info))
103-
print('Can Logger (Started on {})\n'.format(datetime.now()))
102+
print(f"Connected to {bus.__class__.__name__}: {bus.channel_info}")
103+
print(f"Can Logger (Started on {datetime.now()})")
104104
logger = Logger(results.log_file)
105105

106106
try:

can/player.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def main():
7878
in_sync = MessageSync(reader, timestamps=results.timestamps,
7979
gap=results.gap, skip=results.skip)
8080

81-
print('Can LogReader (Started on {})'.format(datetime.now()))
81+
print(f"Can LogReader (Started on {datetime.now()})")
8282

8383
try:
8484
for m in in_sync:

can/viewer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def unpack_data(cmd, cmd_to_struct, data): # type: (int, Dict, bytes) -> List[U
145145
# These messages do not contain a data package
146146
return []
147147

148-
for key in cmd_to_struct.keys():
148+
for key in cmd_to_struct:
149149
if cmd == key if isinstance(key, int) else cmd in key:
150150
value = cmd_to_struct[key]
151151
if isinstance(value, tuple):
@@ -265,7 +265,7 @@ def draw_header(self):
265265
def redraw_screen(self):
266266
# Trigger a complete redraw
267267
self.draw_header()
268-
for key in self.ids.keys():
268+
for key in self.ids:
269269
self.draw_can_bus_message(self.ids[key]['msg'])
270270

271271

0 commit comments

Comments
 (0)