Skip to content

coreprops

coreprops

Core properties part, corresponds to /docProps/core.xml part in package.

CorePropertiesPart

CorePropertiesPart(
    partname: PackURI,
    content_type: str,
    element: BaseOxmlElement,
    package: Package,
)

Bases: XmlPart

Corresponds to part named /docProps/core.xml.

The "core" is short for "Dublin Core" and contains document metadata relatively common across documents of all types, not just DOCX.

Source code in src/docx/opc/part.py
def __init__(
    self, partname: PackURI, content_type: str, element: BaseOxmlElement, package: Package
):
    super(XmlPart, self).__init__(partname, content_type, package=package)
    self._element = element

core_properties property

core_properties

A CoreProperties object providing read/write access to the core properties contained in this core properties part.

default classmethod

default(package: OpcPackage)

Return a new CorePropertiesPart object initialized with default values for its base properties.

Source code in src/docx/opc/parts/coreprops.py
@classmethod
def default(cls, package: OpcPackage):
    """Return a new |CorePropertiesPart| object initialized with default values for
    its base properties."""
    core_properties_part = cls._new(package)
    core_properties = core_properties_part.core_properties
    core_properties.title = "Word Document"
    core_properties.last_modified_by = "python-docx"
    core_properties.revision = 1
    core_properties.modified = dt.datetime.now(dt.timezone.utc)
    return core_properties_part