.. versionadded:: 0.20

    Parameters
    ----------
    only_conda : bool, optional
        Only consider plugins that are installed **as Conda packages**.

        .. versionadded:: 0.22

    Returns
    -------
    list
        List of properties corresponding to each available plugin that is
        **installed**.

        .. versionchanged:: 0.22

            If :data:`only_conda` is ``False``, a plugin is assumed to be
            *installed* if it is present in the
            ``share/microdrop/plugins/available`` directory **and** is a
            **real** directory (i.e., not a link).

            If :data:`only_conda` is ``True``, only properties for plugins that
            are installed **as Conda packages** are returned.

def installed_plugins(only_conda=False):
    '''
    .. versionadded:: 0.20

    Parameters
    ----------
    only_conda : bool, optional
        Only consider plugins that are installed **as Conda packages**.

        .. versionadded:: 0.22

    Returns
    -------
    list
        List of properties corresponding to each available plugin that is
        **installed**.

        .. versionchanged:: 0.22

            If :data:`only_conda` is ``False``, a plugin is assumed to be
            *installed* if it is present in the
            ``share/microdrop/plugins/available`` directory **and** is a
            **real** directory (i.e., not a link).

            If :data:`only_conda` is ``True``, only properties for plugins that
            are installed **as Conda packages** are returned.
    '''
    available_path = MICRODROP_CONDA_SHARE.joinpath('plugins', 'available')
    if not available_path.isdir():
        return []
    installed_plugins_ = []
    for plugin_path_i in available_path.dirs():
        # Only process plugin directory if it is *not a link*.
        if not _islinklike(plugin_path_i):
            # Read plugin package info from `properties.yml` file.
            try:
                with plugin_path_i.joinpath('properties.yml').open('r') as input_:
                    properties_i = yaml.load(input_.read())
            except:
                logger.info('[warning] Could not read package info: `%s`',
                            plugin_path_i.joinpath('properties.yml'),
                            exc_info=True)
            else:
                properties_i['path'] = plugin_path_i.realpath()
                installed_plugins_.append(properties_i)

    if only_conda:
        # Only consider plugins that are installed **as Conda packages**.
        try:
            package_names = [plugin_i['package_name']
                             for plugin_i in installed_plugins_]
            conda_package_infos = ch.package_version(package_names,
                                                     verbose=False)
        except ch.PackageNotFound, exception:
            # At least one specified plugin package name did not correspond to an
            # installed Conda package.
            logger.warning(str(exception))
            conda_package_infos = exception.available
        # Extract name from each Conda plugin package.
        installed_package_names = set([package_i['name']
                                       for package_i in conda_package_infos])
        return [plugin_i for plugin_i in installed_plugins_
                if plugin_i['package_name'] in installed_package_names]
    else:
        # Return all available plugins.
        return installed_plugins_