Coverage for pki_tools/types/__init__.py: 100%
20 statements
« prev ^ index » next coverage.py v7.14.3, created at 2026-11-02 22:00 +0000
« prev ^ index » next coverage.py v7.14.3, created at 2026-11-02 22:00 +0000
1import yaml
3from .certificate import Certificate, Validity
4from .certificates import Certificates
5from .chain import Chain
6from .crl import CertificateRevocationList
7from .csr import CertificateSigningRequest
8from .enums import RevokeMode
9from .extensions import Extensions
10from .key_pair import (
11 CryptoKeyPair,
12 CryptoPrivateKey,
13 CryptoPublicKey,
14 DSAKeyPair,
15 DSAPrivateKey,
16 DSAPublicKey,
17 Ed448KeyPair,
18 Ed448PrivateKey,
19 Ed448PublicKey,
20 Ed25519KeyPair,
21 Ed25519PrivateKey,
22 Ed25519PublicKey,
23 EllipticCurveKeyPair,
24 EllipticCurveName,
25 EllipticCurvePrivateKey,
26 EllipticCurvePublicKey,
27 RSAKeyPair,
28 RSAPrivateKey,
29 RSAPublicKey,
30)
31from .name import Name
32from .ocsp import (
33 OcspCertificateStatus,
34 OCSPRequest,
35 OCSPResponse,
36 OcspResponseStatus,
37)
38from .signature_algorithm import (
39 MD5,
40 SHA1,
41 SHA3_224,
42 SHA3_256,
43 SHA3_384,
44 SHA3_512,
45 SHA224,
46 SHA256,
47 SHA384,
48 SHA512,
49 SHA512_224,
50 SHA512_256,
51 SHAKE128,
52 SHAKE256,
53 SM3,
54 BLAKE2b,
55 BLAKE2s,
56 HashAlgorithm,
57 HashAlgorithmName,
58 SignatureAlgorithm,
59)
61MAX_YAML_LEN = 80
64def str_presenter(dumper, data):
65 if len(data) > MAX_YAML_LEN:
66 chunks = [
67 data[i : i + MAX_YAML_LEN]
68 for i in range(0, len(data), MAX_YAML_LEN)
69 ]
71 data = "\n".join(chunks)
72 return dumper.represent_scalar(
73 "tag:yaml.org,2002:str", data, style="|"
74 )
75 return dumper.represent_scalar("tag:yaml.org,2002:str", data)
78yaml.representer.SafeRepresenter.add_representer(str, str_presenter)