From 812c6b1dd6989b0b630f4eb2c4a0f5c4c4fca7fe Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 5 Feb 2016 18:21:27 +0100 Subject: calcurse-caldav: Use -G and %(hash) to list hashes Instead of reimplementing the code to generate object hashes in the synchronization script, use format strings to print the hashes in grep mode. Signed-off-by: Lukas Fleischer --- contrib/caldav/calcurse-caldav.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'contrib/caldav/calcurse-caldav.py') diff --git a/contrib/caldav/calcurse-caldav.py b/contrib/caldav/calcurse-caldav.py index 21bcfac..25a8d1a 100755 --- a/contrib/caldav/calcurse-caldav.py +++ b/contrib/caldav/calcurse-caldav.py @@ -3,7 +3,6 @@ import argparse import base64 import configparser -import hashlib import http.client import os import re @@ -58,17 +57,12 @@ def calcurse_export(objhash): def calcurse_hashset(): - p = subprocess.Popen([calcurse, '-G'], stdout=subprocess.PIPE) - out = p.communicate()[0] - - hashes = set() - for line in out.split(b'\n'): - if not line: - continue - sha1 = hashlib.new('sha1') - sha1.update(line) - hashes.add(sha1.hexdigest()) - return hashes + p = subprocess.Popen([calcurse, '-G', '--format-apt=%(hash)\\n', + '--format-recur-apt=%(hash)\\n', + '--format-event=%(hash)\\n', + '--format-recur-event=%(hash)\\n', + '--format-todo=%(hash)\\n'], stdout=subprocess.PIPE) + return set(p.communicate()[0].decode('utf-8').rstrip().splitlines()) def calcurse_remove(objhash): @@ -451,7 +445,7 @@ ver = calcurse_version() if ver is None: die('Invalid calcurse binary. Make sure that the file specified in ' + 'the configuration is a valid and up-to-date calcurse binary.') -elif ver < (4, 0, 0, 73): +elif ver < (4, 0, 0, 96): die('Incompatible calcurse binary detected. Version >=4.1.0 is required ' + 'to synchronize with CalDAV servers.') -- cgit v1.2.3