http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n1401.

    Positional arguments:
    data -- bytearray data to read.

    Returns:
    Dictionary of parsed data with string keys.
433450
def get_vendor(data):
    
    if len(data) < 3:
        return dict(('Vendor specific: <too short> data', ' '.join(format(x, '02x'))) for x in data)
    key = data[3]

    if bytes(data[:3]) == ms_oui:
        if key in wifiprinters and wifiprinters[key].flags & 1:
            return get_ie(wifiprinters[key], key, data[4:])
        return dict(('MS/WiFi {0:02x}, data'.format(key), ' '.join(format(x, '02x'))) for x in data[4:])

    if bytes(data[:3]) == wfa_oui:
        if key in wfa_printers and wfa_printers[key].flags & 1:
            return get_ie(wfa_printers[key], key, data[4:])
        return dict(('WFA {0:02x}, data'.format(key), ' '.join(format(x, '02x'))) for x in data[4:])

    unknown_key = 'Vendor specific: OUI {0:02x}:{1:02x}:{2:02x}, data'.format(data[0], data[1], data[2])
    unknown_value = ' '.join(format(x, '02x') for x in data[3:])
    return {unknown_key: unknown_value}
1054792
def get_json_log_data(data):
    
    log_data = data
    for param in LOG_HIDDEN_JSON_PARAMS:
        if param in data['params']:
            if log_data is data:
                log_data = copy.deepcopy(data)
            log_data['params'][param] = "**********"
    return log_data
778502
def get_data_byte_array(self, buffer=False):
        """"""
        if buffer:
            length = len(self.dataList)
            return BytesIO(pack(">i", length)+self.get_data_byte_array())
        else:
            return array.array('B', self.dataList).tostring()
46411
def read_binary_data(fname,fd,length)
      CFData.new(read_fd(fd, length), CFData::DATA_RAW)
    end
131397
def binary_to_term(data):
    
    if not isinstance(data, bytes):
        raise ParseException('not bytes input')
    size = len(data)
    if size <= 1:
        raise ParseException('null input')
    if b_ord(data[0]) != _TAG_VERSION:
        raise ParseException('invalid version')
    try:
        i, term = _binary_to_term(1, data)
        if i != size:
            raise ParseException('unparsed data')
        return term
    except struct.error:
        raise ParseException('missing data')
    except IndexError:
        raise ParseException('missing data')
622910
def recognize_array(self, byte_array):
        
        if type(byte_array) != bytes:
            raise TypeError("Expected a byte array (string in Python 2, bytes in Python 3)")
        pb = ctypes.cast(byte_array, ctypes.POINTER(ctypes.c_ubyte))
        ptr = self._recognize_array_func(self.alpr_pointer, pb, len(byte_array))
        json_data = ctypes.cast(ptr, ctypes.c_char_p).value
        json_data = _convert_from_charp(json_data)
        response_obj = json.loads(json_data)
        self._free_json_mem_func(ctypes.c_void_p(ptr))
        return response_obj
464468
private void parseData(byte[] data)
	{
		int bytesRead = 0;

		if (grouped)
		{
			group = data[bytesRead];
			bytesRead ++;
		}
		if (encrypted)
		{
			encrType = data[bytesRead];
			bytesRead ++;
		}
		if (lengthIndicator)
		{
			dataLength = Helpers.convertDWordToInt(data, bytesRead);
			bytesRead += 4;
		}

		frameData = new byte[data.length - bytesRead];
		System.arraycopy(data, bytesRead, frameData, 0, frameData.length);
	}
1135553
def _read_dict(self, f):
        
        d = {}
        for k, item in f.items():
            if type(item) == h5py._hl.dataset.Dataset:
                v = item.value
                if type(v) == np.string_:
                    v = str(v)
                if type(v) == str and v == "NONE":
                    d[k] = None
                elif type(v) == str and v == "EMPTYARR":
                    d[k] = np.array([])
                elif isinstance(v, bytes):
                    d[k] = v.decode('utf-8')
                else:
                    d[k] = v

            elif k[:5] == "DICT_":
                d[k[5:]] = self._read_dict(item)
            elif k[:5] == "LIST_":
                tmpD = self._read_dict(item)
                d[k[5:]] = [tmpD[str(i)] for i in range(len(tmpD))]
        return d
561197
def parse(cls, data: bytes) -> 'MessageContent':
        
        lines = cls._find_lines(data)
        view = memoryview(data)
        return cls._parse(data, view, lines)
620559
def parse(data):
    

    # convert to string
    data = data.decode("ascii")

    if len(data) == 2 and data == "A5":
        return AckMessage()

    # split into bytes
    raw = [data[i:i+2] for i in range(len(data)) if i % 2 == 0]

    if len(raw) != 7:
        return UnknownMessage(raw)

    if raw[1] == "B8":
        return StateMessage(raw)
    elif raw[3] == "12":
        return CommandMessage(raw)
    elif raw[3] == "14":
        return ScenarioTriggeredMessage(raw)
    elif raw[3] == "15":
        return RequestStatusMessage(raw)
    else:
        return UnknownMessage(raw)
222355
def load_data_file(filename, encoding='utf-8'):
    
    data = pkgutil.get_data(PACKAGE_NAME, os.path.join(DATA_DIR, filename))
    return data.decode(encoding).splitlines()
689816
def read_data_types(self):
        """"""
        return {
            'Binary': self.read_binary,
            'BinaryArray': self.read_binary_array,
            'KeyValue': self.read_key_value,
            'KeyValueArray': self.read_key_value_array,
            'String': self.read_string,
            'StringArray': self.read_string_array,
            'TCEntity': self.read_tc_entity,
            'TCEntityArray': self.read_tc_entity_array,
        }
621662
def parse(self, data: bytes, context=None):
        
        stream = BytesIO(data)
        return self.parse_stream(stream, context)
1020449
def get_strings(data):
    
    # if this is a unicode string, return its string representation
    if isinstance(data, unicode):
        return data.encode('utf-8')

    # if this is a list of values, return list of string values
    if isinstance(data, list):
        return [get_strings(item) for item in data]

    # if this is a dictionary, return dictionary of string keys and values
    if isinstance(data, dict):
        return {
            get_strings(key): get_strings(value)
            for key, value in data.iteritems()
        }
    # if it's anything else, return it in its original form
    return data
32078
def data(self):
    
    try:
      return self._pyregf_value.data
    except IOError as exception:
      raise errors.WinRegistryValueError(
          'Unable to read data from value: {0:s} with error: {1!s}'.format(
              self._pyregf_value.name, exception))
496806
def readPlistFromString(data):
    ''''''
    try:
        plistData = buffer(data)
    except TypeError, err:
        raise NSPropertyListSerializationException(err)
    dataObject, dummy_plistFormat, error = (
        NSPropertyListSerialization.
        propertyListFromData_mutabilityOption_format_errorDescription_(
            plistData, NSPropertyListMutableContainers, None, None))
    if dataObject is None:
        if error:
            error = error.encode('ascii', 'ignore')
        else:
            error = "Unknown error"
        raise NSPropertyListSerializationException(error)
    else:
        return dataObject
137882
private DataType readDataType() {
    String name = readWord();
    switch (name) {
      case "map":
        if (readChar() != '<') throw unexpected("expected '<'");
        DataType keyType = readDataType();
        if (readChar() != ',') throw unexpected("expected ','");
        DataType valueType = readDataType();
        if (readChar() != '>') throw unexpected("expected '>'");
        return MapType.create(keyType, valueType);
      case "any":
        return ScalarType.ANY;
      case "bool":
        return ScalarType.BOOL;
      case "bytes":
        return ScalarType.BYTES;
      case "double":
        return ScalarType.DOUBLE;
      case "float":
        return ScalarType.FLOAT;
      case "fixed32":
        return ScalarType.FIXED32;
      case "fixed64":
        return ScalarType.FIXED64;
      case "int32":
        return ScalarType.INT32;
      case "int64":
        return ScalarType.INT64;
      case "sfixed32":
        return ScalarType.SFIXED32;
      case "sfixed64":
        return ScalarType.SFIXED64;
      case "sint32":
        return ScalarType.SINT32;
      case "sint64":
        return ScalarType.SINT64;
      case "string":
        return ScalarType.STRING;
      case "uint32":
        return ScalarType.UINT32;
      case "uint64":
        return ScalarType.UINT64;
      default:
        return NamedType.create(name);
    }
  }