init project

This commit is contained in:
qiurui 2024-01-09 11:01:49 +08:00
parent 4ca0058e7c
commit b9b26a7a50
13 changed files with 216 additions and 0 deletions

0
README.rst Normal file
View File

1
VERSION Normal file
View File

@ -0,0 +1 @@
0.1.0

6
example-view.md Executable file
View File

@ -0,0 +1,6 @@
# kernel log summary
## upstream
| hash | time | editor | email | body | type | keywords | diff-files |
| :---- | :---- | :---- | :---- | :---- | :------ | :------ | :------ |
| 2af9b20dbb39 | Sat Oct 28 08:15:07 2023 -1000 | Linus Torvalds | torvalds@linux-foundation.org |Merge tag 'x86-urgent-2023-10-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip<br> Pull misc x86 fixes from Ingo Molnar<br> - Fix a possible CPU hotplug deadlock bug caused by the new TSC synchronization code<br> - Fix a legacy PIC discovery bug that results in device troubles on affected systems, such as non-working keybards, etc<br> - Add a new Intel CPU model number to <asm/intel-family.h><br> * tag 'x86-urgent-2023-10-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:<br> &emsp;x86/tsc: Defer marking TSC unstable to a worker<br> &emsp;x86/i8259: Skip probing when ACPI/MADT advertises PCAT compatibility<br> &emsp;x86/cpu: Add model number for Intel Arrow Lake mobile processor |fix<br> add model| X86 CPU | arch/x86/include/asm/i8259.h<br> arch/x86/include/asm/intel-family.h<br> arch/x86/kernel/acpi/boot.c<br> arch/x86/kernel/i8259.c<br> arch/x86/kernel/tsc_sync.c<br>
| 单元格 | 单元格 |

61
key-words.md Executable file
View File

@ -0,0 +1,61 @@
# Core (various)
# File systems
Btrfs
OverlayFS
XFS
ext4
Ceph
FUSE
GFS2
EROFS
KSMBD
NFS
TMPFS
# Memory management
# Block layer
# BPF
# Tracing, perf
# Virtualization
# Cryptography
# Security
# Networking
# Architectures
ARM
x86
DMA engines
LoongArch
RISC-V
PowerPC
PA-RISC
S390
# Drivers
Graphics
Storage
Drivers in the Staging area
Bluetooth
Networking
Audio
Tablets, touch screens, keyboards, mouses
TV tuners, webcams, video capturers
Serial Peripheral Interface (SPI)
Serial
Voltage, current regulators, power capping, power supply
Watchdog
Real Time Clock (RTC)
FRU Support Interface (FSI)
Clock
Multi Media Card (MMC)
Hardware monitoring (hwmon)
Inter-Integrated Circuit (I2C + I3C)
Industrial I/O (iio)
General Purpose I/O (gpio)
Cryptography hardware acceleration
Leds
PHY ("physical layer" framework)
PCI
Universal Serial Bus
IOMMU
Pin Controllers (pinctrl)
Power Management
Memory Technology Devices (MTD)
Various

17
main.py Normal file
View File

@ -0,0 +1,17 @@
from pygitlog.gitoperation import *
from pygitlog.mdoperation import *
from pygitlog.example_module import example_function
if __name__=="__main__":
example_function()
repopath = "/home/qiurui/Documents/kernel/euler/kernel"
version_new = "f04289acdae57aa4066adee541dadd70b062ac88"
version_old = "95982be1aa8140f22bbb90b0edf3e6644167f729"
source = "euler"
file_name = initmd(version_new,version_old,source)
print(file_name)
get_repo(repopath)
count = get_commits_commit_count(version_new,version_old)
hash_list = get_commit_hash(version_new,version_old)
for hash in hash_list:
add_commit_info(file_name,hash)

3
pygitlog/__init__.py Normal file
View File

@ -0,0 +1,3 @@
from .gitoperation import *
from .example_module import *
from .mdoperation import *

View File

@ -0,0 +1,2 @@
def example_function():
print("Hello World! I bet you didn't expect that.")

65
pygitlog/gitoperation.py Normal file
View File

@ -0,0 +1,65 @@
import os
import subprocess
#切换到工作目录
def get_repo(repopath):
os.chdir(repopath)
#切换tag
def checkout_tag(version):
os.system("git checkout"+" "+version)
#获取两个commit/version/tag之间的commit数量
def get_commits_commit_count(commit1,commit2):
cmd = "git log" + " " + commit1 + ".." + commit2 + " --oneline|wc -l"
return os.system(cmd)
#获取两个commit之间的hash列表
def get_commit_hash(commit1,commit2):
cmd = "git log" + " '" + commit1 + "'.." + commit2 + " --oneline --pretty=format:'%h'"
hash = []
multiline_str = os.popen(cmd)
for line in multiline_str.readlines():
hash.append(line.replace('\n',''))
return hash
#获取某个commit的time
def get_commit_time(hash):
cmd = "git log" + " " + hash + " -1 --pretty=format:'%ad'"
process = os.popen(cmd)
preprocessed = process.read()
process.close()
return preprocessed
#获取某个commit的author
def get_commit_author(hash):
cmd = "git log" + " " + hash + " -1 --pretty=format:'%an'"
process = os.popen(cmd)
preprocessed = process.read()
process.close()
return preprocessed
#获取某个commit的email
def get_commit_email(hash):
cmd = "git log" + " " + hash + " -1 --pretty=format:'%ae'"
process = os.popen(cmd)
preprocessed = process.read()
process.close()
return preprocessed
#获取某个commit的body
def get_commit_body(hash):
cmd = "git log" + " " + hash + " -1 --pretty=format:'%B'"
process = os.popen(cmd)
preprocessed = process.read()
process.close()
return preprocessed
#获取某个commit的修改文件
def get_commit_diff_files(hash_list,hash_commit):
num = list.index(hash_list)
cmd = "git diff" + " --name-only " + hash[1] + " " + hash[0]
process = os.popen(cmd)
preprocessed = process.read()
process.close()
return preprocessed

31
pygitlog/mdoperation.py Normal file
View File

@ -0,0 +1,31 @@
from pygitlog.gitoperation import *
def initmd(version1,version2,source):
filename = source + version1 + "_" + version2 + ".md"
with open(filename,mode="w") as file:
file.write("# kernel log summary\n")
file.write("## " + source + " from " + version1 + " to " + version2 + "\n")
file.write("| hash | time | editor | email | body | type | keywords | diff-files | \n")
file.write("| :---- | :---- | :---- | :---- | :--- | :---- | :------- | :--------- | \n")
os.chmod(filename,448)
return os.getcwd() + "/" + filename
def format(str):
return str.replace('\n','<br>')
#
#| 2af9b20dbb39 | Sat Oct 28 08:15:07 2023 -1000 | Linus Torvalds | torvalds@linux-foundation.org
#| Merge tag 'x86-urgent-2023-10-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip<br> Pull misc x86 fixes from Ingo Molnar<br> - Fix a possible CPU hotplug deadlock bug caused by the new TSC synchronization code<br> - Fix a legacy PIC discovery bug that results in device troubles on affected systems, such as non-working keybards, etc<br> - Add a new Intel CPU model number to <asm/intel-family.h><br> * tag 'x86-urgent-2023-10-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:<br> &emsp;x86/tsc: Defer marking TSC unstable to a worker<br> &emsp;x86/i8259: Skip probing when ACPI/MADT advertises PCAT compatibility<br> &emsp;x86/cpu: Add model number for Intel Arrow Lake mobile processor
#| fix<br> add model| X86 CPU | arch/x86/include/asm/i8259.h<br> arch/x86/include/asm/intel-family.h<br> arch/x86/kernel/acpi/boot.c<br> arch/x86/kernel/i8259.c<br> arch/x86/kernel/tsc_sync.c<br>
def add_commit_info(filename,hash):
with open(filename,mode="a+") as file:
file.write("| " + hash + " ")
file.write("| " + get_commit_time(hash) + " ")
file.write("| " + get_commit_author(hash) + " ")
file.write("| " + get_commit_email(hash) + " ")
file.write("| " + format(get_commit_body(hash)) + " ")
file.write("| fix<br>add model<br> ")
file.write("| fix<br>add model<br> ")
file.write("| " + format(get_commit_diff_files(hash)) + " |\n")
file.close()

3
pytest.ini Normal file
View File

@ -0,0 +1,3 @@
[pytest]
addopts = --capture=no -ra --verbose
testpaths = test/

0
requirements.txt Normal file
View File

23
setup.py Normal file
View File

@ -0,0 +1,23 @@
from setuptools import find_packages, setup
def read_requirements(file):
with open(file) as f:
return f.read().splitlines()
def read_file(file):
with open(file) as f:
return f.read()
long_description = read_file("README.rst")
version = read_file("VERSION")
requirements = read_requirements("requirements.txt")
setup(
name='pygitlog',
packages=find_packages(include=['pygitlog']),
version=version,
description='Python library for git log summary',
long_description_content_type = "text/x-rst", # If this causes a warning, upgrade your setuptools package
long_description = long_description,
author='Me',
)

4
test.sh Executable file
View File

@ -0,0 +1,4 @@
#/bin/bash
python setup.py bdist_egg
python setup.py install --user
python main.py