From 4677eae575a02d714f8c0b00628354d551dcfdd1 Mon Sep 17 00:00:00 2001 From: imnyang Date: Sun, 8 Jun 2025 13:42:55 +0900 Subject: [PATCH] =?UTF-8?q?=EB=82=A0=EB=9D=BC=EA=B0=80=EB=8A=94=EB=8D=B0?= =?UTF-8?q?=20=EA=B3=A0=EC=B9=98=EA=B8=B4=20=EA=B7=80=EC=B0=AE=EC=95=84?= =?UTF-8?q?=EC=84=9C...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/report.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/report.py b/lib/report.py index e6198a7..ae803be 100644 --- a/lib/report.py +++ b/lib/report.py @@ -3,19 +3,28 @@ import os import csv from typing import List, Dict, Any +# get unix timestamp +import time +def get_timestamp() -> str: + """ + Get the current Unix timestamp as a string. + + :return: Current Unix timestamp. + """ + return str(int(time.time())) + # target, status, title, description, uri # file path는 'data/report.csv'로 고정 -def save_report(report_data: List[Dict[str, Any]], file_path: str = 'data/report.csv') -> None: - os.makedirs(os.path.dirname(file_path), exist_ok=True) - - +def save_report(report_data: List[Dict[str, Any]], file_path: str = f'data/report-{get_timestamp()}.csv') -> None: """ Save the report data to a CSV file. :param report_data: List of dictionaries containing report data. :param file_path: Path to the CSV file where the report will be saved. """ + os.makedirs(os.path.dirname(file_path), exist_ok=True) + fieldnames = ['target', 'status', 'title', 'description', 'uri'] with open(file_path, mode='w', newline='', encoding='utf-8') as csvfile: