Git图形到networkx

git-networkx的Python项目详细描述


Git网络X

https://github.com/hoduche/git-graph到NetworkX


安装

PyPi

pip install git-networkx

Git

pip install git+https://github.com/CircArgs/git-networkx.git

演示

fromnetworkx.drawing.nx_pydotimportwrite_dotfromgit_networkximportGitNX,Commit#everythingAll=GitNX('my/repo/path/that/has/a/git/directory')#networkx Digraph representing all nodes of the git repo#Commits#notice the path does not have to be .git in case you have used a different nameCommits=GitNX('my/repo/path/located/in/.got',"c")#networkx Digraph representing only commits of the git repo#again, the results of GitNX is just a networkx.DiGraph and as such you can do anything you would on such an object[nforninAllifisinstance(n,Commit)]

假设您有如下日志:

^{pr2}$

那么

G=GitNX(".","lch")print(list(G.neighbors(Commit("80798c310455976e08fedd9b367794692ebb54a6"))))# [Commit('8c7f9cea1f6323d793cd035e2178636d6ebf0a36')]print(list(G.predecessors(Commit("80798c310455976e08fedd9b367794692ebb54a6"))))# [Commit('9a99a4d85cb14005ca829e2cab8f626b4034b981')]print(list(G.predecessors(Commit('9a99a4d85cb14005ca829e2cab8f626b4034b981'))))# [LocalBranch('dev'), LocalBranch('master')]

节点

此表显示了图形中可以包含哪些节点。Letter表示用于创建图形的过滤器,作为git_networkx.GitNX的第二个位置参数,即nodes参数。在

如上面的例子所示,来自GitNXDiGraph可以通过检查下面的节点类isinstance进行过滤,或者通过一个类的实例进行过滤。在

整体节点类:GitNode

Node kindLetterNode ClassNode kindLetterNode Class
blobbBlobremote branchrRemoteBranch
treetTreeremote headdRemoteHead
commitcCommitremote serversRemoteServer
local branchlLocalBranchannotated tagaAnnotatedTag
local headhLocalHeadtaggTag

默认情况下,所有节点都添加到有向图中。在

# you can get your commits, branches and the head of your local repo simply with lchG=GitNX('../git_networkx_test/',"lch")

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
尝试连接到Red5服务器时出现java问题   java实现Runnable的类被认为是ExecutorServices的“Runnable任务”?   java struts2类中的多个@validation   java未能应用插件[class'org.gradle.api.plugins.scala.ScalaBasePlugin']:gradle v2。13   如何使用Java流仅收集长度最大的元素?   从spring引导应用程序连接到firestore的java引发空指针异常   java从SQLite插入和获取真实数据类型会为连续插入获取空值吗?   当存在未知数量的空格时,使用java替代正向查找   部署如何为当今的浏览器部署java小程序(小程序、嵌入、对象)?   @OneToMany和@ManyToOne@Formula之间的java双向关系返回null   java为什么在我的例子中,协议缓冲区的性能比JSON差?   如何部署混合C++/Java(JNI)应用程序?   java如何在程序中显示字符串的完整信息。反恐精英?   java在Hibernate中从持久性上下文中分离实体中的实体