'Returns a file to be edited for the given requested_ft.
If \'bang\' is
empty only private files in g:UltiSnipsSnippetsDir are considered,
otherwise all files are considered and the user gets to choose.'

def _file_to_edit(self, requested_ft, bang):

    snippet_dir = ''
    if (_vim.eval("exists('g:UltiSnipsSnippetsDir')") == '1'):
        dir = _vim.eval('g:UltiSnipsSnippetsDir')
        file = self._get_file_to_edit(dir, requested_ft, bang)
        if file:
            return file
        snippet_dir = dir
    if (_vim.eval("exists('g:UltiSnipsSnippetDirectories')") == '1'):
        dirs = _vim.eval('g:UltiSnipsSnippetDirectories')
        for dir in dirs:
            file = self._get_file_to_edit(dir, requested_ft, bang)
            if file:
                return file
            if (not snippet_dir):
                snippet_dir = dir
    home = _vim.eval('$HOME')
    if (platform.system() == 'Windows'):
        dir = os.path.join(home, 'vimfiles', 'UltiSnips')
        file = self._get_file_to_edit(dir, requested_ft, bang)
        if file:
            return file
        if (not snippet_dir):
            snippet_dir = dir
    if (_vim.eval("has('nvim')") == '1'):
        xdg_home_config = (_vim.eval('$XDG_CONFIG_HOME') or os.path.join(home, '.config'))
        dir = os.path.join(xdg_home_config, 'nvim', 'UltiSnips')
        file = self._get_file_to_edit(dir, requested_ft, bang)
        if file:
            return file
        if (not snippet_dir):
            snippet_dir = dir
    dir = os.path.join(home, '.vim', 'UltiSnips')
    file = self._get_file_to_edit(dir, requested_ft, bang)
    if file:
        return file
    if (not snippet_dir):
        snippet_dir = dir
    return self._get_file_to_edit(snippet_dir, requested_ft, bang, True)
