日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python调用git生成log文件_python解析git log后生成页面显示git更新日志信息

發(fā)布時間:2025/4/16 python 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python调用git生成log文件_python解析git log后生成页面显示git更新日志信息 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

使用git log可以查到git上項目的更新日志。

如下兩個git項目,我想把git的日志信息解析成一個便于在瀏覽器上查看的頁面。

https://github.com/gityf/lua

https://github.com/gityf/db

使用git log命令獲取git更新日志信息:

D:\git\github\lua>git log > ..\lua.gitlog

D:\git\github\db>git log > ..\dbutils.gitlog

生成兩個git更新日志文件lua.gitlog和dbutils.gitlog。

文件內(nèi)容格式是這樣的:

commit a5ff94375f48c7de067a1c191cb60d720bf4f726

Author: Mr.YF

Date: Tue Jan 12 19:43:33 2016 +0800

add thrift binary analysis code and doc.

commit 9dc9437070867e8d8ba7c9d4365efe3f2c317caf

Author: Mr.YF

Date: Mon Jan 11 19:51:48 2016 +0800

add comments.

git log命令會輸出關(guān)鍵字"commit","Merge","Author","Date"

使用下面腳本分析git日志,生成html的頁面,便于查看。

'''

Created on 2016-1-25

@author: Mr.YF

'''

import os

import sys

def header():

headerHtml = '''//W3C//DTD HTML 4.01 Transitional//EN "http://www.w3.org/TR/html4/loose.dtd">

Statistics Report for gitcheck.

body {

font-family: arial, helvetica, sans-serif;

font-size: 12px;

font-weight: normal;

color: black;

background: white;

}

th,td {

font-size: 10px;

}

h1 {

font-size: x-large;

margin-bottom: 0.5em;

}

h2 {

font-family: helvetica, arial;

font-size: x-large;

font-weight: bold;

font-style: italic;

color: #6020a0;

margin-top: 0em;

margin-bottom: 0em;

}

h3 {

font-family: helvetica, arial;

font-size: 16px;

font-weight: bold;

color: #b00040;

background: #e8e8d0;

margin-top: 0em;

margin-bottom: 0em;

}

li {

margin-top: 0.25em;

margin-right: 2em;

}

.hr {margin-top: 0.25em;

border-color: black;

border-bottom-style: solid;

}

.in {color: #6020a0; font-weight: bold; text-align: left;}

.frontend {background: #e8e8d0;}

.s {background: #e0e0e0;}

.a0 {background: #FF99CC; font-weight: bold;}

.a1 {background: #CCFF99;}

.a2 {background: #CCFFFF;}

.a3 {background: #CCCCFF;}

.a4 {background: #66CCCC;}

.a5 {background: #CCFF66;}

.a6 {background: #FFCC99;}

.maintain {background: #c07820;}

.rls {letter-spacing: 0.2em; margin-right: 1px;}

a.px:link {color: #ffff40; text-decoration: none;}

a.px:visited {color: #ffff40; text-decoration: none;}

a.px:hover {color: #ffffff; text-decoration: none;}

a.lfsb:link {color: #000000; text-decoration: none;}

a.lfsb:visited {color: #000000; text-decoration: none;}

a.lfsb:hover {color: #505050; text-decoration: none;}

table.tbl { border-collapse: collapse; border-style: none;}

table.tbl td { text-align: right; border-width: 1px 1px 1px 1px; border-style: solid solid solid solid; padding: 2px 3px; border-color: gray; white-space: nowrap;}

table.tbl td.ac { text-align: center;}

table.tbl th { border-width: 1px; border-style: solid solid solid solid; border-color: gray;}

table.tbl th.pxname { background: #b00040; color: #ffff40; font-weight: bold; border-style: solid solid none solid; padding: 2px 3px; white-space: nowrap;}

table.tbl th.empty { border-style: none; empty-cells: hide; background: white;}

table.tbl th.desc { background: white; border-style: solid solid none solid; text-align: left; padding: 2px 3px;}

table.lgd { border-collapse: collapse; border-width: 1px; border-style: none none none solid; border-color: black;}

table.lgd td { border-width: 1px; border-style: solid solid solid solid; border-color: gray; padding: 2px;}

table.lgd td.noborder { border-style: none; padding: 2px; white-space: nowrap;}

u {text-decoration:none; border-bottom: 1px dotted black;}

-->

GitCheck Center


> General git information

return headerHtml

def footer():

footHtml = '''

'''

return footHtml

def row():

rowHtml = '''

%s%s%s%s%s'''

return rowHtml

def indexMainRow():

rowHtml = '''

IDbranch git log info.'''

return rowHtml

def indexRow():

rowHtml = '''

%d%s'''

return rowHtml

def tdClassId(pageId):

pageId += 1

if pageId >= 7:

pageId = 1

return pageId

def gitcheck(inFileName="gitcheck.in", outFileName="gitcheck.out.html"):

fn = open(inFileName, "r")

fnOut = open(outFileName, "w")

fnOut.write(header())

fnOut.write(row() % (0, "commit","Merge","Author","Date", "Comment"))

lines = fn.readlines()

beginTag = False

pageId = 1

goodLine = {0:"",1:"",2:"",3:"",4:""}

for line in lines:

if len(line) <= 2:

continue

if line.startswith("commit"):

beginTag = True

goodLine[0] = line[6:]

pageId = tdClassId(pageId)

continue

if beginTag:

if line.startswith("Merge: "):

goodLine[1] = line[7:]

elif line.startswith("Author: "):

goodLine[2] = line[8:]

elif line.startswith("Date: "):

goodLine[3] = line[6:]

else :

goodLine[4] = line

beginTag = False

fnOut.write(row() % (pageId,goodLine[0],goodLine[1],goodLine[2],goodLine[3],goodLine[4]))

goodLine = {0:"",1:"",2:"",3:"",4:""}

fn.close()

fnOut.write(footer())

fnOut.flush()

fnOut.close()

def lsHtmls(dirName="gitinfo"):

htmlFiles = []

allFile = os.listdir(dirName)

for f in allFile:

if f.endswith(".html"):

htmlFiles.append(f)

print f

return htmlFiles

def createIndex(dirName):

files = lsHtmls(dirName)

if len(files) > 0:

fnOut = open("index.html", "w")

fnOut.write(header())

fnOut.write(indexMainRow())

pageId = 1

ii = 1

for f in files:

fnOut.write(indexRow() % (ii, pageId, f, f))

ii = tdClassId(ii)

pageId += 1

fnOut.write(footer());

fnOut.close()

if __name__ == '__main__':

if len(sys.argv) >= 3:

gitcheck(sys.argv[1], sys.argv[2])

elif len(sys.argv) >= 2:

createIndex(sys.argv[1])

把python代碼保存為gitcheck.py

使用如下命令解析日志文件lua.gitlog和dbutils.gitlog。

F:\pyworkspace\gitcheck>python gitcheck.py dbutils.gitlog gitinfo\dbutils.html

F:\pyworkspace\gitcheck>python gitcheck.py lua.gitlog gitinfo\lua_thrift_demo.html

F:\pyworkspace\gitcheck>python gitcheck.py gitinfo

dbutils.html

lua_thrift_demo.html

python gitcheck.py gitinfo會把目錄gitinfo下所有的html文件匯總生成一個index.html主頁。

效果如下:

主頁

跳轉(zhuǎn)到某個項目查看git日志信息

Done.

總結(jié)

以上是生活随笔為你收集整理的python调用git生成log文件_python解析git log后生成页面显示git更新日志信息的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美网站在线观看 | 国产又粗又猛又黄又爽 | 99福利网| 69精品无码成人久久久久久 | 少妇高潮一区二区三区喷水 | 免费在线看黄视频 | 欧美男人又粗又长又大 | avtt2015| 午夜神马福利 | a级大片在线观看 | 国产在线啪 | 久久久免费精品 | 男生插女生视频在线观看 | www.x日本 | 91网页在线观看 | 日本少妇久久 | 欧美一级夜夜爽 | 污视频网站免费 | 久久国产精品免费观看 | 欧美性受xxx | 国产一区二区在线精品 | 男人的亚洲天堂 | 亚洲视频网站在线 | 巨胸喷奶水www久久久免费动漫 | 和黑帮大佬的365 | 伊人天堂在线 | 黄网站在线观看视频 | 中国极品少妇xxxx做受 | 亚洲偷自 | 日本三级小视频 | 欧美婷婷六月丁香综合色 | 激情自拍视频 | 日韩精品一区二区视频 | 天天综合一区 | 日日日干 | 午夜黄色影院 | 蜜芽一区二区 | 在线免费观看日本 | 特级性生活片 | 欧美人妖另类 | 三年大片在线观看 | 欧美在线v | 亚洲爆爽| 国产一区二区三区高清 | 精品女厕偷拍一区二区 | 操韩国美女 | 鲁大师私人影院在线观看 | 456亚洲影视 | 中文字幕无码毛片免费看 | 国产无遮挡裸体免费视频 | 一级视频在线免费观看 | 午夜视频污| 老牛影视av一区二区在线观看 | 国产一级淫片免费 | 成人综合在线观看 | 亚洲色图国产视频 | 亚洲综合在线观看视频 | 91精品人妻一区二区 | 国语对白精彩对话 | 大香伊人久久 | 成人中文字幕在线 | 国产视频在线看 | 超碰精品在线观看 | 新婚夫妇白天啪啪自拍 | 一区二区国产欧美 | 深夜福利1000 | 欧美日韩在线影院 | 日韩欧美中文字幕一区二区 | 天天摸天天舔天天操 | 欧美 日韩 国产 在线观看 | 欧美激情欧美激情在线五月 | 精品国产乱码久久久久久鸭王1 | 日韩高清专区 | 欧洲一级视频 | 在线播放一区二区三区 | 手机av资源 | 日韩欧av| 免费av小说 | 中国白嫩丰满人妻videos | 色情毛片 | 欧美黑人粗大 | 狠狠爱欧美 | 久久精品国产电影 | 女性生殖扒开酷刑vk | 911亚洲精品 | 精品久久九九 | 久久久久亚洲精品中文字幕 | 亚洲免费激情视频 | 国产综合久久 | 欧美性做爰猛烈叫床潮 | 中文字幕免费观看视频 | 日韩av在线网 | 国产精品第13页 | 欧美性xxxxxxxxx | 波多野结衣理论片 | 日本免费无人高清 | 亚洲欧美日韩久久精品 | 欧美脚交 | 制服丝袜国产在线 |