cctool

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

commit
b2e46e6cea3bec155c9e8d41ce53f0b1d3a68eb0
parent
3e4fb5fe618fa504c517a29b139c038e46034f5a
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2015-05-08 17:04
event2person

Diffstat

M cctool.py 14 ++++++++++++++

1 files changed, 14 insertions, 0 deletions


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

@@ -60,6 +60,8 @@ except ImportError as err:
   60    60 
   61    61 
   62    62 NOTSET = object()
   -1    63 PERSON = ['abook', 'ldif']
   -1    64 EVENT = ['bsdcal', 'ics']
   63    65 
   64    66 
   65    67 def _str(x):
@@ -188,6 +190,13 @@ def map_keys(mdict, _map, reverse=False, exclusive=True):
  188   190 	return outdict
  189   191 
  190   192 
   -1   193 def event2person(source, reverse=False):
   -1   194 	return map_keys(source, {
   -1   195 		'summary': 'name',
   -1   196 		'dtstart': 'bday',
   -1   197 	}, reverse=reverse, exclusive=False)
   -1   198 
   -1   199 
  191   200 class Format(object):
  192   201 	"""Baseclass with an API similar to the marshal, pickle and json modules.
  193   202 
@@ -493,6 +502,11 @@ def main():
  493   502 		if filename != '-':
  494   503 			infile.close()
  495   504 
   -1   505 	if outformat in PERSON:
   -1   506 		data = [event2person(i) for i in data]
   -1   507 	if outformat in EVENT:
   -1   508 		data = [event2person(i, reverse=True) for i in data]
   -1   509 
  496   510 	if args.merge is not None:
  497   511 		data = merged(data, key=args.merge)
  498   512