summaryrefslogtreecommitdiffstats
path: root/contrib/caldav/calcurse-caldav.py
diff options
context:
space:
mode:
authorSatvik Sharma <satvik.sharma2@gmail.com>2017-10-25 11:52:22 +1100
committerLukas Fleischer <lfleischer@calcurse.org>2017-11-05 20:14:30 +0100
commitb96e175192f8711f07beca6e27f8d9fb42b12227 (patch)
tree3fd098239682fa9cda73b4dc2388671006b02427 /contrib/caldav/calcurse-caldav.py
parent2fa15118987d0afe012a5e408dc262e73e26d185 (diff)
downloadcalcurse-b96e175192f8711f07beca6e27f8d9fb42b12227.tar.gz
calcurse-b96e175192f8711f07beca6e27f8d9fb42b12227.zip
calcurse-caldav: Add SyncFilter config option
The SyncFilter option filters the types of items synced from/to a CalDAV server by making use of the --filter-type command line argument. Signed-off-by: Satvik Sharma <satvik.sharma2@gmail.com> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'contrib/caldav/calcurse-caldav.py')
-rwxr-xr-xcontrib/caldav/calcurse-caldav.py53
1 files changed, 41 insertions, 12 deletions
diff --git a/contrib/caldav/calcurse-caldav.py b/contrib/caldav/calcurse-caldav.py
index 1d0a0c8..bc6d714 100755
--- a/contrib/caldav/calcurse-caldav.py
+++ b/contrib/caldav/calcurse-caldav.py
@@ -44,6 +44,11 @@ def die_atnode(msg, node):
die(msg)
+def validate_sync_filter():
+ valid_sync_filter_values = {'event', 'apt', 'recur-event', 'recur-apt', 'todo', 'recur', 'cal'}
+ return set(sync_filter.split(',')) - valid_sync_filter_values
+
+
def calcurse_wipe():
if verbose:
print('Removing all local calcurse objects...')
@@ -53,13 +58,20 @@ def calcurse_wipe():
def calcurse_import(icaldata):
- p = subprocess.Popen([calcurse, '-i', '-', '--dump-imported', '-q',
- '--format-apt=%(hash)\\n',
- '--format-recur-apt=%(hash)\\n',
- '--format-event=%(hash)\\n',
- '--format-recur-event=%(hash)\\n',
- '--format-todo=%(hash)\\n'],
- stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+ command = [
+ calcurse,
+ '-i', '-',
+ '--dump-imported',
+ '-q',
+ '--filter-type', sync_filter,
+ '--format-apt=%(hash)\\n',
+ '--format-recur-apt=%(hash)\\n',
+ '--format-event=%(hash)\\n',
+ '--format-recur-event=%(hash)\\n',
+ '--format-todo=%(hash)\\n'
+ ]
+
+ p = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
return p.communicate(icaldata.encode('utf-8'))[0].decode('utf-8').rstrip()
@@ -70,11 +82,18 @@ def calcurse_export(objhash):
def calcurse_hashset():
- 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)
+ command = [
+ calcurse,
+ '-G',
+ '--filter-type', sync_filter,
+ '--format-apt=%(hash)\\n',
+ '--format-recur-apt=%(hash)\\n',
+ '--format-event=%(hash)\\n',
+ '--format-recur-event=%(hash)\\n',
+ '--format-todo=%(hash)\\n'
+ ]
+
+ p = subprocess.Popen(command, stdout=subprocess.PIPE)
return set(p.communicate()[0].decode('utf-8').rstrip().splitlines())
@@ -533,6 +552,16 @@ if config.has_option('General', 'AuthMethod'):
else:
authmethod = 'basic'
+if config.has_option('General', 'SyncFilter'):
+ sync_filter = config.get('General', 'SyncFilter')
+
+ invalid_filter_values = validate_sync_filter()
+
+ if len(invalid_filter_values):
+ die('Invalid value(s) in SyncFilter option: ' + ', '.join(invalid_filter_values))
+else:
+ sync_filter = 'cal,todo'
+
if config.has_option('Auth', 'UserName'):
username = config.get('Auth', 'UserName')
else: