PyGithub克隆功能的Python进度栏

问题描述

如何查看克隆过程的进度? tqdm模块不适用于单行语句。我应该添加一个git参数吗?任何参考将有所帮助。谢谢。

import git

#clone to local system
git.Repo.clone_from(repo_url,path,branch='master')

解决方法

GitPython source code包括:

def clone_from(cls,url,to_path,progress=None,env=None,multi_options=None,**kwargs):

进度在git.remote.Remote.push

中定义
:param progress:
    Can take one of many value types:
        * None to discard progress information
        * A function (callable) that is called with the progress information.
          Signature: ``progress(op_code,cur_count,max_count=None,message='')``.
        * An instance of a class derived from ``git.RemoteProgress`` that
          overrides the ``update()`` function.

您可以看到progress function herehere的示例。