1 回答

TA貢獻1895條經驗 獲得超3個贊
假設您有一個文件存儲庫,其 UNC 路徑為\\jira.host.com\browse. 此目錄包含每個票證的文件夾。
要刪除票證文件夾,您可以編寫這樣的函數:
import pathlib
import shutil
# WORK_DIR is the UNC path to your file repository
WORK_DIR = pathlib.Path(r"\\jira.host.com\browse")
def remove_folder(ticket_id: str) -> None:
""" Remove the ticket folder located in the repository """
ticket_path = WORK_DIR.joinpath(f"PROJECT-{ticket_id}")
if ticket_path.exists():
print(f"removing '{ticket_path}'...")
shutil.rmtree(ticket_path, ignore_errors=True)
else:
print(f"'{ticket_path}' already removed.")
然后,您可以調用remove_folder給定工單 ID 的函數。
remove_folder("11111")
添加回答
舉報