From 3086d478a0dbee120ec4453476bc66702562912a Mon Sep 17 00:00:00 2001 From: mrmcwethy Date: Fri, 3 Nov 2017 07:29:35 -0700 Subject: [PATCH 1/2] Added readinto() method to be more consistant with busdevice.spi. Added warning on read_into() saying it will be deprecated in the future --- adafruit_bus_device/i2c_device.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/adafruit_bus_device/i2c_device.py b/adafruit_bus_device/i2c_device.py index 657c2d7..2221333 100644 --- a/adafruit_bus_device/i2c_device.py +++ b/adafruit_bus_device/i2c_device.py @@ -43,7 +43,7 @@ class I2CDevice: device = I2CDevice(i2c, 0x70) bytes_read = bytearray(4) with device: - device.read_into(bytes_read) + device.readinto(bytes_read) # A second transaction with device: device.write(bytes_read) @@ -62,7 +62,7 @@ def __init__(self, i2c, device_address): self.i2c = i2c self.device_address = device_address - def read_into(self, buf, **kwargs): + def readinto(self, buf, **kwargs): """ Read into ``buf`` from the device. The number of bytes read will be the length of ``buf``. @@ -77,6 +77,14 @@ def read_into(self, buf, **kwargs): """ self.i2c.readfrom_into(self.device_address, buf, **kwargs) + def read_into(self, buf, **kwargs): + """ + Warning: This method will be deprecated some time in the future. + Please start using readinto() instead. readinto() is functionally + equivalent to read_into(), same parameters and same actions. + """ + self.i2c.readfrom_into(self.device_address, buf, **kwargs) + def write(self, buf, **kwargs): """ Write the bytes from ``buffer`` to the device. Transmits a stop bit if From 0449ce69e158810e1c41768698c2400cf965adc8 Mon Sep 17 00:00:00 2001 From: mrmcwethy Date: Fri, 3 Nov 2017 11:50:30 -0700 Subject: [PATCH 2/2] updated to improve looks in sphinx --- adafruit_bus_device/i2c_device.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_bus_device/i2c_device.py b/adafruit_bus_device/i2c_device.py index 2221333..50ee065 100644 --- a/adafruit_bus_device/i2c_device.py +++ b/adafruit_bus_device/i2c_device.py @@ -79,8 +79,8 @@ def readinto(self, buf, **kwargs): def read_into(self, buf, **kwargs): """ - Warning: This method will be deprecated some time in the future. - Please start using readinto() instead. readinto() is functionally + .. warning:: This method will be deprecated at some time in the future. + Please use `readinto`() instead. `readinto`() is functionally equivalent to read_into(), same parameters and same actions. """ self.i2c.readfrom_into(self.device_address, buf, **kwargs)