aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/caldav/calcurse-caldav.py
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-02-05 18:21:27 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2016-02-05 19:12:12 +0100
commit812c6b1dd6989b0b630f4eb2c4a0f5c4c4fca7fe (patch)
tree53a27aea4ff7bf5cb81f215bc7fd9dd5c673245f /contrib/caldav/calcurse-caldav.py
parent4ada3deda275ca26a1f809af87a6e81d7920c07c (diff)
downloadcalcurse-812c6b1dd6989b0b630f4eb2c4a0f5c4c4fca7fe.tar.gz
calcurse-812c6b1dd6989b0b630f4eb2c4a0f5c4c4fca7fe.zip
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 <lfleischer@calcurse.org>
Diffstat (limited to 'contrib/caldav/calcurse-caldav.py')
-rwxr-xr-xcontrib/caldav/calcurse-caldav.py20
1 files changed, 7 insertions, 13 deletions
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.')