PKýklG‘ª.ç ç dav2rem.py#!/usr/bin/env python # Python library to convert between Remind and iCalendar # # Copyright (C) 2015 Jochen Sprickerhof # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program 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 this program. If not, see . """Python tool to sync between Remind and CalDAV""" from argparse import ArgumentParser from caldav import DAVClient, Calendar from getpass import getpass from netrc import netrc from os.path import basename, expanduser, splitext from remind import Remind from urlparse import urlparse # pylint: disable=maybe-no-member def main(): """Command line tool to download from CalDAV to Remind""" parser = ArgumentParser(description='Command line tool to download from CalDAV to Remind') parser.add_argument('-d', '--delete', action='store_true', help='Delete old events') parser.add_argument('-r', '--davurl', required=True, help='The URL of the CalDAV server') parser.add_argument('-u', '--davuser', help='The username for the CalDAV server') parser.add_argument('-p', '--davpass', help='The password for the CalDAV server') parser.add_argument('-i', '--insecure', action='store_true', help='Ignore SSL certificate') parser.add_argument('remfile', nargs='?', default=expanduser('~/.reminders'), help='The Remind file to process (default: ~/.reminders)') args = parser.parse_args() # create empty file if it does not exist open(args.remfile, 'a') rem = Remind(args.remfile) ldict = set(rem.get_uids()) if args.davuser and args.davpass: user = args.davuser passwd = args.davpass else: try: (user, _, passwd) = netrc().authenticators(urlparse(args.davurl).netloc) except (IOError, TypeError): if not args.davuser: print 'dav2rem: Error, argument -u/--davuser or netrc is required' return 1 user = args.davuser try: from keyring import get_password passwd = get_password(urlparse(args.davurl).netloc, user) except ImportError: passwd = None if not passwd: passwd = getpass() client = DAVClient(args.davurl, username=user, password=passwd, ssl_verify_cert=not args.insecure) calendar = Calendar(client, args.davurl) rdict = {splitext(basename(event.canonical_url))[0].replace('%40', '@'): event for event in calendar.events()} if args.delete: local = ldict - rdict.viewkeys() for uid in local: rem.remove(uid) remote = rdict.viewkeys() - ldict for uid in remote: vevent = rdict[uid] vevent.load() rem.append(vevent.data) if __name__ == '__main__': main() PK llG1 Q¾¾ rem2dav.py#!/usr/bin/env python # Python library to convert between Remind and iCalendar # # Copyright (C) 2015 Jochen Sprickerhof # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program 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 this program. If not, see . """Python tool to sync between Remind and CalDAV""" from argparse import ArgumentParser from caldav import DAVClient, Calendar from datetime import date, timedelta from dateutil.parser import parse from dateutil.tz import gettz from getpass import getpass from netrc import netrc from os.path import basename, expanduser, splitext from remind import Remind from urlparse import urlparse from sys import stdin from vobject import iCalendar # pylint: disable=maybe-no-member def main(): """Command line tool to upload a Remind file to CalDAV""" parser = ArgumentParser(description='Command line tool to upload a Remind file to CalDAV') parser.add_argument('-z', '--zone', default='Europe/Berlin', help='Timezone of Remind file (default: Europe/Berlin)') parser.add_argument('-s', '--startdate', type=lambda s: parse(s).date(), default=date.today()-timedelta(weeks=12), help='Start offset for remind call (default: -12 weeks)') parser.add_argument('-m', '--month', type=int, default=15, help='Number of month to generate calendar beginning wit stadtdate (default: 15)') parser.add_argument('-d', '--delete', action='store_true', help='Delete old events') parser.add_argument('-r', '--davurl', required=True, help='The URL of the CalDAV server') parser.add_argument('-u', '--davuser', help='The username for the CalDAV server') parser.add_argument('-p', '--davpass', help='The password for the CalDAV server') parser.add_argument('-i', '--insecure', action='store_true', help='Ignore SSL certificate') parser.add_argument('infile', nargs='?', default=expanduser('~/.reminders'), help='The Remind file to process (default: ~/.reminders)') parser.add_argument('-o', '--old', default=None, help='The old reference Remind file (entries not in the current one will be deleted from dav)') args = parser.parse_args() zone = gettz(args.zone) # Manually set timezone name to generate correct ical files # (python-vobject tests for the zone attribute) zone.zone = args.zone if args.infile == '-': remind = Remind(args.infile, zone, args.startdate, args.month) vobject = remind.stdin_to_vobject(stdin.read().decode('utf-8')) else: remind = Remind(args.infile, zone, args.startdate, args.month) vobject = remind.to_vobject() if hasattr(vobject, 'vevent_list'): ldict = {event.uid.value: event for event in vobject.vevent_list} else: ldict = {} if args.davuser and args.davpass: user = args.davuser passwd = args.davpass else: try: (user, _, passwd) = netrc().authenticators(urlparse(args.davurl).netloc) except (IOError, TypeError): if not args.davuser: print 'rem2dav: Error, argument -u/--davuser or netrc is required' return 1 user = args.davuser try: from keyring import get_password passwd = get_password(urlparse(args.davurl).netloc, user) except ImportError: passwd = None if not passwd: passwd = getpass() client = DAVClient(args.davurl, username=user, password=passwd, ssl_verify_cert=not args.insecure) calendar = Calendar(client, args.davurl) rdict = {splitext(basename(event.canonical_url))[0].replace('%40', '@'): event for event in calendar.events()} if args.old: old = Remind(args.old, zone, args.startdate, args.month) old_vobject = old.to_vobject() if hasattr(old_vobject, 'vevent_list'): odict = {event.uid.value: event for event in old_vobject.vevent_list} intersect = rdict.viewkeys() & odict.viewkeys() rdict = {key: rdict[key] for key in intersect} else: rdict = {} local = ldict.viewkeys() - rdict.viewkeys() for uid in local: ncal = iCalendar() ncal.add(ldict[uid]) calendar.add_event(ncal.serialize()) if args.delete or args.old: remote = rdict.viewkeys() - ldict.viewkeys() for uid in remote: rdict[uid].delete() if __name__ == '__main__': main() PKGmlG^-Ò -remind_caldav-0.4.0.dist-info/DESCRIPTION.rstUNKNOWN PKGmlG°‰fdAA.remind_caldav-0.4.0.dist-info/entry_points.txt[console_scripts] dav2rem = dav2rem:main rem2dav = rem2dav:main PKGmlGuÍ,-ÔÔ+remind_caldav-0.4.0.dist-info/metadata.json{"classifiers": ["Programming Language :: Python", "Development Status :: 4 - Beta", "Environment :: Console", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Topic :: Office/Business :: Scheduling"], "extensions": {"python.commands": {"wrap_console": {"dav2rem": "dav2rem:main", "rem2dav": "rem2dav:main"}}, "python.details": {"contacts": [{"email": "remind@jochen.sprickerhof.de", "name": "Jochen Sprickerhof", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst"}, "project_urls": {"Home": "https://github.com/jspricke/remind-caldav"}}, "python.exports": {"console_scripts": {"dav2rem": "dav2rem:main", "rem2dav": "rem2dav:main"}}}, "extras": [], "generator": "bdist_wheel (0.26.0)", "keywords": ["Remind"], "license": "GPLv3+", "metadata_version": "2.0", "name": "remind-caldav", "run_requires": [{"requires": ["caldav", "python-dateutil", "remind", "vobject"]}], "summary": "Remind CalDAV tools\n ", "version": "0.4.0"}PKGmlGf`Òë+remind_caldav-0.4.0.dist-info/top_level.txtdav2rem rem2dav PKGmlGŒ''\\#remind_caldav-0.4.0.dist-info/WHEELWheel-Version: 1.0 Generator: bdist_wheel (0.26.0) Root-Is-Purelib: true Tag: py2-none-any PKGmlG®ð©ƒƒ&remind_caldav-0.4.0.dist-info/METADATAMetadata-Version: 2.0 Name: remind-caldav Version: 0.4.0 Summary: Remind CalDAV tools Home-page: https://github.com/jspricke/remind-caldav Author: Jochen Sprickerhof Author-email: remind@jochen.sprickerhof.de License: GPLv3+ Keywords: Remind Platform: UNKNOWN Classifier: Programming Language :: Python Classifier: Development Status :: 4 - Beta Classifier: Environment :: Console Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) Classifier: Topic :: Office/Business :: Scheduling Requires-Dist: caldav Requires-Dist: python-dateutil Requires-Dist: remind Requires-Dist: vobject UNKNOWN PKGmlGSgÌ~üü$remind_caldav-0.4.0.dist-info/RECORDdav2rem.py,sha256=LuyXsgXeE_PjPMKmJlE6dJJ-ahFkMf1zaVOYGBXtIi0,3303 rem2dav.py,sha256=hWCfdOgpnB-xjcWDQ8gkWsbcYw0RM4F-6CQoefQEJdg,5054 remind_caldav-0.4.0.dist-info/DESCRIPTION.rst,sha256=OCTuuN6LcWulhHS3d5rfjdsQtW22n7HENFRh6jC6ego,10 remind_caldav-0.4.0.dist-info/METADATA,sha256=SFzbNdIROr3t3o8LQGdt5GUOuBxFiTI9wf-GqZqgxOY,643 remind_caldav-0.4.0.dist-info/RECORD,, remind_caldav-0.4.0.dist-info/WHEEL,sha256=JTb7YztR8fkPg6aSjc571Q4eiVHCwmUDlX8PhuuqIIE,92 remind_caldav-0.4.0.dist-info/entry_points.txt,sha256=Ga20rFxT9Z8faDeI8xqnv4bkTjk6amFJzpLhh2md2kA,65 remind_caldav-0.4.0.dist-info/metadata.json,sha256=vNPhgTsVKhe41CnHEV7V9qaxLAeIt3IpXi76D_nYtrM,980 remind_caldav-0.4.0.dist-info/top_level.txt,sha256=DiCbbX9rbrtAUBtCQ2b79WIOHdOdmkwWI1LXmZIXrQw,16 PKýklG‘ª.ç ç dav2rem.pyPK llG1 Q¾¾  rem2dav.pyPKGmlG^-Ò -õ remind_caldav-0.4.0.dist-info/DESCRIPTION.rstPKGmlG°‰fdAA.J!remind_caldav-0.4.0.dist-info/entry_points.txtPKGmlGuÍ,-ÔÔ+×!remind_caldav-0.4.0.dist-info/metadata.jsonPKGmlGf`Òë+ô%remind_caldav-0.4.0.dist-info/top_level.txtPKGmlGŒ''\\#M&remind_caldav-0.4.0.dist-info/WHEELPKGmlG®ð©ƒƒ&ê&remind_caldav-0.4.0.dist-info/METADATAPKGmlGSgÌ~üü$±)remind_caldav-0.4.0.dist-info/RECORDPK Ðï,