Raises BitReaderError
179883
def _get_audio_object_type(self, r):
        """"""

        audioObjectType = r.bits(5)
        if audioObjectType == 31:
            audioObjectTypeExt = r.bits(6)
            audioObjectType = 32 + audioObjectTypeExt
        return audioObjectType
1013199
def set(bit)
      quotient = bit >> 3
      remainder = bit & 0x7
      mask = 0x80 >> remainder

      raise "Bit #{bit} out of range of bitfield with length #{length}" if quotient >= @data.length
      @data[quotient] |= mask
    end
289274
def read_or_raise(reader, n=-1):
    
    data = yield from reader.read(n)
    if not data:
        raise NoDataException("No more data")
    return data
51246
def _fix_lsm_bitspersample(self, parent):
        
        if self.code != 258 or self.count != 2:
            return
        # TODO: test this case; need example file
        log.warning('TiffTag %i: correcting LSM bitspersample tag', self.code)
        value = struct.pack('<HH', *self.value)
        self.valueoffset = struct.unpack('<I', value)[0]
        parent.filehandle.seek(self.valueoffset)
        self.value = struct.unpack('<HH', parent.filehandle.read(4))
586154
function (n) { /* Read n bytes off the big end of number */
			if (bits - n < 0) { /* Not enough bits */
				throw {
					name: 'RangeError',
					message: 'Not enough bits left to read '+n+' bits!'
				};
			}
			/* Extract our value. We use maths rather than bitwise operations because every number is a floating point in javascript */
			var value = Math.floor(number / Math.pow(2, bits - n)) % Math.pow(2, n);
			/* Move the bit we start from along */
			bits -= n;

			return value;
		}
309908
private boolean bit() throws JSONException {
        boolean value;
        try {
            value = this.bitreader.bit();
            if (probe) {
                log(value ? 1 : 0);
            }
            return value;
        } catch (Throwable e) {
            throw new JSONException(e);
        }

    }
1132413
private static int readCode(boolean[] rawbits, int startIndex, int length) {
    int res = 0;
    for (int i = startIndex; i < startIndex + length; i++) {
      res <<= 1;
      if (rawbits[i]) {
        res |= 0x01;
      }
    }
    return res;
  }
113568
def read_byte(self, do_ord=True) -> int:
        
        try:
            if do_ord:
                return ord(self.stream.read(1))
            else:
                return self.stream.read(1)
        except Exception as e:
            raise SDKException(ErrorCode.read_byte_error(e.args[0]))
235265
def expect_invalid_resp_data(data=''):
    """"""
    try:
        yield
    except (ValueError, TypeError, IndexError, AttributeError,
            KeyError) as err:
        msg = ('Invalid smt response data: %s. Error: %s' %
               (data, six.text_type(err)))
        LOG.error(msg)
        raise exception.SDKInternalError(msg=msg)
572057
def process_read_exception(exc, path, ignore=None):
    '''
    
    '''
    if ignore is not None:
        if isinstance(ignore, six.integer_types):
            ignore = (ignore,)
    else:
        ignore = ()

    if exc.errno in ignore:
        return

    if exc.errno == errno.ENOENT:
        raise CommandExecutionError('{0} does not exist'.format(path))
    elif exc.errno == errno.EACCES:
        raise CommandExecutionError(
            'Permission denied reading from {0}'.format(path)
        )
    else:
        raise CommandExecutionError(
            'Error {0} encountered reading from {1}: {2}'.format(
                exc.errno, path, exc.strerror
            )
        )
272879
def validate_read(self, kwargs):
        
        kwargs = super().validate_read(kwargs)
        if 'start' in kwargs or 'stop' in kwargs:
            raise NotImplementedError("start and/or stop are not supported "
                                      "in fixed Sparse reading")
        return kwargs
1283322
def set_bit(self, position: int):
        
        if position > (self._bit_width - 1):
            raise ValueError('position greater than the bit width')

        self._value |= (1 << position)
        self._text_update()
278773
def _raise_timeout(self, err, url, timeout_value):
        """"""

        if isinstance(err, SocketTimeout):
            raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)

        # See the above comment about EAGAIN in Python 3. In Python 2 we have
        # to specifically catch it and throw the timeout error
        if hasattr(err, 'errno') and err.errno in _blocking_errnos:
            raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)

        # Catch possible read timeouts thrown as SSL errors. If not the
        # case, rethrow the original. We need to do this because of:
        # http://bugs.python.org/issue10272
        if 'timed out' in str(err) or 'did not complete (read)' in str(err):  # Python < 2.7.4
            raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
880046
def raise_error(error_type: str) -> None:
    """"""
    try:
        error = next((v for k, v in ERROR_CODES.items() if k in error_type))
    except StopIteration:
        error = AirVisualError
    raise error(error_type)
510181
def bits(self, count):
        

        if count < 0:
            raise ValueError

        if count > self._bits:
            n_bytes = (count - self._bits + 7) // 8
            data = self._fileobj.read(n_bytes)
            if len(data) != n_bytes:
                raise BitReaderError("not enough data")
            for b in bytearray(data):
                self._buffer = (self._buffer << 8) | b
            self._bits += n_bytes * 8

        self._bits -= count
        value = self._buffer >> self._bits
        self._buffer &= (1 << self._bits) - 1
        assert self._bits < 8
        return value
947355
def on_readable
      begin
        on_read @_io.read_nonblock(INPUT_SIZE)
      rescue Errno::EAGAIN, Errno::EINTR
        return

      # SystemCallError catches Errno::ECONNRESET amongst others.
      rescue SystemCallError, EOFError, IOError, SocketError
        close
      end
    end
1282828
public void unreadFrame() throws BitstreamException
	{
		if (wordpointer==-1 && bitindex==-1 && (framesize>0))
		{
			try
			{
				source.unread(frame_bytes, 0, framesize);
			}
			catch (IOException ex)
			{
				throw newBitstreamException(STREAM_ERROR);
			}
		}
	}