国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

python 統(tǒng)計所有的 倉庫 提交者的提交次數(shù)

這篇具有很好參考價值的文章主要介紹了python 統(tǒng)計所有的 倉庫 提交者的提交次數(shù)。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報違法"按鈕提交疑問。

字典去重 YYDS

python 統(tǒng)計所有的 倉庫 提交者的提交次數(shù),Linux,linux

然后再寫入excel 表 yyds

#!/bin/env python3
from git.repo import Repo
import os
import pandas as pds

path = "/home/labstation/workqueue/sw"
url = "git@10.0.128.128"
date = [str(x) for x in range(202307, 202308)]
datefmt = "%Y%m"
counts = 0
AUTHORS = {}
AUTHORS_UNIQU = {}
DATE = {}
DATE_UNIQU = {}

for proj in os.scandir(path):
    if not os.access(path + "/" + proj.name + "/.git", os.F_OK):
        continue
    repo = Repo(path + "/" + proj.name)
    remoteUrl = repo.git.execute(["git", "remote", "-v"])
    if type(remoteUrl) is str:
        remoteUrl = map(lambda x: x.strip("\t"), remoteUrl.split("\n"))
        for checkUrl in remoteUrl:
            if checkUrl.find(url) > 0:
                continue
    res = repo.git.execute(["git", "branch", "-r"])
    if type(res) is str and len(res) != 0:
        branches = filter(
            lambda x: not x.startswith("origin/HEAD"),
            map(lambda x: x.strip(" "), res.split("\n")),
        )
        for it_branch in branches:
            for it in repo.iter_commits(it_branch):
                if it.authored_datetime.strftime(datefmt) in date:
                    AUTHORS[str(it)] = it.author.name
                    DATE[str(it)] = (
                        it_branch,
                        proj.name,
                        it.author.name,
                        it.authored_datetime.strftime(datefmt),
                    )

for _it in AUTHORS:
    AUTHORS_UNIQU[AUTHORS[_it]] = 0

for _it in AUTHORS_UNIQU:
    for _its in AUTHORS:
        if _it == AUTHORS[_its]:
            AUTHORS_UNIQU[_it] += 1

for _it in DATE:
    DATE_UNIQU[DATE[_it]] = 0

for _it in DATE_UNIQU:
    for _its in DATE:
        if _it == DATE[_its]:
            DATE_UNIQU[_it] += 1

TotalExcel = {"姓名": [], "次數(shù)": []}

for _it in AUTHORS_UNIQU:
    TotalExcel["姓名"].append(_it)
    TotalExcel["次數(shù)"].append(AUTHORS_UNIQU[_it])

Excel = {"分支": [], "倉庫名稱": [], "提交者": [], "提交日期": [], "提交次數(shù)": []}
for it in DATE_UNIQU:
    Excel["分支"].append(it[0])
    Excel["倉庫名稱"].append(it[1])
    Excel["提交者"].append(it[2])
    Excel["提交日期"].append(it[3])
    Excel["提交次數(shù)"].append(DATE_UNIQU[it])

writer = pds.ExcelWriter(date[0] + "~" + date[len(date) - 1] + ".xlsx")
excekWrute2 = pds.DataFrame(TotalExcel)
excekWrute2.to_excel(writer, sheet_name="統(tǒng)計總表")
execlWrite1 = pds.DataFrame(Excel)
execlWrite1.to_excel(writer, sheet_name="各倉庫統(tǒng)計")
writer.close()

保存成excel 表格輸出

YYDS … …

添加一個繪圖功能

#!/bin/env python3
from git.repo import Repo
import os
import pandas as pds
import matplotlib.pyplot as plt

path = "/home/code/workqueue"
url = "git@10.0.128.128"
date = [str(x) for x in range(20230701, 20230732)]
datefmt = "%Y%m%d"
counts = 0
AUTHORS = {}
AUTHORS_UNIQU = {}
DATE = {}
DATE_UNIQU = {}

for proj in os.scandir(path):
    if not os.access(path + "/" + proj.name + "/.git", os.F_OK):
        continue
    repo = Repo(path + "/" + proj.name)
    remoteUrl = repo.git.execute(["git", "remote", "-v"])
    if type(remoteUrl) is str:
        remoteUrl = map(lambda x: x.strip("\t"), remoteUrl.split("\n"))
        for checkUrl in remoteUrl:
            if checkUrl.find(url) > 0:
                continue
    res = repo.git.execute(["git", "branch", "-r"])
    if type(res) is str and len(res) != 0:
        branches = filter(
            lambda x: not x.startswith("origin/HEAD"),
            map(lambda x: x.strip(" "), res.split("\n")),
        )
        for it_branch in branches:
            for it in repo.iter_commits(it_branch):
                if it.authored_datetime.strftime(datefmt) in date:
                    AUTHORS[str(it)] = it.author.email
                    DATE[str(it)] = (
                        it_branch,
                        proj.name,
                        it.author.email,
                        it.authored_datetime.strftime(datefmt),
                    )

for _it in AUTHORS:
    AUTHORS_UNIQU[AUTHORS[_it]] = 0

for _it in AUTHORS_UNIQU:
    for _its in AUTHORS:
        if _it == AUTHORS[_its]:
            AUTHORS_UNIQU[_it] += 1

for _it in DATE:
    DATE_UNIQU[DATE[_it]] = 0

for _it in DATE_UNIQU:
    for _its in DATE:
        if _it == DATE[_its]:
            DATE_UNIQU[_it] += 1

TotalExcel = {"姓名": [], "次數(shù)": []}

for _it in AUTHORS_UNIQU:
    TotalExcel["姓名"].append(_it)
    TotalExcel["次數(shù)"].append(AUTHORS_UNIQU[_it])

Excel = {"倉庫名稱": [], "分支": [], "提交者": [], "提交日期": [], "提交次數(shù)": []}
for it in DATE_UNIQU:
    Excel["倉庫名稱"].append(it[1])
    Excel["分支"].append(it[0])
    Excel["提交者"].append(it[2])
    Excel["提交日期"].append(it[3])
    Excel["提交次數(shù)"].append(DATE_UNIQU[it])

repoSheet: dict = {}
for it in DATE_UNIQU:
    repoSheet[it[1]] = {"提交者": [], "分支": [], "提交次數(shù)": [], "提交日期": []}

for it in DATE_UNIQU:
    repoSheet[it[1]]["提交者"].append(it[2])
    repoSheet[it[1]]["分支"].append(it[0])
    repoSheet[it[1]]["提交次數(shù)"].append(DATE_UNIQU[it])
    repoSheet[it[1]]["提交日期"].append(it[3])

if os.path.exists(date[0] + "~" + date[len(date) - 1] + ".xlsx"):
    os.remove(date[0] + "~" + date[len(date) - 1] + ".xlsx")

writer = pds.ExcelWriter(date[0] + "~" + date[len(date) - 1] + ".xlsx")
excekWrute2 = pds.DataFrame(TotalExcel)
excekWrute2.to_excel(writer, sheet_name="統(tǒng)計總表")
execlWrite1 = pds.DataFrame(Excel)
execlWrite1.to_excel(writer, sheet_name="各倉庫統(tǒng)計原始記錄")
for it in repoSheet:
    t = pds.DataFrame(repoSheet[it])
    t.to_excel(writer, sheet_name=it)
writer.close()

Total = 0
ax = []
for it in pds.unique(Excel["倉庫名稱"]):
    Total += 1

_cnts = 0
fig = plt.figure()
for it in pds.unique(Excel["倉庫名稱"]):
    ax.append(fig.add_subplot(int(Total / 4) + 1, 4, _cnts + 1))
    ax[_cnts].set_title(it)
    # FIXME have some bug
    commitTimes = {}
    for _it in repoSheet[it]["提交者"]:
        commitTimes[_it] = 0

    for i in range(0, len(repoSheet[it]["提交者"])):
        commitTimes[repoSheet[it]["提交者"][i]] += repoSheet[it]["提交次數(shù)"][i]
    ax[_cnts].bar(
        list(x for x in commitTimes), list(commitTimes[x] for x in commitTimes)
    )
    _cnts += 1
plt.show()

很有趣的小工具 heartrate

python 統(tǒng)計所有的 倉庫 提交者的提交次數(shù),Linux,linux

實用的小腳本

#!/bin/env python3
from git.repo import Repo
import os
import pandas as pds
import matplotlib.pyplot as plt
from rich.console import Console
from rich.table import Table
import time

path = "/home/code/workqueue"
url = "git@10.0.128.128"
date = [str(x) for x in range(20230101, 20230832)]
datefmt = "%Y%m%d"
counts = 0

AUTHORS = {}
AUTHORS_UNIQU = {}
DATE = {}
DATE_UNIQU = {}
SHOW_PLOT = False
SHOW_TABLE = True
SAVE_XLSX = False
AUTHOR_ONE = ["hong_da_yu@163.com"]

for proj in os.scandir(path):
    if not os.access(path + "/" + proj.name + "/.git", os.F_OK):
        continue
    repo = Repo(path + "/" + proj.name)
    remoteUrl = repo.git.execute(["git", "remote", "-v"])
    if type(remoteUrl) is str:
        remoteUrl = map(lambda x: x.strip("\t"), remoteUrl.split("\n"))
        for checkUrl in remoteUrl:
            if checkUrl.find(url) > 0:
                continue
    res = repo.git.execute(["git", "branch", "-r"])
    if type(res) is str and len(res) != 0:
        branches = filter(
            lambda x: not x.startswith("origin/HEAD"),
            map(lambda x: x.strip(" "), res.split("\n")),
        )
        for it_branch in branches:
            for it in repo.iter_commits(it_branch):
                if it.authored_datetime.strftime(datefmt) in date:
                    AUTHORS[str(it)] = it.author.email
                    DATE[str(it)] = (
                        it_branch,
                        proj.name,
                        it.author.email,
                        it.authored_datetime.strftime(datefmt),
                    )

for _it in AUTHORS:
    AUTHORS_UNIQU[AUTHORS[_it]] = 0

for _it in AUTHORS_UNIQU:
    for _its in AUTHORS:
        if _it == AUTHORS[_its]:
            AUTHORS_UNIQU[_it] += 1

for _it in DATE:
    DATE_UNIQU[DATE[_it]] = 0

for _it in DATE_UNIQU:
    for _its in DATE:
        if _it == DATE[_its]:
            DATE_UNIQU[_it] += 1

TotalExcel = {"姓名": [], "次數(shù)": []}

for _it in AUTHORS_UNIQU:
    TotalExcel["姓名"].append(_it)
    TotalExcel["次數(shù)"].append(AUTHORS_UNIQU[_it])

Excel = {"倉庫名稱": [], "分支": [], "提交者": [], "提交日期": [], "提交次數(shù)": []}
for it in DATE_UNIQU:
    Excel["倉庫名稱"].append(it[1])
    Excel["分支"].append(it[0])
    Excel["提交者"].append(it[2])
    Excel["提交日期"].append(it[3])
    Excel["提交次數(shù)"].append(DATE_UNIQU[it])

repoSheet: dict = {}
for it in DATE_UNIQU:
    repoSheet[it[1]] = {"提交者": [], "分支": [], "提交次數(shù)": [], "提交日期": []}

for it in DATE_UNIQU:
    repoSheet[it[1]]["提交者"].append(it[2])
    repoSheet[it[1]]["分支"].append(it[0])
    repoSheet[it[1]]["提交次數(shù)"].append(DATE_UNIQU[it])
    repoSheet[it[1]]["提交日期"].append(it[3])

if SAVE_XLSX:
    if os.path.exists(date[0] + "~" + date[len(date) - 1] + ".xlsx"):
        os.remove(date[0] + "~" + date[len(date) - 1] + ".xlsx")

    writer = pds.ExcelWriter(date[0] + "~" + date[len(date) - 1] + ".xlsx")
    excekWrute2 = pds.DataFrame(TotalExcel)
    excekWrute2.to_excel(writer, sheet_name="統(tǒng)計總表")
    execlWrite1 = pds.DataFrame(Excel)
    execlWrite1.to_excel(writer, sheet_name="各倉庫統(tǒng)計原始記錄")
    for it in repoSheet:
        t = pds.DataFrame(repoSheet[it])
        t.to_excel(writer, sheet_name=it)
    writer.close()

# NOTE: FIX BUG OKAY
if SHOW_PLOT:
    Total = 0
    ax = []
    for it in pds.unique(Excel["倉庫名稱"]):
        Total += 1
    _cnts = 0
    fig = plt.figure()
    for it in pds.unique(Excel["倉庫名稱"]):
        ax.append(fig.add_subplot(int(Total / 4) + 1, 4, _cnts + 1))
        ax[_cnts].set_title(it)
        commitTimes = {}
        for _it in repoSheet[it]["提交者"]:
            commitTimes[_it] = 0

        for i in range(0, len(repoSheet[it]["提交者"])):
            commitTimes[repoSheet[it]["提交者"][i]] += repoSheet[it]["提交次數(shù)"][i]
        ax[_cnts].bar(
            list(x for x in commitTimes), list(commitTimes[x] for x in commitTimes)
        )
        _cnts += 1
    plt.show()

if SHOW_TABLE:
    table = Table(title=time.strftime("%Y-%m-%d", time.localtime()))
    for it in Excel:
        table.add_column(it, style="cyan", no_wrap=True)

    for it in range(0, len(Excel["倉庫名稱"])):
        if Excel["提交者"][it] in AUTHOR_ONE:
            table.add_row(
                Excel["倉庫名稱"][it],
                Excel["分支"][it],
                Excel["提交者"][it],
                Excel["提交日期"][it],
                str(Excel["提交次數(shù)"][it]),
            )
    console = Console()
    console.print(table, justify="center")

終端打印 表格 ??

python 統(tǒng)計所有的 倉庫 提交者的提交次數(shù),Linux,linux文章來源地址http://www.zghlxwxcb.cn/news/detail-622304.html

到了這里,關(guān)于python 統(tǒng)計所有的 倉庫 提交者的提交次數(shù)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點(diǎn)擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 對于 Git 每一次提交的時間信息,什么是作者日期和提交者日期

    對于 Git 每一次提交的時間信息,什么是作者日期和提交者日期

    對于 Git 的每一次提交,在 TortoiseGit 和 IntelliJ IDEA 都可以看到這次提交的時間。但很多人不知道的是,Git 實際上對每一個提交的時間分為兩個:作者日期和提交者日期。 作者日期(author date):這指的是最開始提交時,所產(chǎn)生的提交文件上的日期 提交者日期(committer date):

    2024年02月05日
    瀏覽(19)
  • Visual Studio 2019代碼上不顯示git提交者

    Visual Studio 2019代碼上不顯示git提交者

    我們一般使用vscode編寫前端代碼,使用vs編寫后端代碼 如下圖,我發(fā)現(xiàn)vscode的每行代碼后邊都有g(shù)it的提交者記錄,覺得這個功能甚好,所以查了一下vs能不能也有這個功能,結(jié)論:社區(qū)版沒有,企業(yè)版和專業(yè)版有 這個功能在哪里呢? Visual Studio頁面: 工具–選項–文本編輯器

    2024年02月15日
    瀏覽(41)
  • 如何設(shè)置 Eclipse Git 插件中的默認(rèn)作者和提交者
  • Python統(tǒng)計一個字符串中所有字符在另一個字符串出現(xiàn)的總次數(shù)

    Python統(tǒng)計一個字符串中所有字符在另一個字符串出現(xiàn)的總次數(shù)

    代碼功能:統(tǒng)計一個字符串中所有字符在另一個字符串中出現(xiàn)的總次數(shù)。 技術(shù)要點(diǎn):函數(shù)式編程。 可能的應(yīng)用:垃圾郵件分類。在大部分垃圾郵件中,為了防止被分類為垃圾郵件,會在一些中間插入類似于【、】、*之類的字符來干擾分詞。可以把這個特點(diǎn)作為一個判

    2024年02月02日
    瀏覽(22)
  • 統(tǒng)計Git項目各成員貢獻(xiàn)量(代碼行數(shù)、提交次數(shù))

    統(tǒng)計Git項目各成員貢獻(xiàn)量(代碼行數(shù)、提交次數(shù))

    在項目的文件夾中,右鍵,選擇Git Bash Here 會彈出命令行框 使用下面的代碼去統(tǒng)計

    2024年02月11日
    瀏覽(22)
  • Gitlab 實現(xiàn)倉庫完全遷移,包括所有提交記錄、分支、標(biāo)簽

    Gitlab 實現(xiàn)倉庫完全遷移,包括所有提交記錄、分支、標(biāo)簽

    如果你和我一樣,不喜歡命令行,就看其他方案。 選中要導(dǎo)出的項目,選擇設(shè)置-expand-export project 刷新一下,直接下載 新建項目并導(dǎo)入 如果你是打雜的,沒管理員權(quán)限,這步也不行。 在 gitlab 倉庫頁面,點(diǎn)擊下載,注意使用 gz 格式?。?! 去往你的新主體的 gitlab頁面開始倉

    2024年03月28日
    瀏覽(20)
  • 【筆記】Git|將git倉庫中所有的 commit 合成一個,清空所有 git 提交記錄

    【筆記】Git|將git倉庫中所有的 commit 合成一個,清空所有 git 提交記錄

    在對代碼進(jìn)行開源時,我們往往并不希望代碼開發(fā)過程中的提交記錄被其他人看到,因為提交的過程中往往會涵蓋一些敏感信息。因此會存在 將倉庫中所有 commit 合成一個 的需求。 直覺上,往往會用 rebase 和 squash 或 reset,不過我嘗試了一下存在問題,會出現(xiàn)最后仍然剩兩個

    2024年02月11日
    瀏覽(20)
  • python統(tǒng)計每個單詞出現(xiàn)的次數(shù)

    編程要求 請按照函數(shù)的注釋,補(bǔ)充程序中缺失部分語句,按要求實現(xiàn)如下程序功能:???????????????????????????????????????????????????????????????? word_frequency() 函數(shù)統(tǒng)計并以字典類型返回每個

    2024年02月11日
    瀏覽(31)
  • linux命令統(tǒng)計文件中某個字符串出現(xiàn)的次數(shù)

    可以使用grep命令統(tǒng)計文件中某個字符串出現(xiàn)的次數(shù)。語法: - grep -o:查找文件中匹配的字符串,并只輸出字符串本身 - \\\'字符串\\\':需要統(tǒng)計的字符串,用單引號括起來 - 文件名:需要查找的文件的路徑和文件名 - wc -l:統(tǒng)計行數(shù),這里統(tǒng)計grep輸出的行數(shù),即字符串出現(xiàn)的次數(shù)例如,要統(tǒng)計

    2024年02月08日
    瀏覽(31)
  • chatgpt賦能python:Python怎么統(tǒng)計字符出現(xiàn)次數(shù)

    在Python編程中,統(tǒng)計字符出現(xiàn)次數(shù)是一項常見的任務(wù)。通過統(tǒng)計字符出現(xiàn)次數(shù),我們可以更好地了解文本數(shù)據(jù),并從中獲取有用信息。Python提供了多種統(tǒng)計字符出現(xiàn)次數(shù)的方法和工具,本文將介紹常用的幾種方法,并分析其優(yōu)缺點(diǎn)。 Counter函數(shù)是Python內(nèi)置的統(tǒng)計器函數(shù),可以

    2024年02月13日
    瀏覽(31)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包