# Path: harpoon/errors.py
# class NoSuchEnvironmentVariable(HarpoonError):
#     desc = "Couldn't find environment variable"


from harpoon.errors import NoSuchEnvironmentVariable
from delfick_project.option_merge.formatter import MergedOptionStringFormatter
import os

        class dictsubclass(dict): pass
        configuration = MergedOptions.using({"some_object": dictsubclass({1:2, 3:4})}, dont_prefix=[dictsubclass])
        formatter = MergedOptionStringFormatter(configuration, "{some_object}")
        val = formatter.format()
        # val == {1:2, 3:4}

    For this to work, the object must be a subclass of dict and in the dont_prefix option of the configuration.
    """

    passthrough_format_specs = ["env", "from_env"]

    def get_string(self, key):
        """Get a string from all_options"""
        # Make sure we special case the "content" option
        if type(key) is str and key.startswith("content."):
            return self.no_format(self.all_options["content"][key[8:]])

        if type(key) is list and len(key) == 2 and key[0] == "content":
            return self.no_format(self.all_options[key])

        return super().get_string(key)

    def special_format_field(self, obj, format_spec):
        """Know about any special formats"""
        if format_spec == "env":
            return "${{{0}}}".format(obj)

        elif format_spec == "from_env":
            if obj not in os.environ:

# Path: harpoon/errors.py
# class NoSuchEnvironmentVariable(HarpoonError):
#     desc = "Couldn't find environment variable"


# Path: harpoon/formatter.py
from harpoon.errors import NoSuchEnvironmentVariable
from delfick_project.option_merge.formatter import MergedOptionStringFormatter
import os


        class dictsubclass(dict): pass
        configuration = MergedOptions.using({"some_object": dictsubclass({1:2, 3:4})}, dont_prefix=[dictsubclass])
        formatter = MergedOptionStringFormatter(configuration, "{some_object}")
        val = formatter.format()
        # val == {1:2, 3:4}

    For this to work, the object must be a subclass of dict and in the dont_prefix option of the configuration.
    """

    passthrough_format_specs = ["env", "from_env"]

    def get_string(self, key):
        """Get a string from all_options"""
        # Make sure we special case the "content" option
        if type(key) is str and key.startswith("content."):
            return self.no_format(self.all_options["content"][key[8:]])

        if type(key) is list and len(key) == 2 and key[0] == "content":
            return self.no_format(self.all_options[key])

        return super().get_string(key)

    def special_format_field(self, obj, format_spec):
        """Know about any special formats"""
        if format_spec == "env":
            return "${{{0}}}".format(obj)

        elif format_spec == "from_env":
            if obj not in os.environ:

                raise NoSuchEnvironmentVariable(wanted=obj)