mirror of
https://github.com/j93es/oauth-backend.git
synced 2026-06-04 08:21:52 +09:00
Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
| 4677eae575 |
1 changed files with 13 additions and 4 deletions
|
|
@ -3,19 +3,28 @@ import os
|
||||||
import csv
|
import csv
|
||||||
from typing import List, Dict, Any
|
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
|
# target, status, title, description, uri
|
||||||
|
|
||||||
# file path는 'data/report.csv'로 고정
|
# file path는 'data/report.csv'로 고정
|
||||||
def save_report(report_data: List[Dict[str, Any]], file_path: str = 'data/report.csv') -> None:
|
def save_report(report_data: List[Dict[str, Any]], file_path: str = f'data/report-{get_timestamp()}.csv') -> None:
|
||||||
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Save the report data to a CSV file.
|
Save the report data to a CSV file.
|
||||||
|
|
||||||
:param report_data: List of dictionaries containing report data.
|
:param report_data: List of dictionaries containing report data.
|
||||||
:param file_path: Path to the CSV file where the report will be saved.
|
: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']
|
fieldnames = ['target', 'status', 'title', 'description', 'uri']
|
||||||
|
|
||||||
with open(file_path, mode='w', newline='', encoding='utf-8') as csvfile:
|
with open(file_path, mode='w', newline='', encoding='utf-8') as csvfile:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue