Detect a microbit.
489138
def detect_microbit(self):
        """"""
        try:
            gpad = MicroBitPad(self)
        except ModuleNotFoundError:
            warn(
                "The microbit library could not be found in the pythonpath. \n"
                "For more information, please visit \n"
                "https://inputs.readthedocs.io/en/latest/user/microbit.html",
                RuntimeWarning)
        else:
            self.microbits.append(gpad)
            self.gamepads.append(gpad)
155155
def set_bit(bitmask, bit, is_on):
    
    bitshift = bit - 1
    if is_on:
        return bitmask | (1 << bitshift)
    return bitmask & (0xff & ~(1 << bitshift))
813798
def check (self):
        """"""
        if self.aggregate.config["trace"]:
            trace.trace_on()
        try:
            self.local_check()
        except (socket.error, select.error):
            # on Unix, ctrl-c can raise
            # error: (4, 'Interrupted system call')
            etype, value = sys.exc_info()[:2]
            if etype == errno.EINTR:
                raise KeyboardInterrupt(value)
            else:
                raise
957513
def sense_ttb(self, target):
        """"""
        info = "{device} does not support sense for Type B Target"
        raise nfc.clf.UnsupportedTargetError(info.format(device=self))
602483
def detect_nintendo()
      if (user_agent.include?(DEVICE_NINTENDO) || user_agent.include?(DEVICE_WII) || user_agent.include?(DEVICE_NINTENDO_DS))
        return true
      end
      return false
    end
230726
def ReadStatusBit(self, bit):
        '  '
        spi.SPI_write_byte(self.CS, 0x39)   # Read from address 0x19 (STATUS)
        spi.SPI_write_byte(self.CS, 0x00)
        data0 = spi.SPI_read_byte()           # 1st byte
        spi.SPI_write_byte(self.CS, 0x00)
        data1 = spi.SPI_read_byte()           # 2nd byte
        #print hex(data0), hex(data1)
        if bit > 7:                                   # extract requested bit
            OutputBit = (data0 >> (bit - 8)) & 1
        else:
            OutputBit = (data1 >> bit) & 1        
        return OutputBit
303099
public boolean detectBlackBerryTouch() {

        if (detectBlackBerry()
            && ((userAgent.indexOf(deviceBBStorm) != -1)
                || (userAgent.indexOf(deviceBBTorch) != -1)
                || (userAgent.indexOf(deviceBBBoldTouch) != -1)
                || (userAgent.indexOf(deviceBBCurveTouch) != -1))) {
            return true;
        }
        return false;
    }
840602
def target_from_bits(bits)
      exponent = ((bits >> 24) & 0xff)
      mantissa = bits & 0x7fffff
      mantissa *= -1 if (bits & 0x800000) > 0
      (mantissa * (256**(exponent-3))).to_i
    end
776136
def _CheckIsDevice(self, file_entry):
    
    if definitions.FILE_ENTRY_TYPE_DEVICE not in self._file_entry_types:
      return False
    return file_entry.IsDevice()
1256201
def supported_sensor(sensor):
    """"""
    if sensor['type'] in DECONZ_BINARY_SENSOR + DECONZ_SENSOR + OTHER_SENSOR:
        return True
    _LOGGER.info('Unsupported sensor type %s (%s)',
                 sensor['type'], sensor['name'])
    return False
419732
function DetectBada()
   {
      if (stripos($this->useragent, $this->deviceBada) > -1)
         return $this->true; 
      else
         return $this->false; 
   }
1066116
def detectBlackBerry(self):
        
        return UAgentInfo.deviceBB in self.__userAgent \
            or UAgentInfo.vndRIM in self.__httpAccept
293199
boolean scanIsEmpty() {
		// This 'slow' implementation is still faster than any external one
		// could be
		// (e.g.: (bitSet.length() == 0 || bitSet.nextSetBit(0) == -1))
		// especially for small BitSets
		// Depends on the ghost bits being clear!
		final int count = numWords;

		for (int i = 0; i < count; i++) {
			if (bits[i] != 0)
				return false;
		}

		return true;
	}
754447
def _detect_hardware_and_os(self, ssh):
        

        info = {
            'series': '',
            'arch': '',
            'cpu-cores': '',
            'mem': '',
        }

        stdout, stderr = self._run_command(
            ssh,
            ["sudo", "/bin/bash -c " + shlex.quote(DETECTION_SCRIPT)],
            pty=True,
        )

        lines = stdout.split("\n")
        info['series'] = lines[0].strip()
        info['arch'] = normalize_arch(lines[1].strip())

        memKb = re.split(r'\s+', lines[2])[1]

        # Convert megabytes -> kilobytes
        info['mem'] = round(int(memKb) / 1024)

        # Detect available CPUs
        recorded = {}
        for line in lines[3:]:
            physical_id = ""
            print(line)

            if line.find("physical id") == 0:
                physical_id = line.split(":")[1].strip()
            elif line.find("cpu cores") == 0:
                cores = line.split(":")[1].strip()

                if physical_id not in recorded.keys():
                    info['cpu-cores'] += cores
                    recorded[physical_id] = True

        return info
81388
def bitop_xor(self, dest, key, *keys):
        """"""
        return self.execute(b'BITOP', b'XOR', dest, key, *keys)
280806
def detect_port(port):
    ''''''
    socket_test = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    try:
        socket_test.connect(('127.0.0.1', int(port)))
        socket_test.close()
        return True
    except:
        return False
624749
public boolean isSet(int bit) {
    int bite = byteForBit(bit);
    if (bite >= bits.length || bits.length == 0) {
      return false;
    }
    int bitOnByte = bitOnByte(bit, bite);
    return ((1 << bitOnByte) & bits[bite]) != 0;
  }