Skip to content

Meta Auto Reload

MetaAutoReload class for “meta:auto-reload” tag.

Classes:

Name Description
MetaAutoReload

Container for auto-reload properties, “meta:auto-reload”.

MetaAutoReload

Bases: Element

Container for auto-reload properties, “meta:auto-reload”.

Methods:

Name Description
__init__

Initialize a MetaAutoReload element.

__repr__
__str__
as_dict

Return the attributes of the auto-reload element as a Python dictionary.

from_dict

Set the attributes of the auto-reload element from a Python dictionary.

Attributes:

Name Type Description
actuate
href
show
type
Source code in odfdo/meta_auto_reload.py
 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
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
class MetaAutoReload(Element):
    """Container for auto-reload properties, "meta:auto-reload"."""

    _tag = "meta:auto-reload"
    _properties: tuple[PropDef | PropDefBool, ...] = (
        PropDef("delay", "meta:delay"),
        PropDef("actuate", "xlink:actuate"),
        PropDef("href", "xlink:href"),
        PropDef("show", "xlink:show"),
        PropDef("type", "xlink:type"),
    )

    def __init__(
        self,
        delay: timedelta | None = None,
        href: str = "",
        **kwargs: Any,
    ) -> None:
        """Initialize a MetaAutoReload element.

        The `meta:auto-reload` element specifies whether a document is
        reloaded or replaced by another document after a specified period
        of time has elapsed.

        Args:
            delay: The time delay after which the document
                should auto-reload.
            href: The URL or path to the document to reload or replace with.
            **kwargs: Additional keyword arguments for the parent `Element` class.
        """
        super().__init__(**kwargs)

        self.actuate = "onLoad"
        self.show = "replace"
        self.type = "simple"
        if self._do_init:
            self._set_delay(delay)
            self.href = href

    def __repr__(self) -> str:
        if self.delay:
            delay = str(Duration.decode(self.delay))
        else:
            delay = ""
        return (
            f"<{self.__class__.__name__} tag={self.tag} href={self.href} delay={delay}>"
        )

    def __str__(self) -> str:
        return f"({self.href})"

    def _set_delay(self, delay: timedelta | None) -> None:
        """Set the `meta:delay` attribute from a `timedelta` object.

        Converts the `timedelta` to an ODF duration string. If `delay` is
        None, it defaults to `timedelta(0)`.

        Args:
            delay: The delay duration.
        """
        if delay is None:
            delay = timedelta(0)
        self.delay = Duration.encode(delay)

    def as_dict(self) -> dict[str, Any]:
        """Return the attributes of the auto-reload element as a Python dictionary.

        Returns:
            dict[str, Any]: A dictionary containing the meta auto-reload
                attributes, with keys like "meta:delay", "xlink:href", etc.
        """
        result: dict[str, Any] = {}
        if self.delay:
            result["meta:delay"] = Duration.decode(self.delay)
        else:
            result["meta:delay"] = timedelta(0)
        result.update(
            {
                "xlink:actuate": self.actuate or "onLoad",
                "xlink:href": self.href or "",
                "xlink:show": self.show or "replace",
                "xlink:type": self.type or "simple",
            }
        )
        return result

    def from_dict(self, data: dict[str, Any]) -> None:
        """Set the attributes of the auto-reload element from a Python dictionary.

        Args:
            data: A dictionary containing the meta auto-reload
                attributes (e.g., "meta:delay", "xlink:href").
        """
        self._set_delay(data.get("meta:delay"))
        self.actuate = data.get("xlink:actuate", "onLoad")
        self.href = data.get("xlink:href", "")
        self.show = data.get("xlink:show", "replace")
        self.type = data.get("xlink:type", "simple")

_properties class-attribute instance-attribute

_properties: tuple[PropDef | PropDefBool, ...] = (
    PropDef("delay", "meta:delay"),
    PropDef("actuate", "xlink:actuate"),
    PropDef("href", "xlink:href"),
    PropDef("show", "xlink:show"),
    PropDef("type", "xlink:type"),
)

_tag class-attribute instance-attribute

_tag = 'meta:auto-reload'

actuate instance-attribute

actuate = 'onLoad'

href instance-attribute

href = href

show instance-attribute

show = 'replace'

type instance-attribute

type = 'simple'

__init__

__init__(
    delay: timedelta | None = None,
    href: str = "",
    **kwargs: Any,
) -> None

Initialize a MetaAutoReload element.

The meta:auto-reload element specifies whether a document is reloaded or replaced by another document after a specified period of time has elapsed.

Parameters:

Name Type Description Default
delay timedelta | None

The time delay after which the document should auto-reload.

None
href str

The URL or path to the document to reload or replace with.

''
**kwargs Any

Additional keyword arguments for the parent Element class.

{}
Source code in odfdo/meta_auto_reload.py
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
def __init__(
    self,
    delay: timedelta | None = None,
    href: str = "",
    **kwargs: Any,
) -> None:
    """Initialize a MetaAutoReload element.

    The `meta:auto-reload` element specifies whether a document is
    reloaded or replaced by another document after a specified period
    of time has elapsed.

    Args:
        delay: The time delay after which the document
            should auto-reload.
        href: The URL or path to the document to reload or replace with.
        **kwargs: Additional keyword arguments for the parent `Element` class.
    """
    super().__init__(**kwargs)

    self.actuate = "onLoad"
    self.show = "replace"
    self.type = "simple"
    if self._do_init:
        self._set_delay(delay)
        self.href = href

__repr__

__repr__() -> str
Source code in odfdo/meta_auto_reload.py
70
71
72
73
74
75
76
77
def __repr__(self) -> str:
    if self.delay:
        delay = str(Duration.decode(self.delay))
    else:
        delay = ""
    return (
        f"<{self.__class__.__name__} tag={self.tag} href={self.href} delay={delay}>"
    )

__str__

__str__() -> str
Source code in odfdo/meta_auto_reload.py
79
80
def __str__(self) -> str:
    return f"({self.href})"

_set_delay

_set_delay(delay: timedelta | None) -> None

Set the meta:delay attribute from a timedelta object.

Converts the timedelta to an ODF duration string. If delay is None, it defaults to timedelta(0).

Parameters:

Name Type Description Default
delay timedelta | None

The delay duration.

required
Source code in odfdo/meta_auto_reload.py
82
83
84
85
86
87
88
89
90
91
92
93
def _set_delay(self, delay: timedelta | None) -> None:
    """Set the `meta:delay` attribute from a `timedelta` object.

    Converts the `timedelta` to an ODF duration string. If `delay` is
    None, it defaults to `timedelta(0)`.

    Args:
        delay: The delay duration.
    """
    if delay is None:
        delay = timedelta(0)
    self.delay = Duration.encode(delay)

as_dict

as_dict() -> dict[str, Any]

Return the attributes of the auto-reload element as a Python dictionary.

Returns:

Type Description
dict[str, Any]

dict[str, Any]: A dictionary containing the meta auto-reload attributes, with keys like “meta:delay”, “xlink:href”, etc.

Source code in odfdo/meta_auto_reload.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
def as_dict(self) -> dict[str, Any]:
    """Return the attributes of the auto-reload element as a Python dictionary.

    Returns:
        dict[str, Any]: A dictionary containing the meta auto-reload
            attributes, with keys like "meta:delay", "xlink:href", etc.
    """
    result: dict[str, Any] = {}
    if self.delay:
        result["meta:delay"] = Duration.decode(self.delay)
    else:
        result["meta:delay"] = timedelta(0)
    result.update(
        {
            "xlink:actuate": self.actuate or "onLoad",
            "xlink:href": self.href or "",
            "xlink:show": self.show or "replace",
            "xlink:type": self.type or "simple",
        }
    )
    return result

from_dict

from_dict(data: dict[str, Any]) -> None

Set the attributes of the auto-reload element from a Python dictionary.

Parameters:

Name Type Description Default
data dict[str, Any]

A dictionary containing the meta auto-reload attributes (e.g., “meta:delay”, “xlink:href”).

required
Source code in odfdo/meta_auto_reload.py
117
118
119
120
121
122
123
124
125
126
127
128
def from_dict(self, data: dict[str, Any]) -> None:
    """Set the attributes of the auto-reload element from a Python dictionary.

    Args:
        data: A dictionary containing the meta auto-reload
            attributes (e.g., "meta:delay", "xlink:href").
    """
    self._set_delay(data.get("meta:delay"))
    self.actuate = data.get("xlink:actuate", "onLoad")
    self.href = data.get("xlink:href", "")
    self.show = data.get("xlink:show", "replace")
    self.type = data.get("xlink:type", "simple")