#NEWLINE# def _open( self , devpath ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self . _fd = os . open ( devpath , os . O_RDWR ) #NEWLINE# #UNINDENT# except OSError as e : #NEWLINE# #INDENT# raise I2CError ( e . errno , ( 'Opening I2C device: ' + e . strerror ) ) #NEWLINE# #UNINDENT# self . _devpath = devpath #NEWLINE# buf = array . array ( 'I' , [ 0 ] ) #NEWLINE# try : #NEWLINE# #INDENT# fcntl . ioctl ( self . _fd , I2C . _I2C_IOC_FUNCS , devpath , True ) #NEWLINE# #UNINDENT# except OSError as e : #NEWLINE# #INDENT# self . close ( ) #NEWLINE# raise I2CError ( e . errno , ( 'Querying supported functions: ' + e . strerror ) ) #NEWLINE# #UNINDENT# if ( ( buf [ 0 ] & I2C . _I2C_FUNC_I2C ) == 0 ) : #NEWLINE# #INDENT# self . close ( ) #NEWLINE# raise I2CError ( None , ( 'I2C not supported on device %s.' % devpath ) )