Skip to content

Commit

Permalink
icalendar was an optional dependency ... but why not make it an offic…
Browse files Browse the repository at this point in the history
…ial dependency?
  • Loading branch information
tobixen committed Oct 22, 2022
1 parent 452d0df commit d51c5f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions caldav/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2312,7 +2312,7 @@ def _complete_recurring_thisandfuture(self, completion_timestamp):
if count is not None and count[0] <= len(
[x for x in recurrences if not self._is_pending(x)]
):
self._complete_ical(recurrences[0])
self._complete_ical(recurrences[0], completion_timestamp=completion_timestamp)
self.save(increase_seqno=False)
return

Expand Down Expand Up @@ -2340,18 +2340,14 @@ def complete(
* this_and_future - see doc for _complete_recurring_thisandfuture for details
* safe - see doc for _complete_recurring_safe for details
"""
## TODO: after 1.0 release, call on self._complete_ical instead
if not completion_timestamp:
completion_timestamp = datetime.utcnow().astimezone(vobject.icalendar.utc)

if hasattr(self.instance.vtodo, "rrule") and handle_rrule:
return getattr(self, "_complete_recurring_%s" % rrule_mode)(
completion_timestamp
)
if not hasattr(self.vobject_instance.vtodo, "status"):
self.vobject_instance.vtodo.add("status")
self.vobject_instance.vtodo.status.value = "COMPLETED"
self.vobject_instance.vtodo.add("completed").value = completion_timestamp
self._complete_ical(completion_timestamp=completion_timestamp)
self.save()

def _complete_ical(self, i=None, completion_timestamp=None):
Expand All @@ -2360,8 +2356,6 @@ def _complete_ical(self, i=None, completion_timestamp=None):
if i is None:
i = self.icalendar_instance.subcomponents[0]
assert self._is_pending(i)
if completion_timestamp is None:
completion_timestamp = datetime.now()
status = i.pop("STATUS", None)
i.add("STATUS", "COMPLETED")
i.add("COMPLETED", completion_timestamp)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
packages=find_packages(exclude=["tests"]),
include_package_data=True,
zip_safe=False,
install_requires=["vobject", "lxml", "requests", "six"] + extra_packages,
install_requires=["vobject", "lxml", "requests", "six", "icalendar"] + extra_packages,
tests_require=test_packages + extra_test_packages,
extras_require={
"test": test_packages,
Expand Down

0 comments on commit d51c5f9

Please sign in to comment.