Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/656.feature.3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added the ``DERIVED`` property parameter from :rfc:`9073#section-5.3` (Event Publishing Extensions to iCalendar). It is available on anyproperty (such as :class:`~icalendar.prop.text.vText`) to mark that its value is computed from other properties and must not be edited directly.I used Claude AI (Sonnet 5.5) to assist me with this change.@Mrbozz
16 changes: 16 additions & 0 deletions src/icalendar/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,12 +838,28 @@ def _del_GAP(prop): # noqa: N802

GAP = property(_get_GAP, _set_GAP, _del_GAP)

DERIVED = boolean_parameter("DERIVED", False)
"""Indicate that a property's value is derived from other property values.

Conformance:
This property parameter is specified in :rfc:`9073#section-5.3`.

This parameter MAY be specified on any property whose value can be
derived from the value of one or more other properties. When set to
``TRUE``, clients MUST NOT update the property's value directly, since
it is expected to be recomputed from the properties it derives from.
The default, when absent, is ``FALSE``.
"""



__all__ = [
"ALTREP",
"CN",
"CUTYPE",
"DELEGATED_FROM",
"DELEGATED_TO",
"DERIVED",
"DIR",
"EMAIL",
"FBTYPE",
Expand Down
2 changes: 1 addition & 1 deletion src/icalendar/prop/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def ical_value(self) -> str:
"""The string value of the text."""
return str(self)

from icalendar.param import ALTREP, GAP, LANGUAGE, RELTYPE, VALUE
from icalendar.param import ALTREP,DERIVED, GAP, LANGUAGE, RELTYPE, VALUE

def to_jcal(self, name: str) -> list:
"""The jCal representation of this property according to :rfc:`7265`."""
Expand Down
25 changes: 25 additions & 0 deletions src/icalendar/tests/prop/test_derived_param.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
r"""DERIVED property parameter from :rfc:`9073`.

:rfc:`9073#section-5.3` defines DERIVED to mark that a property's value was
computed from other property values and so MUST NOT be edited directly.
The RFC's own example is a STYLED-DESCRIPTION rendering generated from
another STYLED-DESCRIPTION -- a value type not implemented in this codebase
yet (see :issue:`656`). Exercised here on :class:`~icalendar.prop.text.vText`
instead, since DERIVED may be specified on any property.
"""

from icalendar import vText


def test_derived_default_is_false():
"""DERIVED defaults to False when absent, per RFC 9073 5.3."""
comment = vText("Generated summary")
assert comment.DERIVED is False


def test_derived_round_trips_as_bool():
"""Setting DERIVED to True serializes as DERIVED=TRUE and reads back True."""
comment = vText("Generated summary")
comment.DERIVED = True
assert comment.DERIVED is True
assert comment.params["DERIVED"] == "TRUE"
Loading