Skip to content

Commit 4f53a30

Browse files
Merge pull request #810 from niccokunzmann/issue-798
Add parameters to properties
2 parents 7bb2877 + ec46b5d commit 4f53a30

File tree

16 files changed

+926
-54
lines changed

16 files changed

+926
-54
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Minor changes:
88

99
- Use ``ruff`` to format the source code.
1010
- Update project metadata to use License-Expression.
11+
- Use ``tzp.localize(dt, None)`` to remove the timezone from a datetime.
12+
- Remove the HTML documentation when building with ``tox`` to force rebuild.
1113
- Switch to PyData Sphinx Theme for documentation. See `Issue 803 <https://github.com/collective/icalendar/issues/804>`_.
1214

1315
Breaking changes:
@@ -22,11 +24,14 @@ New features:
2224
- Add ``sequence`` attribute to ``Event``, ``Todo``, and ``Journal`` components. See `Issue 802 <https://github.com/collective/icalendar/issues/802>`_.
2325
- Add ``categories`` attribute to ``Calendar``, ``Event``, ``Todo``, and ``Journal`` components. See `Issue 655 <https://github.com/collective/icalendar/issues/655>`_.
2426
- Add compatibility to :rfc:`6868`. See `Issue 652 <https://github.com/collective/icalendar/issues/652>`_.
27+
- Add ``freebusy`` property to the ``Calendar`` to get this type of subcomponents easier.
28+
- Add parameters from :rfc:`5545` to properties ``ALTREP``, ``CN``, ``CUTYPE``, ``DELEGATED_FROM``, ``DELEGATED_TO``, ``DIR``, ``FBTYPE``, ``LANGUAGE``, ``MEMBER``, ``PARTSTAT``, ``RANGE``, ``RELATED``, ``ROLE``, ``RSVP``, ``SENT_BY``, ``TZID``, and ``RELTYPE``. See `Issue 798 <https://github.com/collective/icalendar/issues/798>`_.
2529
- New properties from :rfc:`7986` can occur multiple times in ``VCALENDAR``. See `PR 808`_.
2630

2731
Bug fixes:
2832

2933
- Move import at the end of ``icalendar.parser`` into a function to mitigate import errors, see `Issue 781 <https://github.com/collective/icalendar/issues/781>`_.
34+
- ``ALTREP``, ``DELEGATED-FROM``, ``DELEGATED-TO``, ``DIR``, ``MEMBER``, and ``SENT-BY`` require double quotes. These are now always added.
3035
- Classify ``CATEGORIES`` as multiple in ``VEVENT``. See `PR 808 <https://github.com/collective/icalendar/pull/808>`_.
3136

3237
6.1.3 (2025-03-19)

docs/api.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
API Reference
22
-------------
33

4+
icalendar.attr
5+
++++++++++++++
6+
7+
.. automodule:: icalendar.attr
8+
:members:
9+
410
icalendar.alarms
511
++++++++++++++++
612

713
.. automodule:: icalendar.alarms
814
:members:
915

10-
1116
icalendar.cal
1217
+++++++++++++
1318

@@ -26,12 +31,24 @@ icalendar.cli
2631
.. automodule:: icalendar.cli
2732
:members:
2833

34+
icalendar.enums
35+
+++++++++++++++
36+
37+
.. automodule:: icalendar.enums
38+
:members:
39+
2940
icalendar.error
3041
+++++++++++++++
3142

3243
.. automodule:: icalendar.error
3344
:members:
3445

46+
icalendar.param
47+
+++++++++++++++
48+
49+
.. automodule:: icalendar.param
50+
:members:
51+
3552
icalendar.parser
3653
++++++++++++++++
3754

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"sphinx_copybutton",
1111
"sphinx.ext.intersphinx",
1212
"sphinx.ext.autosectionlabel",
13+
"sphinx.ext.napoleon",
1314
]
1415
source_suffix = ".rst"
1516
master_doc = "index"

src/icalendar/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
TimezoneStandard,
1616
Todo,
1717
)
18+
from icalendar.enums import CUTYPE, FBTYPE, PARTSTAT, RANGE, RELATED, RELTYPE, ROLE
1819
from icalendar.error import (
1920
ComponentEndMissing,
2021
ComponentStartMissing,
@@ -111,5 +112,13 @@
111112
"ComponentStartMissing",
112113
"IncompleteAlarmInformation",
113114
"LocalTimezoneMissing",
115+
"CUTYPE",
116+
"FBTYPE",
117+
"PARTSTAT",
118+
"RANGE",
114119
"vSkip",
120+
"RELATED",
121+
"vSkip",
122+
"RELTYPE",
123+
"ROLE",
115124
]

src/icalendar/attr.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Attributes of Components and properties."""
22
from __future__ import annotations
33

4-
from datetime import date, datetime, timedelta
54
import itertools
5+
from datetime import date, datetime, timedelta
66
from typing import TYPE_CHECKING, Optional, Union
77

88
from icalendar.error import InvalidCalendar
@@ -313,9 +313,9 @@ def multi_language_text_property(main_prop:str, compatibility_prop:str, doc:str)
313313
This property can be defined several times with different ``LANGUAGE`` parameters.
314314
315315
Args:
316-
main_prop: The property to set and get, such as ``NAME``
317-
compatibility_prop: An old property used before, such as ``X-WR-CALNAME``
318-
doc: The documentation string
316+
main_prop (str): The property to set and get, such as ``NAME``
317+
compatibility_prop (str): An old property used before, such as ``X-WR-CALNAME``
318+
doc (str): The documentation string
319319
"""
320320
def fget(self: Component) -> Optional[str]:
321321
"""Get the property"""
@@ -369,8 +369,9 @@ def fdel(self: Component):
369369
def single_utc_property(name: str, docs: str) -> property:
370370
"""Create a property to access a value of datetime in UTC timezone.
371371
372-
name - name of the property
373-
docs - documentation string
372+
Args:
373+
name: name of the property
374+
docs: documentation string
374375
"""
375376
docs = (
376377
f"""The {name} property. datetime in UTC

src/icalendar/cal.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,6 +1956,16 @@ def todos(self) -> list[Todo]:
19561956
"""
19571957
return self.walk("VTODO")
19581958

1959+
@property
1960+
def freebusy(self) -> list[FreeBusy]:
1961+
"""All FreeBusy components in the calendar.
1962+
1963+
This is a shortcut to get all FreeBusy.
1964+
Modifications do not change the calendar.
1965+
Use :py:meth:`Component.add_component`.
1966+
"""
1967+
return self.walk("VFREEBUSY")
1968+
19591969
def get_used_tzids(self) -> set[str]:
19601970
"""The set of TZIDs in use.
19611971

src/icalendar/enums.py

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
"""Enumerations for different types in the RFCs."""
2+
from enum import Enum as _Enum
3+
4+
5+
class Enum(_Enum):
6+
"""Enum class that can be pickled."""
7+
8+
def __reduce_ex__(self, _p):
9+
"""For pickling."""
10+
return self.__class__, (self._name_,)
11+
12+
13+
class StrEnum(str, Enum):
14+
"""Enum for strings."""
15+
16+
17+
class PARTSTAT(StrEnum):
18+
"""Enum for PARTSTAT from :rfc:`5545`.
19+
20+
Attributes:
21+
``NEEDS_ACTION``,
22+
``ACCEPTED``,
23+
``DECLINED``,
24+
``TENTATIVE``,
25+
``DELEGATED``,
26+
``COMPLETED``,
27+
``IN_PROCESS``
28+
"""
29+
NEEDS_ACTION = "NEEDS-ACTION"
30+
ACCEPTED = "ACCEPTED"
31+
DECLINED = "DECLINED"
32+
TENTATIVE = "TENTATIVE"
33+
DELEGATED = "DELEGATED"
34+
COMPLETED = "COMPLETED"
35+
IN_PROCESS = "IN-PROCESS"
36+
37+
38+
class FBTYPE(StrEnum):
39+
"""Enum for FBTYPE from :rfc:`5545`.
40+
41+
Attributes:
42+
``FREE``,
43+
``BUSY``,
44+
``BUSY-UNAVAILABLE``,
45+
``BUSY-TENTATIVE``
46+
"""
47+
FREE = "FREE"
48+
BUSY = "BUSY"
49+
BUSY_UNAVAILABLE = "BUSY-UNAVAILABLE"
50+
BUSY_TENTATIVE = "BUSY-TENTATIVE"
51+
52+
53+
class CUTYPE(StrEnum):
54+
"""Enum for CTYPE from :rfc:`5545`.
55+
56+
Attributes:
57+
``INDIVIDUAL``,
58+
``GROUP``,
59+
``RESOURCE``,
60+
``ROOM``,
61+
``UNKNOWN``
62+
"""
63+
INDIVIDUAL = "INDIVIDUAL"
64+
GROUP = "GROUP"
65+
RESOURCE = "RESOURCE"
66+
ROOM = "ROOM"
67+
UNKNOWN = "UNKNOWN"
68+
69+
70+
class RELTYPE(StrEnum):
71+
"""Enum for RELTYPE from :rfc:`5545`.
72+
73+
Attributes:
74+
``PARENT``,
75+
``CHILD``,
76+
``SIBLING``
77+
"""
78+
PARENT = "PARENT"
79+
CHILD = "CHILD"
80+
SIBLING = "SIBLING"
81+
82+
83+
class RANGE(StrEnum):
84+
"""Enum for RANGE from :rfc:`5545`.
85+
86+
Attributes:
87+
``THISANDFUTURE``,
88+
``THISANDPRIOR``
89+
"""
90+
91+
THISANDFUTURE = "THISANDFUTURE"
92+
THISANDPRIOR = "THISANDPRIOR" # deprecated
93+
94+
95+
class RELATED(StrEnum):
96+
"""Enum for RELATED from :rfc:`5545`.
97+
98+
Attributes:
99+
``START``,
100+
``END``
101+
"""
102+
START = "START"
103+
END = "END"
104+
105+
106+
class ROLE(StrEnum):
107+
"""Enum for ROLE from :rfc:`5545`.
108+
109+
Attributes:
110+
``CHAIR``,
111+
``REQ-PARTICIPANT``,
112+
``OPT-PARTICIPANT``,
113+
``NON-PARTICIPANT``
114+
"""
115+
CHAIR = "CHAIR"
116+
REQ_PARTICIPANT = "REQ-PARTICIPANT"
117+
OPT_PARTICIPANT = "OPT-PARTICIPANT"
118+
NON_PARTICIPANT = "NON-PARTICIPANT"
119+
120+
121+
__all__ = [
122+
"PARTSTAT",
123+
"FBTYPE",
124+
"CUTYPE",
125+
"RANGE",
126+
"RELATED",
127+
"ROLE",
128+
"RELTYPE",
129+
]

0 commit comments

Comments
 (0)