Paper Office
paper-docxAPI referenceopc.part

PartFactory

paper-docx 0.2.0 API reference

Provides a way for client code to specify a subclass of Part to be constructed by Unmarshaller based on its content type and/or a custom callable.

Setting PartFactory.part_class_selector to a callable object will cause that object to be called with the parameters content_type, reltype, once for each part in the package. If the callable returns an object, it is used as the class for that part. If it returns None, part class selection falls back to the content type map defined in PartFactory.part_type_for. If no class is returned from either of these, the class contained in PartFactory.default_part_type is used to construct the part, which is by default opc.package.Part.

Attributes

default_part_type

attributedefault_part_type
= Part

part_class_selector

attributepart_class_selectorCallable[[str, str], Type[Part] | None] | None

part_type_for

attributepart_type_fordict[str, Type[Part]]
= {}

On this page