'Find the configuration file.
:param bool create: If a config file is not found, and create is True, one will be created in the home folder
:raises: `IOError` when no config file could be found, and `create` is False.'

def find_config(self, create=False):

    home_path = os.path.join(os.path.expanduser(u'~'), u'.flexget')
    options_config = os.path.expanduser(self.options.config)
    possible = []
    if os.path.isabs(options_config):
        config = options_config
        possible = [config]
    else:
        log.debug(u'Figuring    out    config    load    paths')
        try:
            possible.append(os.getcwd())
        except OSError:
            log.debug(u'current    directory    invalid,    not    searching    for    config    there')
        if hasattr(sys, u'real_prefix'):
            log.debug(u'Adding    virtualenv    path')
            possible.append(sys.prefix)
        possible.append(home_path)
        if sys.platform.startswith(u'win'):
            home_path = os.path.join(os.path.expanduser(u'~'), u'flexget')
            possible.append(home_path)
        else:
            xdg_config = os.environ.get(u'XDG_CONFIG_HOME', os.path.join(os.path.expanduser(u'~'), u'.config'))
            possible.append(os.path.join(xdg_config, u'flexget'))
        for path in possible:
            config = os.path.join(path, options_config)
            if os.path.exists(config):
                log.debug((u'Found    config:    %s' % config))
                break
        else:
            config = None
    if (create and (not (config and os.path.exists(config)))):
        config = os.path.join(home_path, options_config)
        log.info((u'Config    file    %s    not    found.    Creating    new    config    %s' % (options_config, config)))
        with open(config, u'w') as newconfig:
            newconfig.write(yaml.dump({u'tasks': {}}))
    elif (not config):
        log.critical((u'Failed    to    find    configuration    file    %s' % options_config))
        log.info((u'Tried    to    read    from:    %s' % u',    '.join(possible)))
        raise IOError(u'No    configuration    file    found.')
    if (not os.path.isfile(config)):
        raise IOError((u'Config    `%s`    does    not    appear    to    be    a    file.' % config))
    log.debug((u'Config    file    %s    selected' % config))
    self.config_path = config
    self.config_name = os.path.splitext(os.path.basename(config))[0]
    self.config_base = os.path.normpath(os.path.dirname(config))
    self.lockfile = os.path.join(self.config_base, (u'.%s-lock' % self.config_name))
    self.db_filename = os.path.join(self.config_base, (u'db-%s.sqlite' % self.config_name))
