Skip to content

Commit

Permalink
add loguru (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Svtter authored Dec 2, 2024
1 parent 495ad74 commit 3527576
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 9 deletions.
32 changes: 30 additions & 2 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Default template for PDM package"
authors = [
{name = "svtter", email = "[email protected]"},
]
dependencies = []
dependencies = ["loguru>=0.7.2"]
requires-python = ">=3.9"
readme = "README.md"
license = {text = "MIT"}
Expand Down
2 changes: 1 addition & 1 deletion src/easybuilder/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.0"
__version__ = "0.2.1"
12 changes: 7 additions & 5 deletions src/easybuilder/checker.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import os

from loguru import logger


def check_clean(folder: str = "."):
# 检查git仓库是否有未提交的更改
os.chdir(folder)
result = os.popen("git status --porcelain").read()
if not os.path.exists(".git"):
print("错误: 当前目录不是git仓库")
logger.error("错误: 当前目录不是git仓库")
exit(1)
if result:
print("错误: git仓库不干净,请先提交所有更改")
print("未提交的更改:")
print(result)
logger.error("错误: git仓库不干净,请先提交所有更改")
logger.error("未提交的更改:")
logger.error(result)
exit(1)
print("git仓库状态检查通过")
logger.info("git仓库状态检查通过")
6 changes: 6 additions & 0 deletions src/easybuilder/worker.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import loguru

from . import task


Expand All @@ -9,6 +11,10 @@ class Worker(object):
def __init__(self):
pass

def get_logger(self):
"""using loguru for logger"""
return loguru.logger

def before_run(self):
for t in self.default_tasks:
t().action()
Expand Down

0 comments on commit 3527576

Please sign in to comment.