From d40ed4b3cb4c1fe66f8078544557ee52e8b786cc Mon Sep 17 00:00:00 2001 From: HannaEpelboim Date: Tue, 17 Nov 2026 22:44:16 -0300 Subject: [PATCH 1/3] ORDER property --- src/icalendar/param.py | 16 ++++++++++++++ src/icalendar/prop/text.py | 2 +- src/icalendar/tests/prop/test_order_param.py | 23 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/icalendar/tests/prop/test_order_param.py diff --git a/src/icalendar/param.py b/src/icalendar/param.py index bca86330f..1d4cdf7ea 100644 --- a/src/icalendar/param.py +++ b/src/icalendar/param.py @@ -838,6 +838,21 @@ def _del_GAP(prop): # noqa: N802 GAP = property(_get_GAP, _set_GAP, _del_GAP) +ORDER = string_parameter( + "ORDER", + """Specify the ordering of the property instance it is attached to. + + Conformance: + This property parameter is specified in :rfc:`9073#section-5.1`. + + The value is an integer >= 1, with a value of 1 + meaning the instance appears first. + """, + default=lambda: None, + convert=int, + convert_to=str, +) + __all__ = [ "ALTREP", "CN", @@ -853,6 +868,7 @@ def _del_GAP(prop): # noqa: N802 "LANGUAGE", "LINKREL", "MEMBER", + "ORDER", "PARTSTAT", "RANGE", "RELATED", diff --git a/src/icalendar/prop/text.py b/src/icalendar/prop/text.py index 3c4e7f5c1..2b2207bcc 100644 --- a/src/icalendar/prop/text.py +++ b/src/icalendar/prop/text.py @@ -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, GAP, LANGUAGE, ORDER, RELTYPE, VALUE def to_jcal(self, name: str) -> list: """The jCal representation of this property according to :rfc:`7265`.""" diff --git a/src/icalendar/tests/prop/test_order_param.py b/src/icalendar/tests/prop/test_order_param.py new file mode 100644 index 000000000..d3440f7ac --- /dev/null +++ b/src/icalendar/tests/prop/test_order_param.py @@ -0,0 +1,23 @@ +from icalendar import Event, vText + + +def test_order_default_is_none(): + """ORDER is absent by default, meaning 'comes last'.""" + contact = vText("Dev") + assert contact.ORDER is None + + +def test_order_round_trips_as_int(): + """Setting ORDER stores an int and reads back the same int.""" + contact = vText("Dev") + contact.ORDER = 1 + assert contact.ORDER == 1 + assert contact.params["ORDER"] == "1" + + +def test_order_parses_from_ical(): + """A CONTACT with ORDER set in a real .ics round-trips through from_ical.""" + ics = "BEGIN:VEVENT\r\nCONTACT;ORDER=2:Dev\r\nEND:VEVENT\r\n" + event = Event.from_ical(ics) + [contact] = event.contacts + assert contact.ORDER == 2 From 63c42f65643a3ff04090e8e622307601648be452 Mon Sep 17 00:00:00 2001 From: HannaEpelboim Date: Tue, 17 Nov 2026 22:54:45 -0300 Subject: [PATCH 2/3] changelog --- news/news/656.feature.1 | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/news/656.feature.1 diff --git a/news/news/656.feature.1 b/news/news/656.feature.1 new file mode 100644 index 000000000..28d78560f --- /dev/null +++ b/news/news/656.feature.1 @@ -0,0 +1 @@ +Added the ``ORDER`` property parameter from :rfc:`9073#section-5.1` (Event Publishing Extensions to iCalendar). It is available on any TEXT-valued property (such as :class:`~icalendar.prop.text.vText`, used by ``CONTACT``). See :issue:`656`. @HannaEpelboim \ No newline at end of file From 75c49a43acbdbecff84772a726ee993354e7b0f1 Mon Sep 17 00:00:00 2001 From: HannaEpelboim Date: Thu, 19 Nov 2026 14:11:30 -0300 Subject: [PATCH 3/3] Fix news fragment path --- news/{news => }/656.feature.1 | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename news/{news => }/656.feature.1 (100%) diff --git a/news/news/656.feature.1 b/news/656.feature.1 similarity index 100% rename from news/news/656.feature.1 rename to news/656.feature.1