cctool

A tool for managing contacts and calendars.
git clone https://git.ce9e.org/cctool.git

commit
a2c3c180bd2547bfdd32e2cb21828d432feefeb3
parent
87f87d988c52f0399ea98036bdc7a11df6f2c075
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2015-05-08 17:40
filter non-events in person2event

Diffstat

M cctool.py 22 ++++++++++++----------

1 files changed, 12 insertions, 10 deletions


diff --git a/cctool.py b/cctool.py

@@ -191,16 +191,18 @@ def map_keys(mdict, _map, reverse=False, exclusive=True):
  191   191 	return outdict
  192   192 
  193   193 
  194    -1 def event2person(source, reverse=False):
  195    -1 	target = map_keys(source, {
  196    -1 		'summary': 'name',
  197    -1 		'dtstart': 'bday',
  198    -1 	}, reverse=reverse, exclusive=False)
   -1   194 def event2person(data, reverse=False):
   -1   195 	for source in data:
   -1   196 		target = map_keys(source, {
   -1   197 			'summary': 'name',
   -1   198 			'dtstart': 'bday',
   -1   199 		}, reverse=reverse, exclusive=False)
  199   200 
  200    -1 	if reverse and 'bday' in source:
  201    -1 		target.append('freq', ['yearly'])
   -1   201 		if reverse and 'bday' in source:
   -1   202 			target.append('freq', ['yearly'])
  202   203 
  203    -1 	return target
   -1   204 		if not reverse or 'dtstart' in target:
   -1   205 			yield target
  204   206 
  205   207 
  206   208 class Format(object):
@@ -514,9 +516,9 @@ def main():
  514   516 			infile.close()
  515   517 
  516   518 	if outformat in PERSON:
  517    -1 		data = [event2person(i) for i in data]
   -1   519 		data = list(event2person(data))
  518   520 	if outformat in EVENT:
  519    -1 		data = [event2person(i, reverse=True) for i in data]
   -1   521 		data = list(event2person(data, reverse=True))
  520   522 
  521   523 	if args.merge is not None:
  522   524 		data = merged(data, key=args.merge)