summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/delete.py49
-rwxr-xr-xtools/make_iata.py34
2 files changed, 83 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()
diff --git a/tools/make_iata.py b/tools/make_iata.py
new file mode 100755
index 0000000..5644469
--- /dev/null
+++ b/tools/make_iata.py
@@ -0,0 +1,34 @@
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# Create the iata.py file from upstream data.
22
23import urllib.request
24
25f = urllib.request.urlopen("https://raw.githubusercontent.com/hroptatyr/dateutils/tzmaps/iata.tzmap")
26data = f.read().decode('ascii')
27
28with open('iata.py', 'w') as out:
29 out.write('tzmap = {\n')
30 for line in data.split('\n'):
31 if not line: continue
32 code, tz = [x.strip() for x in line.split()]
33 out.write(" '%s': '%s',\n" % (code, tz))
34 out.write('}\n')