Same as nsummary(), except that if a packet has a Raw layer, it will be hexdumped  # noqa: E501
        lfilter: a truth function that decides whether a packet must be displayed
545819
def hexraw(self, lfilter=None):
        """"""  # noqa: E501
        for i, res in enumerate(self.res):
            p = self._elt2pkt(res)
            if lfilter is not None and not lfilter(p):
                continue
            print("%s %s %s" % (conf.color_theme.id(i, fmt="%04i"),
                                p.sprintf("%.time%"),
                                self._elt2sum(res)))
            if p.haslayer(conf.raw_layer):
                hexdump(p.getlayer(conf.raw_layer).load)
870743
def iscomplete(rawmessage):
    """"""
    if len(rawmessage) < 2:
        return False

    if rawmessage[0] != 0x02:
        raise ValueError('message does not start with 0x02')

    messageBuffer = bytearray()
    filler = bytearray(30)
    messageBuffer.extend(rawmessage)
    messageBuffer.extend(filler)

    msg = _get_msg_class(rawmessage[1])

    if hasattr(msg, 'receivedSize') and msg.receivedSize:
        expectedSize = msg.receivedSize
    else:
        _LOGGER.error('Unable to find a receivedSize for code 0x%x',
                      rawmessage[1])
        return ValueError

    is_expected_size = False
    if len(rawmessage) >= expectedSize:
        is_expected_size = True

    return is_expected_size
483850
def format_packet(command):
        """"""
        frame_header = b"\xaa"
        verify = b"\x0b"
        send_delim = b"\xbb"
        return frame_header + command.ljust(17, b"\x00") + verify + send_delim
894382
function getKeyValueChunks(raw) {
  var chunks = [];
  var offset = 0;
  var sep = ';';
  var hasUnclosedUrl = /url\([^\)]+$/;
  var chunk = '';
  var nextSplit;
  while (offset < raw.length) {
    nextSplit = raw.indexOf(sep, offset);
    if (nextSplit === -1) { nextSplit = raw.length; }

    chunk += raw.substring(offset, nextSplit);

    // data URIs can contain semicolons, so make sure we get the whole thing
    if (hasUnclosedUrl.test(chunk)) {
      chunk += ';';
      offset = nextSplit + 1;
      continue;
    }

    chunks.push(chunk);
    chunk = '';
    offset = nextSplit + 1;
  }

  return chunks;
}
347415
def _get_data_format_2and4(raw):
        
        try:
            # TODO: Fix conversion so convered data will show https://ruu.vi/# and htts://r/
            # Now it has e.g. [Non_ASCII characters]ruu.vi/#AjwYAMFc
            base16_split = [raw[i:i + 2] for i in range(0, len(raw), 2)]
            selected_hexs = filter(lambda x: int(x, 16) < 128, base16_split)
            characters = [chr(int(c, 16)) for c in selected_hexs]
            data = ''.join(characters)

            # take only part after ruu.vi/# or r/
            index = data.find('ruu.vi/#')
            if index > -1:
                return data[(index + 8):]
            else:
                index = data.find('r/')
                if index > -1:
                    return data[(index + 2):]
                return None
        except:
            return None
185224
function formatBufferUncolored(err, options) {
    // istanbul ignore else
    if (!hex) {
        return err.buffer.toString('hex');
    }

    options = options || {};

    var hasOffset = !(err.offset === undefined || err.offset === null);
    var hasEnd = !(err.endOffset === undefined || err.endOffset === null);
    var markStart = options.markStart || '>';
    var markEnd = options.markEnd || '<';
    var accum = 0;

    var opts = options.hexerOptions ? Object.create(options.hexerOptions) : {};
    if (hasOffset) {
        opts.groupSeparator = '';
        if (hasEnd) {
            opts.decorateHexen = decorateRangedError;
        } else {
            opts.decorateHexen = decorateError;
        }
    }
    return hex(err.buffer, opts);

    // TODO: suspected broken across lines, should either test and complete or
    // use some sort of alternate notation such as interstitial lines
    function decorateRangedError(totalOffset, screenOffset, hexen) {
        var s;
        if (totalOffset === err.offset) {
            accum = 1;
            s = markStart + hexen;
            if (totalOffset === err.endOffset-1) {
                s += markEnd;
                accum = 0;
            } else {
                s = ' ' + s;
            }
            return s;
        } else if (totalOffset === err.endOffset-1) {
            s = hexen + markEnd;
            while (accum-- > 0) s += ' ';
            accum = 0;
            return s;
        } else if (accum) {
            accum += 2;
            return hexen;
        } else {
            return ' ' + hexen + ' ';
        }
    }

    function decorateError(totalOffset, screenOffset, hexen) {
        if (totalOffset === err.offset) {
            return markStart + hexen + markEnd;
        } else {
            return ' ' + hexen + ' ';
        }
    }
}
604416
function processMultiBytePacketStop (o) {
  processMultiBytePacket(o);
  const str = o.multiPacketBuffer.toString();
  o.multiPacketBuffer = null;
  return {
    'message': str
  };
}
680004
def read_raw(self, length, *, error=None):
        """"""
        if length is None:
            length = len(self)

        raw = dict(
            packet=self._read_fileng(length),
            error=error or None,
        )

        return raw
1358471
def skipNullPadding(self, buff):
        '''
        
        '''
        def readNext(buff, first_run=True):
            datas = unpack('<i', buff.read(4))
            header = datas[0]

            if header == CHUNK_NULL_TYPE and first_run:
                print("Skipping null padding in StringPoolChunk header")
                header = readNext(buff, first_run=False)
            elif header != CHUNK_STRINGPOOL_TYPE:
                print("Invalid StringPoolChunk header")

            return header

        header = readNext(buff)
        return header >> 8, header & 0xFF
1121945
def _handle_lines(self):
        """"""
        while b'\xdd' in self._buffer:
            linebuf, self._buffer = self._buffer.rsplit(b'\xdd', 1)
            line = linebuf[-19:]
            self._buffer += linebuf[:-19]
            if self._valid_packet(line):
                self._handle_raw_packet(line)
            else:
                self.logger.warning('dropping invalid data: %s',
                                    binascii.hexlify(line))
194664
function filterStringChunks (pattern, unfilteredString, filter) {
      var pattenMatches = unfilteredString.match(pattern);
      var filteredString = unfilteredString.replace(pattern, VALUE_PLACEHOLDER);

      if (pattenMatches) {
        var pattenMatchesLength = pattenMatches.length;
        var currentChunk;

        for (var i = 0; i < pattenMatchesLength; i++) {
          currentChunk = pattenMatches.shift();
          filteredString = filteredString.replace(
            VALUE_PLACEHOLDER, filter(currentChunk));
        }
      }

      return filteredString;
    }
391364
static boolean containsDisallowedQuantileLabelForSummary(List<String> labelNames, Type type) {
    if (!Type.SUMMARY.equals(type)) {
      return false;
    }
    for (String label : labelNames) {
      if (LABEL_NAME_QUANTILE.equals(label)) {
        return true;
      }
    }
    return false;
  }
653118
def hexdumpLine (bytes, length=None):
  
  line = ""

  if length is None:
    length = len(bytes)

  for n in xrange(0, length, 2):
    if n < len(bytes) - 1:
      line += "%02x%02x  " % (bytes[n], bytes[n + 1])
    elif n < len(bytes):
      line += "%02x    "   % bytes[n]
    else:
      line += "      "

  line += "*"

  for n in xrange(length):
    if n < len(bytes):
      if bytes[n] in xrange(32, 127):
        line += "%c" % bytes[n]
      else:
        line += "."
    else:
      line += " "

  line += "*"
  return line
951166
def parse_packet(packet):
    """"""
    frame = parse_ltv_packet(packet)
    if frame is None:
        frame = parse_ibeacon_packet(packet)
    return frame
440281
def handle_raw_packet(self, raw_packet):
        """"""
        log.debug('got packet: %s', raw_packet)
        if rflink_log:
            print(raw_packet, file=rflink_log)
            rflink_log.flush()
        packet = None
        try:
            packet = decode_packet(raw_packet)
        except:
            log.exception('failed to parse packet: %s', packet)

        log.debug('decoded packet: %s', packet)

        if packet:
            if 'ok' in packet:
                # handle response packets internally
                log.debug('command response: %s', packet)
                self._last_ack = packet
                self._command_ack.set()
            else:
                self.handle_packet(packet)
        else:
            log.warning('no valid packet')
1089571
function readPESPackets(filter = true, warning = false) {
  var pesBuilder = {};
  var pesMaker = x => {
    if (x.type === 'TSPacket') {
      if (x.payloadUnitStartIndicator === true) {
        if (x.payload.readUIntBE(0, 3) !== 0x000001) {
          if (warning)
            console.log(`Warning: Non PES packet found at payload start indicator for PID ${x.pid}.`);
          return H([x]);
        }
        var pesOptional = x.payload.readUInt16BE(6);
        var pesPacket = {
          type : 'PESPacket',
          pid : x.pid,
          streamID : util.streamIDName[x.payload.readUInt8(3)],
          pesPacketLength : x.payload.readUInt16BE(4),
          scramblingControl : (pesOptional & 0x3000) >>> 12,
          priority : (pesOptional & 0x0800) !== 0,
          dataAlignmentIndicator : (pesOptional & 0x0400) !== 0,
          copyright : (pesOptional & 0x0200) !== 0,
          originalOrCopy : (pesOptional & 0x0100) !== 0,
          ptsDtsIndicator : (pesOptional & 0x00c0) >> 6,
          escrFlag : (pesOptional & 0x0020) !== 0,
          esRateFlag : (pesOptional & 0x0010) !== 0,
          dsmTrickModeFlag : (pesOptional & 0x0008) !== 0,
          additionalCopyInfoFlag : (pesOptional & 0x0004) !== 0,
          crcFlag : (pesOptional & 0x0002) !== 0,
          extensionFlag : (pesOptional & 0x00001) !== 0,
          pesHeaderLength : x.payload.readUInt8(8)
        };
        switch (pesPacket.ptsDtsIndicator) {
        case 2:
          pesPacket.pts = readTimeStamp(x.payload, 9);
          break;
        case 3:
          pesPacket.pts = readTimeStamp(x.payload, 9);
          pesPacket.dts = readTimeStamp(x.payload, 14);
          break;
        default:
          break;
        }
        pesPacket.payloads = [ x.payload.slice(9 + pesPacket.pesHeaderLength) ];
        if (pesBuilder[x.pid]) {
          var finishedPacket = pesBuilder[x.pid];
          pesBuilder[x.pid] = pesPacket;
          return filter ? H([finishedPacket]) : H([x, finishedPacket]);
        } else {
          pesBuilder[x.pid] = pesPacket;
          return filter ? H([]) : H([x]);
        }
      } else { // execute if payloadUnitStartIndicator !== true
        if (pesBuilder[x.pid]) {
          if (x.payload) // Might be a adaptation field only - no payload
            pesBuilder[x.pid].payloads.push(x.payload);
        }
        return filter ? H([]) : H([x]);
      } // payloadUnitStartIndicator === true
    } else {
      return H([x]);
    }  // Is TSPacket
  };
  return H.pipeline(H.flatMap(pesMaker));
}
344886
def _sense_packet_to_data(packet):
        """"""
        data = bytearray(0)
        last = 0
        i = 1
        while (i < len(packet)):
            if not (last == 2 and packet[i] == 0):
                data.append(packet[i])
            last = packet[i]
            i += 1

        return data