21 lines
679 B
Python
21 lines
679 B
Python
import json
|
|
from structs import CertInfo
|
|
from pathlib import Path
|
|
from dataclasses import asdict
|
|
|
|
class ServiceFunctions:
|
|
|
|
def save_cert_info(self, cert_info: CertInfo, path_to_save_folder: Path):
|
|
data = asdict(cert_info)
|
|
|
|
save_dir = path_to_save_folder / cert_info.dir_cert.name
|
|
save_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
data["expires_at"] = cert_info.expires_at.isoformat()
|
|
data["path_to_key"] = str(cert_info.path_to_key)
|
|
data["dir_cert"] = str(cert_info.dir_cert)
|
|
|
|
(save_dir / cert_info.dir_cert.name).write_text(
|
|
json.dumps(data, indent=4, ensure_ascii=False),
|
|
encoding="utf-8"
|
|
) |