40
40
41
41
__version__ = "0.0.0-auto.0"
42
42
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Debug_I2C.git"
43
- from re import sub
44
43
45
44
class DebugI2C :
46
45
"""
@@ -73,7 +72,6 @@ class DebugI2C:
73
72
print(accelerometer.acceleration)
74
73
75
74
"""
76
- #pylint: disable=anomalous-backslash-in-string
77
75
def __init__ (self , i2c ):
78
76
self ._i2c = i2c
79
77
if hasattr (self ._i2c , 'writeto_then_readfrom' ):
@@ -109,7 +107,7 @@ def readfrom_into(self, address, buffer, *args, start=0, end=None):
109
107
"""
110
108
self ._i2c .readfrom_into (address , buffer , * args , start = start , end = end )
111
109
112
- in_buffer_str = sub ( "\[|\]|'" , "" , str ([hex (i ) for i in buffer ]) )
110
+ in_buffer_str = " , ". join ([hex (i ) for i in buffer ])
113
111
print ("\t I2CREAD @ {} ::" .format (hex (address )), in_buffer_str )
114
112
115
113
def scan (self ):
@@ -150,7 +148,7 @@ def writeto(self, address, buffer, *args, **kwargs):
150
148
"""
151
149
self ._i2c .writeto (address , buffer , * args , ** kwargs )
152
150
153
- out_buffer_str = sub ( "\[|\]|'" , "" , str ([hex (i ) for i in buffer ]) )
151
+ out_buffer_str = " , ". join ([hex (i ) for i in buffer ])
154
152
print ("\t I2CWRITE @ {} ::" .format (hex (address )), out_buffer_str )
155
153
156
154
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
172
170
:param int in_end: End of the slice; this index is not included. Defaults to
173
171
``len(buffer_in)``
174
172
"""
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 ]])
176
174
print ("\t I2CWRITE @ {} ::" .format (hex (address )), out_buffer_str )
177
175
178
176
self ._i2c .writeto_then_readfrom (address , buffer_out , buffer_in , * args , out_start = out_start ,
179
177
out_end = out_end , in_start = in_start , in_end = in_end )
180
178
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 ]])
182
180
print ("\t I2CREAD @ {} ::" .format (hex (address )), in_buffer_str )
0 commit comments