summaryrefslogtreecommitdiff
path: root/tools/delete.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/delete.py')
-rwxr-xr-xtools/delete.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/tools/delete.py b/tools/delete.py
new file mode 100755
index 0000000..f68f3d6
--- /dev/null
+++ b/tools/delete.py
@@ -0,0 +1,49 @@
1#!/usr/bin/env python3
2
3# Copyright (C) 2019 James E. Blair <corvus@gnu.org>
4#
5# This file is part of Email-assistant.
6#
7# Email-assistant is free software: you can redistribute it and/or
8# modify it under the terms of the GNU Affero General Public License
9# as published by the Free Software Foundation, either version 3 of
10# the License, or (at your option) any later version.
11#
12# Email-assistant is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15# General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with Email-assistant. If not, see
19# <https://www.gnu.org/licenses/>.
20
21# Delete all events from a calendar
22
23import sys
24import os
25import configparser
26import email
27import logging
28import imaplib
29import json
30
31import caldav
32
33url = sys.argv[1]
34username = sys.argv[2]
35password = sys.argv[3]
36calendar_name = sys.argv[4]
37
38client = caldav.DAVClient(url, username=username, password=password)
39principal = client.principal()
40calendar = None
41for c in principal.calendars():
42 if c.name == calendar_name:
43 calendar = c
44existing_events = []
45for e in calendar.events():
46 print(e.url)
47 existing_events.append((e.instance.vevent.dtstart.value,
48 e.instance.vevent.summary.value))
49 e.delete()