Skip to content

Commit 3ae6294

Browse files
committed
removing sub
1 parent e2192b3 commit 3ae6294

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

adafruit_debug_i2c.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040

4141
__version__ = "0.0.0-auto.0"
4242
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Debug_I2C.git"
43-
from re import sub
4443

4544
class DebugI2C:
4645
"""
@@ -73,7 +72,6 @@ class DebugI2C:
7372
print(accelerometer.acceleration)
7473
7574
"""
76-
#pylint: disable=anomalous-backslash-in-string
7775
def __init__(self, i2c):
7876
self._i2c = i2c
7977
if hasattr(self._i2c, 'writeto_then_readfrom'):
@@ -109,7 +107,7 @@ def readfrom_into(self, address, buffer, *args, start=0, end=None):
109107
"""
110108
self._i2c.readfrom_into(address, buffer, *args, start=start, end=end)
111109

112-
in_buffer_str = sub("\[|\]|'", "", str([hex(i) for i in buffer]))
110+
in_buffer_str = ", ".join([hex(i) for i in buffer])
113111
print("\tI2CREAD @ {} ::".format(hex(address)), in_buffer_str)
114112

115113
def scan(self):
@@ -150,7 +148,7 @@ def writeto(self, address, buffer, *args, **kwargs):
150148
"""
151149
self._i2c.writeto(address, buffer, *args, **kwargs)
152150

153-
out_buffer_str = sub("\[|\]|'", "", str([hex(i) for i in buffer]))
151+
out_buffer_str = ", ".join([hex(i) for i in buffer])
154152
print("\tI2CWRITE @ {} ::".format(hex(address)), out_buffer_str)
155153

156154
def _writeto_then_readfrom(self, address, buffer_out, buffer_in, *args, out_start=0,
@@ -172,11 +170,11 @@ def _writeto_then_readfrom(self, address, buffer_out, buffer_in, *args, out_star
172170
:param int in_end: End of the slice; this index is not included. Defaults to
173171
``len(buffer_in)``
174172
"""
175-
out_buffer_str = sub("\[|\]|'", "", str([hex(i) for i in buffer_out[out_start:out_end]]))
173+
out_buffer_str = ", ".join([hex(i) for i in buffer_out[out_start:out_end]])
176174
print("\tI2CWRITE @ {} ::".format(hex(address)), out_buffer_str)
177175

178176
self._i2c.writeto_then_readfrom(address, buffer_out, buffer_in, *args, out_start=out_start,
179177
out_end=out_end, in_start=in_start, in_end=in_end)
180178

181-
in_buffer_str = sub("\[|\]|'", "", str([hex(i) for i in buffer_in[in_start:in_end]]))
179+
in_buffer_str = ", ".join([hex(i) for i in buffer_in[in_start:in_end]])
182180
print("\tI2CREAD @ {} ::".format(hex(address)), in_buffer_str)

0 commit comments

Comments
 (0)