# Path: src/stratis_cli/_stratisd_constants.py
# BLOCK_DEV_TIER_TO_NAME = value_to_name(BlockDevTiers)
# 
# STRATISD_ERROR_TO_NAME = value_to_name(StratisdErrors)
# 
# class BlockDevTiers(IntEnum):
#     """
#     Tier to which a blockdev device belongs.
#     """
# 
#     DATA = 0
#     CACHE = 1


import os
from ._stratisd_constants import (
    BLOCK_DEV_TIER_TO_NAME,
    STRATISD_ERROR_TO_NAME,
    BlockDevTiers,
)


class StratisCliInUseOtherTierError(StratisCliInUseError):
    """
    Raised if a request made of stratisd must result in a device being
    included in both data and cache tiers.
    """

    def __init__(self, pools_to_blockdevs, added_as):
        """
        Initializer.

        :param pools_to_blockdevs: pools mapped to the blockdevs they own
        :type pools_to_blockdevs: dict of str * frozenset of str
        :param added_as: what tier the devices were to be added to
        :type added_as: _stratisd_constants.BlockDevTiers

        Precondition: pools_to_blockdevs != {}
        Precondition: all frozenset of str in pools_to_blockdevs have at least one item
        """
        # pylint: disable=super-init-not-called
        self.pools_to_blockdevs = pools_to_blockdevs
        self.added_as = added_as

    def __str__(self):
        (target_blockdev_tier, already_blockdev_tier) = (
            BLOCK_DEV_TIER_TO_NAME(self.added_as),
            BLOCK_DEV_TIER_TO_NAME(
                BlockDevTiers.DATA
                if self.added_as == BlockDevTiers.CACHE

# Path: src/stratis_cli/_stratisd_constants.py
# BLOCK_DEV_TIER_TO_NAME = value_to_name(BlockDevTiers)
# 
# STRATISD_ERROR_TO_NAME = value_to_name(StratisdErrors)
# 
# class BlockDevTiers(IntEnum):
#     """
#     Tier to which a blockdev device belongs.
#     """
# 
#     DATA = 0
#     CACHE = 1


# Path: src/stratis_cli/_errors.py
import os
from ._stratisd_constants import (
    BLOCK_DEV_TIER_TO_NAME,
    STRATISD_ERROR_TO_NAME,
    BlockDevTiers,
)



class StratisCliInUseOtherTierError(StratisCliInUseError):
    """
    Raised if a request made of stratisd must result in a device being
    included in both data and cache tiers.
    """

    def __init__(self, pools_to_blockdevs, added_as):
        """
        Initializer.

        :param pools_to_blockdevs: pools mapped to the blockdevs they own
        :type pools_to_blockdevs: dict of str * frozenset of str
        :param added_as: what tier the devices were to be added to
        :type added_as: _stratisd_constants.BlockDevTiers

        Precondition: pools_to_blockdevs != {}
        Precondition: all frozenset of str in pools_to_blockdevs have at least one item
        """
        # pylint: disable=super-init-not-called
        self.pools_to_blockdevs = pools_to_blockdevs
        self.added_as = added_as

    def __str__(self):
        (target_blockdev_tier, already_blockdev_tier) = (
            BLOCK_DEV_TIER_TO_NAME(self.added_as),
            BLOCK_DEV_TIER_TO_NAME(
                BlockDevTiers.DATA
                if self.added_as == BlockDevTiers.CACHE

                else BlockDevTiers.CACHE