pyhanko.pdf_utils.config_utils module

This module contains utilities for allowing dataclasses to be populated by user-provided configuration (e.g. from a Yaml file).


On naming conventions: this module converts hyphens in key names to underscores as a matter of course.

exception pyhanko.pdf_utils.config_utils.ConfigurationError

Bases: ValueError

Signal configuration errors.

class pyhanko.pdf_utils.config_utils.ConfigurableMixin

Bases: object

General configuration mixin for dataclasses

classmethod process_entries(config_dict)

Hook method that can modify the configuration dictionary to overwrite or tweak some of their values (e.g. to convert string parameters into more complex Python objects)

Subclasses that override this method should call super().process_entries(), and leave keys that they do not recognise untouched.


config_dict – A dictionary containing configuration values.


ConfigurationError – when there is a problem processing a relevant entry.

classmethod from_config(config_dict)

Attempt to instantiate an object of the class on which it is called, by means of the configuration settings passed in.

First, we check that the keys supplied in the dictionary correspond to data fields on the current class. Then, the dictionary is processed using the process_entries() method. The resulting dictionary is passed to the initialiser of the current class as a kwargs dict.


config_dict – A dictionary containing configuration values.


An instance of the class on which it is called.


ConfigurationError – when an unexpected configuration key is encountered or left unfilled, or when there is a problem processing one of the config values.

pyhanko.pdf_utils.config_utils.check_config_keys(config_name, expected_keys, config_dict)
pyhanko.pdf_utils.config_utils.process_oid(asn1crypto_class: Type[asn1crypto.core.ObjectIdentifier], id_string, param_name)
pyhanko.pdf_utils.config_utils.process_oids(asn1crypto_class: Type[asn1crypto.core.ObjectIdentifier], strings, param_name)
pyhanko.pdf_utils.config_utils.process_bit_string_flags(asn1crypto_class: Type[asn1crypto.core.BitString], strings, param_name)