Skip to content

Mixin List

Mixin class for classes containing Lists, “text:list”.

Classes:

Name Description
ListMixin

Mixin class for classes containing Lists.

ListMixin

Bases: Element

Mixin class for classes containing Lists.

Used by the following classes: “draw:caption”, “draw:circle”, “draw:connector”, “draw:custom-shape”, “draw:ellipse”, “draw:image”, “draw:line”, “draw:measure”, “draw:path”, “draw:polygon”, “draw:polyline”, “draw:rect”, “draw:regular-polygon”, “draw:text-box”, “office:annotation”, “office:text”, “style:footer”, “style:footer-first”, “style:footer-left”, “style:header”, “style:header-first”, “style:header-left”, “table:covered-table-cell”, “table:table-cell”, “text:deletion”, “text:index-body”, “text:index-title”, “text:list-header”, “text:list-item”, “text:note-body”, “text:section”.

*: not implemented.

Methods:

Name Description
get_list

Returns a single list that matches the specified criteria.

get_lists

Returns all lists that match the specified criteria.

Attributes:

Name Type Description
lists list[List]

Returns all lists as a list.

Source code in odfdo/mixin_list.py
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
class ListMixin(Element):
    """Mixin class for classes containing Lists.

    Used by the following classes:
    *"draw:caption", *"draw:circle", "draw:connector", *"draw:custom-shape",
    "draw:ellipse", "draw:image", "draw:line", *"draw:measure", *"draw:path",
    *"draw:polygon", *"draw:polyline", "draw:rect", *"draw:regular-polygon",
    "draw:text-box", "office:annotation", "office:text", "style:footer",
    "style:footer-first", "style:footer-left", "style:header",
    "style:header-first", "style:header-left", "table:covered-table-cell",
    "table:table-cell", "text:deletion", "text:index-body",
    "text:index-title", "text:list-header", "text:list-item",
    "text:note-body", "text:section".

    *: not implemented.
    """

    def get_lists(
        self,
        style: str | None = None,
        content: str | None = None,
    ) -> list[List]:
        """Returns all lists that match the specified criteria.

        Args:
            style: The name of the style to filter lists by.
            content: A regex pattern to match against the list's content.

        Returns:
            list[List]: A list of `List` instances matching the criteria.
        """
        return cast(
            "list[List]",
            self._filtered_elements(
                "descendant::text:list", text_style=style, content=content
            ),
        )

    @property
    def lists(self) -> list[List]:
        """Returns all lists as a list.

        Returns:
            list[List]: A list of all List instances that are descendants of
                this element.
        """
        return cast("list[List]", self.get_elements("descendant::text:list"))

    def get_list(
        self,
        position: int = 0,
        content: str | None = None,
    ) -> List | None:
        """Returns a single list that matches the specified criteria.

        Args:
            position: The 0-based index of the matching list to return.
            content: A regex pattern to match against the list's content.

        Returns:
            List | None: A List instance, or None if no list matches the
                criteria.
        """
        return cast(
            "None | List",
            self._filtered_element("descendant::text:list", position, content=content),
        )

lists property

lists: list[List]

Returns all lists as a list.

Returns:

Type Description
list[List]

list[List]: A list of all List instances that are descendants of this element.

get_list

get_list(
    position: int = 0, content: str | None = None
) -> List | None

Returns a single list that matches the specified criteria.

Parameters:

Name Type Description Default
position int

The 0-based index of the matching list to return.

0
content str | None

A regex pattern to match against the list’s content.

None

Returns:

Type Description
List | None

List | None: A List instance, or None if no list matches the criteria.

Source code in odfdo/mixin_list.py
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
def get_list(
    self,
    position: int = 0,
    content: str | None = None,
) -> List | None:
    """Returns a single list that matches the specified criteria.

    Args:
        position: The 0-based index of the matching list to return.
        content: A regex pattern to match against the list's content.

    Returns:
        List | None: A List instance, or None if no list matches the
            criteria.
    """
    return cast(
        "None | List",
        self._filtered_element("descendant::text:list", position, content=content),
    )

get_lists

get_lists(
    style: str | None = None, content: str | None = None
) -> list[List]

Returns all lists that match the specified criteria.

Parameters:

Name Type Description Default
style str | None

The name of the style to filter lists by.

None
content str | None

A regex pattern to match against the list’s content.

None

Returns:

Type Description
list[List]

list[List]: A list of List instances matching the criteria.

Source code in odfdo/mixin_list.py
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
def get_lists(
    self,
    style: str | None = None,
    content: str | None = None,
) -> list[List]:
    """Returns all lists that match the specified criteria.

    Args:
        style: The name of the style to filter lists by.
        content: A regex pattern to match against the list's content.

    Returns:
        list[List]: A list of `List` instances matching the criteria.
    """
    return cast(
        "list[List]",
        self._filtered_elements(
            "descendant::text:list", text_style=style, content=content
        ),
    )