feat ipo
This commit is contained in:
18
py-client/libs/lockfile.py
Normal file
18
py-client/libs/lockfile.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""简单的文件锁标记工具。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from os import PathLike
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def is_lock(file_path: str | PathLike[str]) -> bool:
|
||||
"""判断指定的锁文件是否存在。"""
|
||||
return Path(file_path).is_file()
|
||||
|
||||
|
||||
def write_lockfile(file_path: str | PathLike[str]) -> None:
|
||||
"""创建锁文件;父目录不存在时自动创建。"""
|
||||
path = Path(file_path)
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text("LOCK", encoding="utf-8")
|
||||
Reference in New Issue
Block a user