cctool

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

commit
5e3bce589aced7180f2dac375312b039d9aa4c0a
parent
a195789c02a10a5aab907f1b8f9cc53c860d7a91
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2014-04-20 22:53
write down available ical/vcard fields

Diffstat

M cctool.py 28 ++++++++++++++++++++++++++--

1 files changed, 26 insertions, 2 deletions


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

@@ -125,6 +125,14 @@ class BSDCal(Format):
  125   125 
  126   126 
  127   127 class ICal(Format):
   -1   128 	fields = ['attach', 'categories', 'class', 'comment', 'description', 'geo',
   -1   129 		'location', 'percent-complete', 'priority', 'resources', 'status',
   -1   130 		'summary', 'completed', 'dtend', 'due', 'dtstart', 'duration', 'freebusy',
   -1   131 		'transp', 'tzid', 'tzname', 'tzoffsetfrom', 'tzoffsetto', 'tzurl',
   -1   132 		'attendee', 'contact', 'organizer', 'recurrence-id', 'related-to', 'url',
   -1   133 		'uid', 'exdate', 'rdate', 'rrule', 'action', 'repeat', 'trigger',
   -1   134 		'created', 'dtstamp', 'last-modified', 'sequence']
   -1   135 
  128   136 	@classmethod
  129   137 	def load(cls, fh):
  130   138 		if isinstance(vobject, Exception):
@@ -146,7 +154,9 @@ class ICal(Format):
  146   154 		for event in data:
  147   155 			vevent = ical.add('vevent')
  148   156 			for key in event:
  149    -1 				vevent.add(key).value = event.join(key)
   -1   157 				if key in cls.fields:
   -1   158 					for value in event[key]:
   -1   159 						vevent.add(key).value = value
  150   160 		ical.serialize(fh)
  151   161 
  152   162 
@@ -231,6 +241,12 @@ class LDIF(Format):
  231   241 
  232   242 
  233   243 class VCard(Format):
   -1   244 	fields = ['fn', 'n', 'nickname', 'photo', 'bday', 'anniversary', 'gender',
   -1   245 		'adr', 'tel', 'email', 'impp', 'lang', 'tz', 'geo', 'title', 'role',
   -1   246 		'logo', 'org', 'member', 'related', 'categories', 'note', 'prodid', 'rev',
   -1   247 		'sound', 'uid', 'clientpidmap', 'url', 'version', 'key', 'fburl',
   -1   248 		'caladruri', 'caluri']
   -1   249 
  234   250 	@classmethod
  235   251 	def load(cls, fh):
  236   252 		if isinstance(vobject, Exception):
@@ -249,8 +265,16 @@ class VCard(Format):
  249   265 
  250   266 		for item in data:
  251   267 			vcard = vobject.vCard()
   -1   268 			vcard.add('n').value = ''
  252   269 			for key in item:
  253    -1 				vcard.add(key).value = item.join(key)
   -1   270 				if key == 'name':
   -1   271 					vcard.add('fn').value = item.join(key)
   -1   272 				elif key == 'nick':
   -1   273 					for value in item[key]:
   -1   274 						vcard.add('nickname').value = value
   -1   275 				elif key in cls.fields:
   -1   276 					for value in item[key]:
   -1   277 						vcard.add(key).value = value
  254   278 			vcard.serialize(fh)
  255   279 
  256   280