From c44874cfa48bf00b83057033fc7800b35e157702 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Sat, 8 Jun 2019 14:19:35 -0700 Subject: Initial commit --- tools/delete.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ tools/make_iata.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100755 tools/delete.py create mode 100755 tools/make_iata.py (limited to 'tools') 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 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2019 James E. Blair +# +# This file is part of Email-assistant. +# +# Email-assistant is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# Email-assistant is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Email-assistant. If not, see +# . + +# Delete all events from a calendar + +import sys +import os +import configparser +import email +import logging +import imaplib +import json + +import caldav + +url = sys.argv[1] +username = sys.argv[2] +password = sys.argv[3] +calendar_name = sys.argv[4] + +client = caldav.DAVClient(url, username=username, password=password) +principal = client.principal() +calendar = None +for c in principal.calendars(): + if c.name == calendar_name: + calendar = c +existing_events = [] +for e in calendar.events(): + print(e.url) + existing_events.append((e.instance.vevent.dtstart.value, + e.instance.vevent.summary.value)) + 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 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2019 James E. Blair +# +# This file is part of Email-assistant. +# +# Email-assistant is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# Email-assistant is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Email-assistant. If not, see +# . + +# Create the iata.py file from upstream data. + +import urllib.request + +f = urllib.request.urlopen("https://raw.githubusercontent.com/hroptatyr/dateutils/tzmaps/iata.tzmap") +data = f.read().decode('ascii') + +with open('iata.py', 'w') as out: + out.write('tzmap = {\n') + for line in data.split('\n'): + if not line: continue + code, tz = [x.strip() for x in line.split()] + out.write(" '%s': '%s',\n" % (code, tz)) + out.write('}\n') -- cgit v1.2.3