MCPcopy
hub / github.com/pyca/cryptography / get_extension_for_class

Method get_extension_for_class

src/cryptography/x509/extensions.py:125–141  ·  view source on GitHub ↗
(
        self, extclass: type[ExtensionTypeVar]
    )

Source from the content-addressed store, hash-verified

123 raise ExtensionNotFound(f"No {oid} extension was found", oid)
124
125 def get_extension_for_class(
126 self, extclass: type[ExtensionTypeVar]
127 ) -> Extension[ExtensionTypeVar]:
128 if extclass is UnrecognizedExtension:
129 raise TypeError(
130 "UnrecognizedExtension can't be used with "
131 "get_extension_for_class because more than one instance of the"
132 " class may be present."
133 )
134
135 for ext in self:
136 if isinstance(ext.value, extclass):
137 return ext
138
139 raise ExtensionNotFound(
140 f"No {extclass} extension was found", extclass.oid
141 )
142
143 __len__, __iter__, __getitem__ = _make_sequence_methods("_extensions")
144

Callers 15

test_sign_extensionsMethod · 0.80
test_sign_dsa_keyMethod · 0.80
test_sign_ec_keyMethod · 0.80
test_sign_ed25519_keyMethod · 0.80
test_sign_ed448_keyMethod · 0.80
test_sign_mldsa_keyMethod · 0.80
test_eqMethod · 0.80
test_neMethod · 0.80

Calls 1

ExtensionNotFoundClass · 0.85

Tested by 15

test_sign_extensionsMethod · 0.64
test_sign_dsa_keyMethod · 0.64
test_sign_ec_keyMethod · 0.64
test_sign_ed25519_keyMethod · 0.64
test_sign_ed448_keyMethod · 0.64
test_sign_mldsa_keyMethod · 0.64
test_eqMethod · 0.64
test_neMethod · 0.64