def _open_bde_container(self):
        """Mounts a BDE container. Uses key material provided by the :attr:`keys` attribute. The key material should be
        provided in the same format as to :cmd:`bdemount`, used as follows:

        k:full volume encryption and tweak key
        p:passphrase
        r:recovery password
        s:file to startup key (.bek)

        :return: the Volume contained in the BDE container, or None on failure.
        """

        self.bde_path = tempfile.mkdtemp(prefix='image_mounter_bde_')

        try:
            if str(self.index) in self.keys:
                t, v = self.keys[str(self.index)].split(':', 1)
                key = ['-' + t, v]
            else:
                logger.warning("No key material provided for %s", self)
                key = []
        except __HOLE__:
            logger.exception("Invalid key material provided (%s) for %s. Expecting [arg]:[value]",
                             self.keys.get(str(self.index)), self)
            return None

        # noinspection PyBroadException
        try:
            cmd = ["bdemount", self.get_raw_path(), self.bde_path, '-o', str(self.offset)]
            cmd.extend(key)
            _util.check_call_(cmd)
        except Exception:
            self.bde_path = ""
            logger.exception("Failed mounting BDE volume %s.", self)
            return None

        container = self.volumes._make_subvolume()
        container.index = "{0}.0".format(self.index)
        container.fsdescription = 'BDE Volume'
        container.flag = 'alloc'
        container.offset = 0
        container.size = self.size

        return container
dataset/ETHPy150Open ralphje/imagemounter/imagemounter/volume.py/Volume._open_bde_container