Check a parsed packet and figure out if it is an Eddystone Beacon.
        If it is , return the relevant data as a dictionary.

        Return None, it is not an Eddystone Beacon advertising packet
2181
def decode(self, packet):
        """"""

        ssu=packet.retrieve("Complete uuids")
        found=False
        for x in ssu:
            if EDDY_UUID in x:
                found=True
                break
        if not found:
            return None

        found=False
        adv=packet.retrieve("Advertised Data")
        for x in adv:
            luuid=x.retrieve("Service Data uuid")
            for uuid in luuid:
                if EDDY_UUID == uuid:
                    found=x
                    break
            if found:
                break


        if not found:
            return None

        try:
            top=found.retrieve("Adv Payload")[0]
        except:
            return None
        #Rebuild that part of the structure
        found.payload.remove(top)
        #Now decode
        result={}
        data=top.val
        etype = aios.EnumByte("type",self.type.val,{ESType.uid.value:"Eddystone-UID",
                                                ESType.url.value:"Eddystone-URL",
                                                ESType.tlm.value:"Eddystone-TLM",
                                                ESType.eid.value:"Eddystone-EID"})
        data=etype.decode(data)
        found.payload.append(etype)
        if etype.val== ESType.uid.value:
            power=aios.IntByte("tx_power")
            data=power.decode(data)
            found.payload.append(power)
            result["tx_power"]=power.val

            nspace=aios.Itself("namespace")
            xx=nspace.decode(data[:10])  #According to https://github.com/google/eddystone/tree/master/eddystone-uid
            data=data[10:]
            found.payload.append(nspace)
            result["name space"]=nspace.val

            nspace=aios.Itself("instance")
            xx=nspace.decode(data[:6])  #According to https://github.com/google/eddystone/tree/master/eddystone-uid
            data=data[6:]
            found.payload.append(nspace)
            result["instance"]=nspace.val

        elif etype.val== ESType.url.value:
            power=aios.IntByte("tx_power")
            data=power.decode(data)
            found.payload.append(power)
            result["tx_power"]=power.val

            url=aios.EnumByte("type",0,{0x00:"http://www.",0x01:"https://www.",0x02:"http://",0x03:"https://"})
            data=url.decode(data)
            result["url"]=url.strval
            for x in data:
                if bytes([x]) == b"\x00":
                    result["url"]+=".com/"
                elif bytes([x]) == b"\x01":
                    result["url"]+=".org/"
                elif bytes([x]) == b"\x02":
                    result["url"]+=".edu/"
                elif bytes([x]) == b"\x03":
                    result["url"]+=".net/"
                elif bytes([x]) == b"\x04":
                    result["url"]+=".info/"
                elif bytes([x]) == b"\x05":
                    result["url"]+=".biz/"
                elif bytes([x]) == b"\x06":
                    result["url"]+=".gov/"
                elif bytes([x]) == b"\x07":
                    result["url"]+=".com"
                elif bytes([x]) == b"\x08":
                    result["url"]+=".org"
                elif bytes([x]) == b"\x09":
                    result["url"]+=".edu"
                elif bytes([x]) == b"\x10":
                    result["url"]+=".net"
                elif bytes([x]) == b"\x11":
                    result["url"]+=".info"
                elif bytes([x]) == b"\x12":
                    result["url"]+=".biz"
                elif bytes([x]) == b"\x13":
                    result["url"]+=".gov"
                else:
                    result["url"]+=chr(x) #x.decode("ascii") #Yep ASCII only
                    url=aios.String("url")
            url.decode(result["url"])
            found.payload.append(url)
        elif etype.val== ESType.tlm.value:
            myinfo=aios.IntByte("version")
            data=myinfo.decode(data)
            found.payload.append(myinfo)
            myinfo=aios.ShortInt("battery")
            data=myinfo.decode(data)
            result["battery"]=myinfo.val
            found.payload.append(myinfo)
            myinfo=aios.Float88("temperature")
            data=myinfo.decode(data)
            found.payload.append(myinfo)
            result["temperature"]=myinfo.val
            myinfo=aios.LongInt("pdu count")
            data=myinfo.decode(data)
            found.payload.append(myinfo)
            result["pdu count"]=myinfo.val
            myinfo=aios.LongInt("uptime")
            data=myinfo.decode(data)
            found.payload.append(myinfo)
            result["uptime"]=myinfo.val*100 #in msecs
            return result
        #elif etype.val== ESType.tlm.eid:
        else:
            result["data"]=data
            xx=Itself("data")
            xx.decode(data)
            found.payload.append(xx)

        rssi=packet.retrieve("rssi")
        if rssi:
            result["rssi"]=rssi[-1].val
        mac=packet.retrieve("peer")
        if mac:
            result["mac address"]=mac[-1].val
        return result
114502
def _isNewTxn(self, identifier, reply, txnId) -> bool:
        
        return (identifier not in self.processedRequests or
                reply.reqId not in self.processedRequests[identifier]) and \
            txnId is not None
1161067
def _read_http_none(self, size, kind, flag):
        """"""
        if any((int(bit, base=2) for bit in flag)):
            raise ProtocolError(f'HTTP/2: [Type {kind}] invalid format', quiet=True)

        data = dict(
            flags=None,
            payload=self._read_fileng(size - 9) or None,
        )

        return data
814561
def identify_request(request: RequestType):
    
    # Private encrypted JSON payload
    try:
        data = json.loads(decode_if_bytes(request.body))
        if "encrypted_magic_envelope" in data:
            return True
    except Exception:
        pass
    # Public XML payload
    try:
        xml = etree.fromstring(encode_if_text(request.body))
        if xml.tag == MAGIC_ENV_TAG:
            return True
    except Exception:
        pass
    return False
1142448
def is_whitelisted(self, addrinfo):
        
        # For details about the ``getaddrinfo`` struct, see the Python docs:
        # http://docs.python.org/library/socket.html#socket.getaddrinfo
        family, socktype, proto, canonname, sockaddr = addrinfo
        address, port = sockaddr[:2]
        return address in self.socket_address_whitelist
965989
def parse_ltv_packet(packet):
    """"""
    try:
        frame = LTVFrame.parse(packet)
        for ltv in frame:
            if ltv['type'] == SERVICE_DATA_TYPE:
                data = ltv['value']

                if data["service_identifier"] == EDDYSTONE_UUID:
                    return parse_eddystone_service_data(data)

                elif data["service_identifier"] == ESTIMOTE_UUID:
                    return parse_estimote_service_data(data)

    except ConstructError:
        return None

    return None
1275501
def _resolve_device_type(self, device):
        
        try:
            from tests.unit import fakes
            server_types = (pyrax.CloudServer, fakes.FakeServer)
            lb_types = (CloudLoadBalancer, fakes.FakeLoadBalancer,
                    fakes.FakeDNSDevice)
        except ImportError:
            # Not running with tests
            server_types = (pyrax.CloudServer, )
            lb_types = (CloudLoadBalancer, )
        if isinstance(device, server_types):
            device_type = "server"
        elif isinstance(device, lb_types):
            device_type = "loadbalancer"
        else:
            raise exc.InvalidDeviceType("The device '%s' must be a CloudServer "
                    "or a CloudLoadBalancer." % device)
        return device_type
95140
def is_serving(self) -> bool:
        
        try:
            # Python ≥ 3.7
            return self.server.is_serving()  # type: ignore
        except AttributeError:  # pragma: no cover
            # Python < 3.7
            return self.server.sockets is not None
631006
def packetToDict(pkt):
	

	d = {
		'id': pkt[4],
		'instruction': xl320.InstrToStr[pkt[7]],
		'length': (pkt[6] << 8) + pkt[5],
		'params': pkt[8:-2],
		'crc': pkt[-2:]
	}

	return d
1280167
def is_response(self, other):
        """"""
        if other.flags & dns.flags.QR == 0 or \
           self.id != other.id or \
           dns.opcode.from_flags(self.flags) != \
           dns.opcode.from_flags(other.flags):
            return False
        if dns.rcode.from_flags(other.flags, other.ednsflags) != \
               dns.rcode.NOERROR:
            return True
        if dns.opcode.is_update(self.flags):
            return True
        for n in self.question:
            if n not in other.question:
                return False
        for n in other.question:
            if n not in self.question:
                return False
        return True
782697
def IsNTFS(self):
    
    tsk_fs_type = self.GetFsType()
    return tsk_fs_type in [
        pytsk3.TSK_FS_TYPE_NTFS, pytsk3.TSK_FS_TYPE_NTFS_DETECT]
265532
def is_block_device(self):
        
        try:
            return S_ISBLK(self.stat().st_mode)
        except OSError as e:
            if e.errno != ENOENT:
                raise
            # Path doesn't exist or is a broken symlink
            # (see https://bitbucket.org/pitrou/pathlib/issue/12/)
            return False
1061001
def _parse_request(header_data, ignore_bad_cookies=False):
    
    cookies_dict = {}
    for line in Definitions.EOL.split(header_data.strip()):
        matches = Definitions.COOKIE_RE.finditer(line)
        matches = [item for item in matches]
        for match in matches:
            invalid = match.group('invalid')
            if invalid:
                if not ignore_bad_cookies:
                    raise InvalidCookieError(data=invalid)
                _report_invalid_cookie(invalid)
                continue
            name = match.group('name')
            values = cookies_dict.get(name)
            value = match.group('value').strip('"')
            if values:
                values.append(value)
            else:
                cookies_dict[name] = [value]
        if not matches:
            if not ignore_bad_cookies:
                raise InvalidCookieError(data=line)
            _report_invalid_cookie(line)
    return cookies_dict
582949
def save_bt_addr(self, packet, bt_addr):
        """"""
        if isinstance(packet, EddystoneUIDFrame):
            # remove out old mapping
            new_mappings = [m for m in self.eddystone_mappings if m[0] != bt_addr]
            new_mappings.append((bt_addr, packet.properties))
            self.eddystone_mappings = new_mappings
1123116
def VerifyCoARequest(self):
        
        assert(self.raw_packet)
        hash = md5_constructor(self.raw_packet[0:4] + 16 * six.b('\x00') +
                self.raw_packet[20:] + self.secret).digest()
        return hash == self.authenticator
805745
function parse(packet) {
    if ('object' === typeof packet) return packet;

    try { return JSON.parse(packet); }
    catch (e) { return failed(e); }
  }
824997
def contains(haystack, needle):
    
    if sys.version_info[0] < 3:
        return needle in haystack
    else:
        return to_bytes(needle) in to_bytes(haystack)