<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def load_config(config, expand_env=False, force=False):
 """Return repos from a directory and fnmatch. Not recursive. :param config: paths to config file :type config: str :param expand_env: True to expand environment varialbes in the config. :type expand_env: bool :param bool force: True to aggregate even if repo is dirty. :returns: expanded config dict item :rtype: iter(dict) """

    if not os.path.exists(config):
        raise ConfigException('Unable to find configuration file: %s' % config)

    file_extension = os.path.splitext(config)[1][1:]
    conf = kaptan.Kaptan(handler=kaptan.HANDLER_EXT.get(file_extension))

    if expand_env:
        with open(config, 'r') as file_handler:
            config = Template(file_handler.read())
            config = config.substitute(os.environ)

    conf.import_config(config)
    return get_repos(conf.export('dict') or {}, force)