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

    Positional arguments:
    data -- bytearray data to read.

    Returns:
    Dict.
968038
def get_wifi_wmm_param(data):
    
    answers = dict()
    aci_tbl = ('BE', 'BK', 'VI', 'VO')
    if data[0] & 0x80:
        answers['u-APSD'] = True
    data = data[2:]

    for i in range(4):
        key = aci_tbl[(data[0] >> 5) & 3]
        value = dict()
        if data[0] & 0x10:
            value['acm'] = True
        value['CW'] = ((1 << (data[1] & 0xf)) - 1, (1 << (data[1] >> 4)) - 1)
        value['AIFSN'] = data[0] & 0xf
        if data[2] | data[3]:
            value['TXOP'] = (data[2] + (data[3] << 8)) * 32
        answers[key] = value
        data = data[4:]

    return {'Parameter version 1': answers}
1341156
def _load_data(self):
        
        ipa_canonical_string_to_ascii_str = dict()
        for line in load_data_file(
            file_path=self.DATA_FILE_PATH,
            file_path_is_relative=True,
            line_format=u"sxA"
        ):
            i_desc, i_ascii = line
            if len(i_ascii) == 0:
                raise ValueError("Data file '%s' contains a bad line: '%s'" % (self.DATA_FILE_PATH, line))
            key = (variant_to_canonical_string(i_desc),)
            ipa_canonical_string_to_ascii_str[key] = i_ascii[0]
        return ipa_canonical_string_to_ascii_str
498458
def get_data(self, datatype, mode, disp):
        

        # Imports
        import os
        from ..const import EnumDispDirection as _E_DD
        from ..const import EnumAnharmRepoData
        from ..error import RepoError as RErr

        # Must be valid mode
        if not (mode >=0 and isinstance(mode, int)):
            raise ValueError("Mode must be a non-negative integer")
        ## end if

        # Must be a valid disp direction
        if not disp in _E_DD:
            raise ValueError("'{0}' is not a valid " +
                    "displacement enum value".format(disp))
        ## end if

        # Must be a valid data type
        if not datatype in EnumAnharmRepoData:
            raise ValueError("'{0}' is not a valid " +
                    "repository data type enum value".format(datatype))
        ## end if

        # Get the appropriate geom group name
        if disp == _E_DD.NO_DISP:
            grpname = self.G_geom_ref
        else:
            grpname = self.F_mode_fmt % \
                                    (mode, self.dircode[disp])
        ## end if

        # Get the group, complaining if repo not bound
        try:
            grp = self._repo.get(grpname)
        except AttributeError:
            raise RErr(RErr.STATUS,
                        "Cannot load; no repository open", "")
        ## end try

        # If succeeded, check if group not found
        if grp is None:
            raise RErr(RErr.GROUP,
                    "Group '" + grpname + "' not found",
                    self.fname)
        ## end if

        # Group found, try loading the data object; complain if not found
        try:
            out_data = grp.get(datatype).value
        except AttributeError:
            raise RErr(RErr.DATA,
                    "Dataset '" + datatype + "' not found",
                    self.fname)
        ## end try

        # Return as-is (h5py creates NumPy arrays of appropriate dimensions)
        return out_data
281645
def get_blocks_byte_array(self, buffer=False):
        """"""
        if buffer:
            length = len(self.blocksList)
            return BytesIO(pack(">i", length)+self.get_blocks_byte_array())
        else:
            return array.array('B', self.blocksList).tostring()
880082
def tree_entries_from_data(data):
    """"""
    ord_zero = ord('0')
    space_ord = ord(' ')
    len_data = len(data)
    i = 0
    out = []
    while i < len_data:
        mode = 0

        # read mode
        # Some git versions truncate the leading 0, some don't
        # The type will be extracted from the mode later
        while byte_ord(data[i]) != space_ord:
            # move existing mode integer up one level being 3 bits
            # and add the actual ordinal value of the character
            mode = (mode << 3) + (byte_ord(data[i]) - ord_zero)
            i += 1
        # END while reading mode

        # byte is space now, skip it
        i += 1

        # parse name, it is NULL separated

        ns = i
        while byte_ord(data[i]) != 0:
            i += 1
        # END while not reached NULL

        # default encoding for strings in git is utf8
        # Only use the respective unicode object if the byte stream was encoded
        name = data[ns:i]
        name = safe_decode(name)

        # byte is NULL, get next 20
        i += 1
        sha = data[i:i + 20]
        i = i + 20
        out.append((sha, mode, name))
    # END for each byte in data stream
    return out
892162
def bytes_array(self):
        ''''''
        assert len(self.dimensions) == 2, \
            '{}: cannot get value as bytes array!'.format(self.name)
        l, n = self.dimensions
        return [self.bytes[i*l:(i+1)*l] for i in range(n)]
382012
def extractBinaries(binaryDataArrayList, arrayLength):
    
    extractedArrays = dict()
    arrayInfo = dict()
    for binaryData in binaryDataArrayList:
        if findParam(binaryData['params'], 'MS:1000523') is not None:
            bitEncoding = '64'
        else:
            bitEncoding = '32'
        if findParam(binaryData['params'], 'MS:1000574') is not None:
            compression = 'zlib'
        else:
            compression = None
        dataType, dataTypeParam = findBinaryDataType(binaryData['params'])
        if binaryData['binary']:
            extractedArrays[dataType] = decodeBinaryData(binaryData['binary'],
                                                         arrayLength,
                                                         bitEncoding,
                                                         compression
                                                         )
        else:
            __, numpyType = interpretBitEncoding(bitEncoding)
            extractedArrays[dataType] = numpy.array([], dtype=numpyType)

        binaryData['binary'] = None
        arrayInfo[dataType] = {'dataProcessingRef': None,
                               'params': binaryData['params']
                               }
        if 'dataProcessingRef' in binaryData:
            arrayInfo[dataType]['dataProcessingRef'] = \
                binaryData['dataProcessingRef']
    return extractedArrays, arrayInfo
355921
def retrieve_data(file_paths):

    
    data_dict = {}
    for file_path in file_paths:
        with open(file_path) as fh:
            try:
                content = yaml.load(fh.read())
            except yaml.YAMLError as e:
                raise MiuraException(
                    "Unable to parse yaml at {0}: \n {1}".format(
                        file_path,
                        str(e)
                    ))
            if not isinstance(content, dict):
                raise MiuraException(
                    "{0} is does not translate to a dictionary!".format(file_path)
                )
            data_dict.update(content)
    return data_dict
615083
def read_cz_lsm_scan_info(fd, byte_order):
    """"""
    block = Record()
    blocks = [block]
    unpack = struct.unpack
    if 0x10000000 != struct.unpack(byte_order+"I", fd.read(4))[0]:
        raise ValueError("not a lsm_scan_info structure")
    fd.read(8)
    while True:
        entry, dtype, size = unpack(byte_order+"III", fd.read(12))
        if dtype == 2:
            value = stripnull(fd.read(size))
        elif dtype == 4:
            value = unpack(byte_order+"i", fd.read(4))[0]
        elif dtype == 5:
            value = unpack(byte_order+"d", fd.read(8))[0]
        else:
            value = 0
        if entry in CZ_LSM_SCAN_INFO_ARRAYS:
            blocks.append(block)
            name = CZ_LSM_SCAN_INFO_ARRAYS[entry]
            newobj = []
            setattr(block, name, newobj)
            block = newobj
        elif entry in CZ_LSM_SCAN_INFO_STRUCTS:
            blocks.append(block)
            newobj = Record()
            block.append(newobj)
            block = newobj
        elif entry in CZ_LSM_SCAN_INFO_ATTRIBUTES:
            name = CZ_LSM_SCAN_INFO_ATTRIBUTES[entry]
            setattr(block, name, value)
        elif entry == 0xffffffff:
            block = blocks.pop()
        else:
            setattr(block, "unknown_%x" % entry, value)
        if not blocks:
            break
    return block
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))
905294
def _data(self):
        """"""
        current_position = self.file.tell()
        self.file.seek(self.position)
        data = self.file.read(self.length)
        self.file.seek(current_position)
        if self.length % 2:
            data += '\x00' # Padding byte
        return data
1211889
def __read(self, i: int) -> bytes:
        """"""
        b = self.data[self.idx: self.idx + i]
        self.idx += i
        if len(b) != i:
            raise bencodepy.DecodingError(
                "Incorrect byte length returned between indexes of {0} and {1}. Possible unexpected End of File."
                    .format(str(self.idx), str(self.idx - i)))
        return b
1116966
def _read_var_data(self):
        

        var_bundles = OrderedDict()
        var_attrs = OrderedDict()

        n_vars = 0

        while self.fp.tell() < self.fsize:

            var_attr = OrderedDict()

            # read first and second header lines
            line = self.fp.readline('20sffii')
            modelname, res0, res1, halfpolar, center180 = line

            line = self.fp.readline('40si40sdd40s7i')
            category_name, number, unit, tau0, tau1, reserved = line[:6]
            dim0, dim1, dim2, dim3, dim4, dim5, skip = line[6:]
            var_attr['number'] = number

            # Decode byte-strings to utf-8
            category_name = str(category_name, 'utf-8')
            var_attr['category'] = category_name.strip()
            unit = str(unit, 'utf-8')

            # get additional metadata from tracerinfo / diaginfo
            try:
                cat_df = self.diaginfo_df[
                    self.diaginfo_df.name == category_name.strip()
                ]
                # TODO: Safer logic for handling case where more than one
                #       tracer metadata match was made
                # if len(cat_df > 1):
                #     raise ValueError(
                #         "More than one category matching {} found in "
                #         "diaginfo.dat".format(
                #             category_name.strip()
                #         )
                #     )
                # Safe now to select the only row in the DataFrame
                cat = cat_df.T.squeeze()

                tracer_num = int(cat.offset) + int(number)
                diag_df = self.tracerinfo_df[
                    self.tracerinfo_df.tracer == tracer_num
                ]
                # TODO: Safer logic for handling case where more than one
                #       tracer metadata match was made
                # if len(diag_df > 1):
                #     raise ValueError(
                #         "More than one tracer matching {:d} found in "
                #         "tracerinfo.dat".format(tracer_num)
                #     )
                # Safe now to select only row in the DataFrame
                diag = diag_df.T.squeeze()
                diag_attr = diag.to_dict()

                if not unit.strip():  # unit may be empty in bpch
                    unit = diag_attr['unit']  # but not in tracerinfo
                var_attr.update(diag_attr)
            except:
                diag = {'name': '', 'scale': 1}
                var_attr.update(diag)
            var_attr['unit'] = unit

            vname = diag['name']
            fullname = category_name.strip() + "_" + vname

            # parse metadata, get data or set a data proxy
            if dim2 == 1:
                data_shape = (dim0, dim1)         # 2D field
            else:
                data_shape = (dim0, dim1, dim2)
            var_attr['original_shape'] = data_shape

            # Add proxy time dimension to shape
            data_shape = tuple([1, ] + list(data_shape))
            origin = (dim3, dim4, dim5)
            var_attr['origin'] = origin

            timelo, timehi = cf.tau2time(tau0), cf.tau2time(tau1)

            pos = self.fp.tell()
            # Note that we don't pass a dtype, and assume everything is
            # single-fp floats with the correct endian, as hard-coded
            var_bundle = BPCHDataBundle(
                data_shape, self.endian, self.filename, pos, [timelo, timehi],
                metadata=var_attr,
                use_mmap=self.use_mmap, dask_delayed=self.dask_delayed
            )
            self.fp.skipline()

            # Save the data as a "bundle" for concatenating in the final step
            if fullname in var_bundles:
                var_bundles[fullname].append(var_bundle)
            else:
                var_bundles[fullname] = [var_bundle, ]
                var_attrs[fullname] = var_attr
                n_vars += 1

        self.var_data = var_bundles
        self.var_attrs = var_attrs
317929
def _read_data(self, fh, byteorder='>'):
        """"""
        fh.seek(len(self.header))
        data = fh.read()
        dtype = 'u1' if self.maxval < 256 else byteorder + 'u2'
        depth = 1 if self.magicnum == b"P7 332" else self.depth
        shape = [-1, self.height, self.width, depth]
        size = numpy.prod(shape[1:])
        if self.magicnum in b"P1P2P3":
            data = numpy.array(data.split(None, size)[:size], dtype)
            data = data.reshape(shape)
        elif self.maxval == 1:
            shape[2] = int(math.ceil(self.width / 8))
            data = numpy.frombuffer(data, dtype).reshape(shape)
            data = numpy.unpackbits(data, axis=-2)[:, :, :self.width, :]
        else:
            data = numpy.frombuffer(data, dtype)
            data = data[:size * (data.size // size)].reshape(shape)
        if data.shape[0] < 2:
            data = data.reshape(data.shape[1:])
        if data.shape[-1] < 2:
            data = data.reshape(data.shape[:-1])
        if self.magicnum == b"P7 332":
            rgb332 = numpy.array(list(numpy.ndindex(8, 8, 4)), numpy.uint8)
            rgb332 *= [36, 36, 85]
            data = numpy.take(rgb332, data, axis=0)
        return data
1163676
def getBinaryData(self, name, channel=None):
        
        return self._getNodeData(name, self._BINARYNODE, channel)
67759
def parse(self, data):
        # type: (bytes) -> None
        '''
        
        '''
        (self.len_di, self.xattr_length, self.extent_location,
         self.parent_directory_num) = struct.unpack_from(self.FMT, data[:8], 0)

        if self.len_di % 2 != 0:
            self.directory_identifier = data[8:-1]
        else:
            self.directory_identifier = data[8:]
        self.dirrecord = None
        self._initialized = True
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,
        }