Skip to content

Commit

Permalink
Merge branch 'main' into security
Browse files Browse the repository at this point in the history
  • Loading branch information
niccokunzmann authored Dec 23, 2024
2 parents 02f6426 + 03e32e9 commit 47f59d1
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 17 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Changelog
Minor changes:

- Add a ``weekday`` attribute to ``vWeekday`` components. See `Issue 749 <https://github.com/collective/icalendar/issues/749>`_.
- Document ``vRecur`` property. See `Issue 758 <https://github.com/collective/icalendar/issues/758>`_.
- Print failure of doctest to aid debugging.

Breaking changes:

Expand Down Expand Up @@ -36,7 +38,7 @@ Minor changes:
- Merge "File Structure" and "Overview" sections in the docs. See `Issue 626 <https://github.com/collective/icalendar/issues/626>`_.
- Update code blocks in ``usage.rst`` with the correct lexer.
- Tidy up the docstring for ``icalendar.prop.vPeriod``.
- Improve typing and fix typing issues
- Improve typing and fix typing issues


New features:
Expand Down
4 changes: 3 additions & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,9 @@ By extending the event with subcomponents, you can create multiple alarms.
>>> alarm_24h_before.add('description', 'Reminder: Event in 24 hours')
>>> event.add_component(alarm_24h_before)
Or even recurrence.
Or even recurrence, either from a dictionary or a string.
Note that if you want to add the reccurence rule from a string, you must use the ``vRecur`` property.
Otherwise the rule will be escaped, making it invalid.

.. code-block:: pycon
Expand Down
87 changes: 77 additions & 10 deletions src/icalendar/prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,15 @@ class vCalAddress(str):
.. code-block:: text
mailto:[email protected]
.. code-block:: pycon
>>> from icalendar.prop import vCalAddress
>>> cal_address = vCalAddress.from_ical('mailto:[email protected]')
>>> cal_address
vCalAddress('mailto:[email protected]')
"""

def __new__(cls, value, encoding=DEFAULT_ENCODING):
Expand Down Expand Up @@ -259,7 +259,7 @@ class vFloat(float):
1000000.0000001
1.333
-3.14
.. code-block:: pycon
>>> from icalendar.prop import vFloat
Expand Down Expand Up @@ -505,11 +505,11 @@ class vDate(TimeBase):
Value Name:
DATE
Purpose:
This value type is used to identify values that contain a
calendar date.
Format Definition:
This value type is defined by the following notation:
Expand All @@ -531,7 +531,7 @@ class vDate(TimeBase):
format specifies a four-digit year, two-digit month, and two-digit
day of the month. There are no separator characters between the
year, month, and day component text.
Example:
The following represents July 14, 1997:
Expand Down Expand Up @@ -696,7 +696,7 @@ class vDuration(TimeBase):
components MUST be added first, that is, the number of days MUST
be added first, followed by the number of hours, number of
minutes, and number of seconds.
Example:
A duration of 15 days, 5 hours, and 20 seconds would be:
Expand All @@ -709,7 +709,7 @@ class vDuration(TimeBase):
.. code-block:: text
P7W
.. code-block:: pycon
>>> from icalendar.prop import vDuration
Expand Down Expand Up @@ -805,7 +805,7 @@ class vPeriod(TimeBase):
; [ISO.8601.2004] complete representation basic format for a
; period of time consisting of a start and positive duration
; of time.
Description:
If the property permits, multiple "period" values are
specified by a COMMA-separated list of values. There are two
Expand Down Expand Up @@ -835,7 +835,7 @@ class vPeriod(TimeBase):
.. code-block:: text
19970101T180000Z/PT5H30M
.. code-block:: pycon
>>> from icalendar.prop import vPeriod
Expand Down Expand Up @@ -1100,6 +1100,73 @@ def __reduce_ex__(self, _p):

class vRecur(CaselessDict):
"""Recurrence definition.
Property Name:
RRULE
Purpose:
This property defines a rule or repeating pattern for recurring events, to-dos,
journal entries, or time zone definitions.
Value Type:
RECUR
Property Parameters:
IANA and non-standard property parameters can be specified on this property.
Conformance:
This property can be specified in recurring "VEVENT", "VTODO", and "VJOURNAL"
calendar components as well as in the "STANDARD" and "DAYLIGHT" sub-components
of the "VTIMEZONE" calendar component, but it SHOULD NOT be specified more than once.
The recurrence set generated with multiple "RRULE" properties is undefined.
Description:
The recurrence rule, if specified, is used in computing the recurrence set.
The recurrence set is the complete set of recurrence instances for a calendar component.
The recurrence set is generated by considering the initial "DTSTART" property along
with the "RRULE", "RDATE", and "EXDATE" properties contained within the
recurring component. The "DTSTART" property defines the first instance in the
recurrence set. The "DTSTART" property value SHOULD be synchronized with the
recurrence rule, if specified. The recurrence set generated with a "DTSTART" property
value not synchronized with the recurrence rule is undefined.
The final recurrence set is generated by gathering all of the start DATE-TIME
values generated by any of the specified "RRULE" and "RDATE" properties, and then
excluding any start DATE-TIME values specified by "EXDATE" properties.
This implies that start DATE- TIME values specified by "EXDATE" properties take
precedence over those specified by inclusion properties (i.e., "RDATE" and "RRULE").
Where duplicate instances are generated by the "RRULE" and "RDATE" properties,
only one recurrence is considered. Duplicate instances are ignored.
The "DTSTART" property specified within the iCalendar object defines the first
instance of the recurrence. In most cases, a "DTSTART" property of DATE-TIME value
type used with a recurrence rule, should be specified as a date with local time
and time zone reference to make sure all the recurrence instances start at the
same local time regardless of time zone changes.
If the duration of the recurring component is specified with the "DTEND" or
"DUE" property, then the same exact duration will apply to all the members of the
generated recurrence set. Else, if the duration of the recurring component is
specified with the "DURATION" property, then the same nominal duration will apply
to all the members of the generated recurrence set and the exact duration of each
recurrence instance will depend on its specific start time. For example, recurrence
instances of a nominal duration of one day will have an exact duration of more or less
than 24 hours on a day where a time zone shift occurs. The duration of a specific
recurrence may be modified in an exception component or simply by using an
"RDATE" property of PERIOD value type.
Example:
The following RRULE specifies daily events for 10 occurrences.
.. code-block:: text
RRULE:FREQ=DAILY;COUNT=10
.. code-block:: pycon
>>> from icalendar.prop import vRecur
>>> rrule = vRecur.from_ical('FREQ=DAILY;COUNT=10')
>>> rrule
vRecur({'FREQ': ['DAILY'], 'COUNT': [10]})
"""

frequencies = ["SECONDLY", "MINUTELY", "HOURLY", "DAILY", "WEEKLY",
Expand Down
10 changes: 5 additions & 5 deletions src/icalendar/tests/test_with_doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ def test_documentation_file(document, zoneinfo_only, env_for_doctest, tzp):
functions are also replaced to work.
"""
try:
import pytz
except ImportError:
pytest.skip("pytz not installed, skipping this file.")
try:
# set raise_on_error to False if you wand to see the error for debug
test_result = doctest.testfile(
document, module_relative=False, globs=env_for_doctest, raise_on_error=True
document, module_relative=False, globs=env_for_doctest, raise_on_error=False
)
except doctest.UnexpectedException as e:
ty, err, tb = e.exc_info
if issubclass(ty, ModuleNotFoundError) and err.name == "pytz":
pytest.skip("pytz not installed, skipping this file.")
finally:
tzp.use_zoneinfo()
assert (
Expand Down

0 comments on commit 47f59d1

Please sign in to comment.