1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-14 00:06:15 +01:00
github.com_openSUSE_osc/osc/obs_api/keyinfo_pubkey.py

52 lines
1.2 KiB
Python

from ..util.models import * # pylint: disable=wildcard-import,unused-wildcard-import
class KeyinfoPubkey(XmlModel):
XML_TAG = "pubkey"
keyid: str = Field(
xml_attribute=True,
)
userid: str = Field(
xml_attribute=True,
)
algo: str = Field(
xml_attribute=True,
)
keysize: str = Field(
xml_attribute=True,
)
expires: int = Field(
xml_attribute=True,
)
fingerprint: str = Field(
xml_attribute=True,
)
value: str = Field(
xml_set_text=True,
)
def get_expires_str(self) -> str:
import datetime
return datetime.datetime.fromtimestamp(self.expires).strftime("%Y-%m-%d %H:%M:%S")
def to_human_readable_string(self) -> str:
"""
Render the object as a human readable string.
"""
from ..output import KeyValueTable
table = KeyValueTable()
table.add("Type", "GPG public key")
table.add("User ID", self.userid, color="bold")
table.add("Algorithm", self.algo)
table.add("Key size", self.keysize)
table.add("Expires", self.get_expires_str())
table.add("Fingerprint", self.fingerprint)
return f"{table}\n{self.value}"