diff options
| author | James E. Blair <corvus@gnu.org> | 2019-06-08 14:19:35 -0700 | 
|---|---|---|
| committer | James E. Blair <corvus@gnu.org> | 2019-06-08 14:28:18 -0700 | 
| commit | c44874cfa48bf00b83057033fc7800b35e157702 (patch) | |
| tree | 052829810af7ecc0c85c94eb68404e492d2ee379 /tools | |
Initial commit
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/delete.py | 49 | ||||
| -rwxr-xr-x | tools/make_iata.py | 34 | 
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 | |||
| 23 | import sys | ||
| 24 | import os | ||
| 25 | import configparser | ||
| 26 | import email | ||
| 27 | import logging | ||
| 28 | import imaplib | ||
| 29 | import json | ||
| 30 | |||
| 31 | import caldav | ||
| 32 | |||
| 33 | url = sys.argv[1] | ||
| 34 | username = sys.argv[2] | ||
| 35 | password = sys.argv[3] | ||
| 36 | calendar_name = sys.argv[4] | ||
| 37 | |||
| 38 | client = caldav.DAVClient(url, username=username, password=password) | ||
| 39 | principal = client.principal() | ||
| 40 | calendar = None | ||
| 41 | for c in principal.calendars(): | ||
| 42 | if c.name == calendar_name: | ||
| 43 | calendar = c | ||
| 44 | existing_events = [] | ||
| 45 | for 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 | |||
| 23 | import urllib.request | ||
| 24 | |||
| 25 | f = urllib.request.urlopen("https://raw.githubusercontent.com/hroptatyr/dateutils/tzmaps/iata.tzmap") | ||
| 26 | data = f.read().decode('ascii') | ||
| 27 | |||
| 28 | with 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') | ||
