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).
Note
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.- Parameters
config_dict – A dictionary containing configuration values.
- Raises
ConfigurationError – when there is a problem processing a relevant entry.
- classmethod check_config_keys(keys_supplied: Set[str])
Check whether all supplied keys are meaningful.
- Parameters
keys_supplied – The keys supplied in the configuration.
- Raises
ConfigurationError – if at least one key does not make sense.
- 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.- Parameters
config_dict – A dictionary containing configuration values.
- Returns
An instance of the class on which it is called.
- Raises
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, supplied_keys)
- pyhanko.pdf_utils.config_utils.process_oid(asn1crypto_class: Type[ObjectIdentifier], id_string, param_name)
- pyhanko.pdf_utils.config_utils.process_oids(asn1crypto_class: Type[ObjectIdentifier], strings, param_name)
- pyhanko.pdf_utils.config_utils.process_bit_string_flags(asn1crypto_class: Type[BitString], strings, param_name)