Skip to content

Mixin Dc Creator

Mixin class for .

Classes:

Name Description
DcCreatorMixin

Creator of the document, “dc:creator”.

DcCreatorMixin

Creator of the document, “dc:creator”.

Methods:

Name Description
get_creator

Get the name of the document creator.

set_creator

Set the name of the document creator.

Attributes:

Name Type Description
creator str | None

Get or set the element.

Source code in odfdo/mixin_dc_creator.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class DcCreatorMixin:
    """Creator of the document, "dc:creator"."""

    def get_creator(self) -> str | None:
        """Get the name of the document creator.

        This corresponds to the `dc:creator` element.

        Returns:
            The creator's name, or `None` if not specified.
        """
        element = self.clone.get_element("//dc:creator")
        if element is None:
            return None
        return element.text  # type: ignore[no-any-return]

    def set_creator(self, creator: str) -> None:
        """Set the name of the document creator.

        This updates the `dc:creator` element.

        Args:
            creator: The name of the creator to set.
        """
        element = self.get_element("//dc:creator")
        if element is None:
            element = Element.from_tag("dc:creator")
            if hasattr(self, "get_meta_body"):
                self.get_meta_body().append(element)
            else:
                self.append(element)
        element.text = creator

    @property
    def creator(self) -> str | None:
        """Get or set the <dc:creator> element.

        The <dc:creator> element specifies the name of the person who last
        modified a document (<office:meta>), who created an annotation
        (<office:annotation>), who authored a change (<office:change-info>).

        The <dc:creator> element is usable within the following elements:
        <office:annotation>, <office:change-info> and <office:meta>.
        """
        return self.get_creator()

    @creator.setter
    def creator(self, creator: str) -> None:
        self.set_creator(creator)

creator property writable

creator: str | None

Get or set the element.

The element specifies the name of the person who last modified a document (), who created an annotation (), who authored a change ().

The element is usable within the following elements: , and .

get_creator

get_creator() -> str | None

Get the name of the document creator.

This corresponds to the dc:creator element.

Returns:

Type Description
str | None

The creator’s name, or None if not specified.

Source code in odfdo/mixin_dc_creator.py
30
31
32
33
34
35
36
37
38
39
40
41
def get_creator(self) -> str | None:
    """Get the name of the document creator.

    This corresponds to the `dc:creator` element.

    Returns:
        The creator's name, or `None` if not specified.
    """
    element = self.clone.get_element("//dc:creator")
    if element is None:
        return None
    return element.text  # type: ignore[no-any-return]

set_creator

set_creator(creator: str) -> None

Set the name of the document creator.

This updates the dc:creator element.

Parameters:

Name Type Description Default
creator str

The name of the creator to set.

required
Source code in odfdo/mixin_dc_creator.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
def set_creator(self, creator: str) -> None:
    """Set the name of the document creator.

    This updates the `dc:creator` element.

    Args:
        creator: The name of the creator to set.
    """
    element = self.get_element("//dc:creator")
    if element is None:
        element = Element.from_tag("dc:creator")
        if hasattr(self, "get_meta_body"):
            self.get_meta_body().append(element)
        else:
            self.append(element)
    element.text = creator