コード例 #1
0
ファイル: github.py プロジェクト: momo-lab/vim-gista
 def _request_entries(lock,
                      queue,
                      entries_per_pages,
                      url,
                      headers,
                      callback=None):
     try:
         while True:
             page, indicator = queue.popleft()
             entries = request_json(url, headers=headers, page=page)
             entries_per_pages.append([page, entries])
             if callback:
                 message = indicator % {'page': len(entries_per_pages)}
                 if hasattr(vim, 'async_call'):
                     with lock:
                         vim.async_call(callback, message)
                 else:
                     with lock:
                         callback(message)
     except IndexError:
         pass
     except Exception as e:
         # clear queue to stop other threads
         queue.clear()
         entries_per_pages.append(e)
コード例 #2
0
    def _executeCmd(self, root, dbpath):
        if not os.path.exists(dbpath):
            os.makedirs(dbpath)
        cmd = self._file_list_cmd(root)
        if cmd:
            if os.name == 'nt':
                cmd = 'cd {}"{}" && ( {} ) | gtags -i {}{}{}{}--gtagslabel {} -f- "{}"'.format(
                    self._cd_option, root, cmd, self._accept_dotfiles,
                    self._skip_unreadable, self._skip_symlink,
                    '--gtagsconf %s ' %
                    self._gtagsconf if self._gtagsconf else "",
                    self._gtagslabel, dbpath)
            else:
                cmd = 'cd {}"{}" && {{ {}; }} | gtags -i {}{}{}{}--gtagslabel {} -f- "{}"'.format(
                    self._cd_option, root, cmd, self._accept_dotfiles,
                    self._skip_unreadable, self._skip_symlink,
                    '--gtagsconf %s ' %
                    self._gtagsconf if self._gtagsconf else "",
                    self._gtagslabel, dbpath)
        else:
            cmd = 'cd {}"{}" && gtags -i {}{}{}{}--gtagslabel {} "{}"'.format(
                self._cd_option, root, self._accept_dotfiles,
                self._skip_unreadable, self._skip_symlink,
                '--gtagsconf %s ' % self._gtagsconf if self._gtagsconf else "",
                self._gtagslabel, dbpath)

        env = os.environ
        env["GTAGSFORCECPP"] = ""
        proc = subprocess.Popen(cmd,
                                shell=True,
                                universal_newlines=True,
                                stderr=subprocess.PIPE,
                                env=env)
        _, error = proc.communicate()

        def print_log(args):
            print(args)

        if error:
            if self._has_nvim:
                vim.async_call(print_log, cmd)
                vim.async_call(print_log, error)
                vim.async_call(print_log, "gtags error!")
            else:
                print(cmd)
                print(error)
                print("gtags error!")
        else:
            if self._has_nvim:
                vim.async_call(print_log, "gtags generated successfully!")
            else:
                print("gtags generated successfully!")

        if self._has_nvim:
            vim.async_call(lfCmd,
                           "let g:Lf_Debug_GtagsCmd = '%s'" % escQuote(cmd))
        else:
            lfCmd("let g:Lf_Debug_GtagsCmd = '%s'" % escQuote(cmd))
コード例 #3
0
ファイル: github.py プロジェクト: hspin/vim-dev
 def _request_entries(lock, queue, entries_per_pages, url, headers, callback=None):
     try:
         while True:
             page, indicator = queue.popleft()
             entries = request_json(url, headers=headers, page=page)
             entries_per_pages.append([page, entries])
             if callback:
                 message = indicator % {"page": len(entries_per_pages)}
                 if hasattr(vim, "async_call"):
                     with lock:
                         vim.async_call(callback, message)
                 else:
                     with lock:
                         callback(message)
     except IndexError:
         pass
     except Exception as e:
         # clear queue to stop other threads
         queue.clear()
         entries_per_pages.append(e)
コード例 #4
0
ファイル: gtagsExpl.py プロジェクト: ljq199612/main
    def _update(self, filename, single_update, auto):
        if filename == "":
            return

        if self._gtagsconf == '' and os.name == 'nt':
            self._gtagsconf = os.path.normpath(
                os.path.join(self._which("gtags.exe"), "..", "share", "gtags",
                             "gtags.conf"))

        root, dbpath, exists = self._root_dbpath(filename)
        if not filename.startswith(root):
            if self._has_nvim:
                vim.async_call(
                    lfCmd, "let g:Lf_Debug_Gtags = '%s'" %
                    escQuote(str((filename, root))))
            else:
                lfCmd("let g:Lf_Debug_Gtags = '%s'" %
                      escQuote(str((filename, root))))

            return

        self._updateLibGtags(dbpath)
        if single_update:
            if exists:
                cmd = 'cd {}"{}" && gtags {}{}{}{}--gtagslabel {} --single-update "{}" "{}"'.format(
                    self._cd_option, root, self._accept_dotfiles,
                    self._skip_unreadable, self._skip_symlink,
                    '--gtagsconf %s ' %
                    self._gtagsconf if self._gtagsconf else "",
                    self._gtagslabel, filename, dbpath)
                env = os.environ
                env["GTAGSFORCECPP"] = ""
                subprocess.Popen(cmd, shell=True, env=env)
        elif not auto:
            self._executeCmd(root, dbpath)
        elif self._isVersionControl(filename):
            if not exists:
                self._executeCmd(root, dbpath)
コード例 #5
0
ファイル: gtagsExpl.py プロジェクト: Yggdroot/LeaderF
    def _executeCmd(self, root, dbpath):
        if not os.path.exists(dbpath):
            os.makedirs(dbpath)
        cmd = self._file_list_cmd(root)
        if cmd:
            if os.name == 'nt':
                cmd = 'cd {}"{}" && ( {} ) | gtags {}{}{}{}--gtagslabel {} -f- "{}"'.format(self._cd_option, root, cmd,
                            self._accept_dotfiles, self._skip_unreadable, self._skip_symlink,
                            '--gtagsconf "%s" ' % self._gtagsconf if self._gtagsconf else "",
                            self._gtagslabel, dbpath)
            else:
                cmd = 'cd {}"{}" && {{ {}; }} | gtags {}{}{}{}--gtagslabel {} -f- "{}"'.format(self._cd_option, root, cmd,
                            self._accept_dotfiles, self._skip_unreadable, self._skip_symlink,
                            '--gtagsconf "%s" ' % self._gtagsconf if self._gtagsconf else "",
                            self._gtagslabel, dbpath)
        else:
            cmd = 'cd {}"{}" && gtags {}{}{}{}--gtagslabel {} "{}"'.format(self._cd_option, root,
                        self._accept_dotfiles, self._skip_unreadable, self._skip_symlink,
                        '--gtagsconf "%s" ' % self._gtagsconf if self._gtagsconf else "",
                        self._gtagslabel, dbpath)

        env = os.environ
        env["GTAGSFORCECPP"] = ""
        proc = subprocess.Popen(cmd, shell=True, universal_newlines=True, stderr=subprocess.PIPE, env=env)
        _, error = proc.communicate()

        def print_log(args):
            print(args)

        if error:
            if self._has_nvim:
                vim.async_call(print_log, cmd)
                vim.async_call(print_log, error)
                vim.async_call(print_log, "gtags error!")
            else:
                print(cmd)
                print(error)
                print("gtags error!")
        else:
            if self._has_nvim:
                vim.async_call(print_log, "gtags generated successfully!")
            else:
                print("gtags generated successfully!")
コード例 #6
0
 def wrapper():
     vim.async_call(func)