# Path: openformats/exceptions.py
# class RuleError(OpenformatsError):
#     pass


import six
from openformats.exceptions import RuleError
    # Use this flag for handlers whose the content should be processed as
    # binary and not be converted to unicode
    PROCESSES_BINARY = False

    _RULES_ITOA = {value: key for key, value in six.iteritems(_RULES_ATOI)}

    _RULE_ERROR_MSG = (
        '{attempted} is not a valid rule value. Valid choices are {valid}'
    )

    @classmethod
    def get_rule_number(cls, string_value):
        try:
            return cls._RULES_ATOI[string_value]
        except KeyError:
            msg = cls._RULE_ERROR_MSG.format(
                attempted=string_value,
                valid=list(six.iterkeys(cls._RULES_ATOI))
            )
            raise RuleError(msg)

    @classmethod
    def get_rule_string(cls, number_value):
        try:
            return cls._RULES_ITOA[number_value]
        except KeyError:
            msg = cls._RULE_ERROR_MSG.format(
                attempted=number_value,
                valid=list(six.iterkeys(cls._RULES_ITOA))
            )

# Path: openformats/exceptions.py
# class RuleError(OpenformatsError):
#     pass


# Path: openformats/handlers.py
import six
from openformats.exceptions import RuleError

    # Use this flag for handlers whose the content should be processed as
    # binary and not be converted to unicode
    PROCESSES_BINARY = False

    _RULES_ITOA = {value: key for key, value in six.iteritems(_RULES_ATOI)}

    _RULE_ERROR_MSG = (
        '{attempted} is not a valid rule value. Valid choices are {valid}'
    )

    @classmethod
    def get_rule_number(cls, string_value):
        try:
            return cls._RULES_ATOI[string_value]
        except KeyError:
            msg = cls._RULE_ERROR_MSG.format(
                attempted=string_value,
                valid=list(six.iterkeys(cls._RULES_ATOI))
            )
            raise RuleError(msg)

    @classmethod
    def get_rule_string(cls, number_value):
        try:
            return cls._RULES_ITOA[number_value]
        except KeyError:
            msg = cls._RULE_ERROR_MSG.format(
                attempted=number_value,
                valid=list(six.iterkeys(cls._RULES_ITOA))
            )

            raise RuleError(msg)