# Path: boussole/exceptions.py
# class SettingsDiscoveryError(BoussoleBaseException):
#     """
#     Exception to be raised when config discovery has failed to find settings
#     file.
#     """
#     pass


import os
from collections import OrderedDict
from ..exceptions import SettingsDiscoveryError
            tuple: Absolute filepath and backend engine class.
        """
        # None values would cause trouble with path joining
        if filepath is None:
            filepath = ""
        if basedir is None:
            basedir = "."

        if not basedir and not filepath:
            msg = "Either basedir or filepath is required for discovering"
            raise SettingsDiscoveryError(msg)

        if kind and kind not in self.engines:
            msg = "Given settings format is unknow: {}"
            raise SettingsDiscoveryError(msg.format(kind))

        # Implicit filename to find from backend
        if not filepath:
            filename, engine = self.guess_filename(basedir, kind)
            filepath = os.path.join(basedir, filename)
        # Explicit filename dont have to search for default backend file and
        # blindly force given backend if any
        else:
            if os.path.isabs(filepath):
                basedir, filename = os.path.split(filepath)
            else:
                filepath = os.path.join(basedir, filepath)

            if not os.path.exists(filepath):
                msg = "Given settings file does not exists: {}"

# Path: boussole/exceptions.py
# class SettingsDiscoveryError(BoussoleBaseException):
#     """
#     Exception to be raised when config discovery has failed to find settings
#     file.
#     """
#     pass


# Path: boussole/conf/discovery.py
import os
from collections import OrderedDict
from ..exceptions import SettingsDiscoveryError

            tuple: Absolute filepath and backend engine class.
        """
        # None values would cause trouble with path joining
        if filepath is None:
            filepath = ""
        if basedir is None:
            basedir = "."

        if not basedir and not filepath:
            msg = "Either basedir or filepath is required for discovering"
            raise SettingsDiscoveryError(msg)

        if kind and kind not in self.engines:
            msg = "Given settings format is unknow: {}"
            raise SettingsDiscoveryError(msg.format(kind))

        # Implicit filename to find from backend
        if not filepath:
            filename, engine = self.guess_filename(basedir, kind)
            filepath = os.path.join(basedir, filename)
        # Explicit filename dont have to search for default backend file and
        # blindly force given backend if any
        else:
            if os.path.isabs(filepath):
                basedir, filename = os.path.split(filepath)
            else:
                filepath = os.path.join(basedir, filepath)

            if not os.path.exists(filepath):
                msg = "Given settings file does not exists: {}"

                raise SettingsDiscoveryError(msg.format(filepath))