Exemplo n.º 1
0
    def _convert(self, vcal, d):
        global module_debug
        for i in vcal:
            try:
                dd = {"start": None, "end": None}
                for j in self._calendar_keys:
                    if i.has_key(j[0]):
                        k = i[j[0]]
                        if j[2] is not None:
                            dd[j[1]] = j[2](self, k, dd)
                        else:
                            dd[j[1]] = k["value"]
                if dd["start"] is None and dd["end"] is None:
                    # no start or end, drop this one
                    continue
                if dd["start"] is None:
                    dd["start"] = dd["end"]
                elif dd["end"] is None:
                    dd["end"] = dd["start"]
                if dd.get("allday", False) and dd["end"] > dd["start"]:
                    # All day event, adjust the end time as necessary
                    dd["end"] = (bptime.BPTime(dd["end"]) - bptime.timedelta(days=1)).get()[:3] + (0, 0)

                if module_debug:
                    print dd
                d.append(dd)
            except:
                if module_debug:
                    raise
Exemplo n.º 2
0
    def _convert(self, vcal, d):
        global module_debug
        for i in vcal:
            try:
                dd = {'start': None, 'end': None}
                for j in self._calendar_keys:
                    if i.has_key(j[0]):
                        k = i[j[0]]
                        if j[2] is not None:
                            dd[j[1]] = j[2](self, k, dd)
                        else:
                            dd[j[1]] = k['value']
                if dd['start'] is None and dd['end'] is None:
                    # no start or end, drop this one
                    continue
                if dd['start'] is None:
                    dd['start'] = dd['end']
                elif dd['end'] is None:
                    dd['end'] = dd['start']
                if dd.get('allday', False) and dd['end'] > dd['start']:
                    # All day event, adjust the end time as necessary
                    dd['end']=(bptime.BPTime(dd['end'])-\
                               bptime.timedelta(days=1)).get()[:3]+(0, 0)

                if module_debug: print dd
                d.append(dd)
            except:
                if module_debug: raise
Exemplo n.º 3
0
 def _write_times_single(self, keyword, v, event, tzid):
     # write the DTSTART/DTEND property for a single
     # (non-recurrent) event
     _start=bptime.BPTime(event.start)
     _end=bptime.BPTime(event.end)
     if event.allday:
         # all day event
         _params=('VALUE=DATE',)
         _res=out_line('DTSTART', _params,
                       _start.iso_str(no_time=True), None)
         _end+=bptime.timedelta(days=1)
         _res+=out_line('DTEND', _params,
                        _end.iso_str(no_time=True), None)
     else:
         _params=('TZID=%s'%tzid,)
         _res=out_line('DTSTART', _params, _start.iso_str(no_seconds=False), None)
         _res+=out_line('DTEND', _params, _end.iso_str(no_seconds=False), None)
     return _res
Exemplo n.º 4
0
 def _write_times_single(self, keyword, v, event, tzid):
     # write the DTSTART/DTEND property for a single
     # (non-recurrent) event
     _start=bptime.BPTime(event.start)
     _end=bptime.BPTime(event.end)
     if event.allday:
         # all day event
         _params=('VALUE=DATE',)
         _res=out_line('DTSTART', _params,
                       _start.iso_str(no_time=True), None)
         _end+=bptime.timedelta(days=1)
         _res+=out_line('DTEND', _params,
                        _end.iso_str(no_time=True), None)
     else:
         _params=('TZID=%s'%tzid,)
         _res=out_line('DTSTART', _params, _start.iso_str(no_seconds=False), None)
         _res+=out_line('DTEND', _params, _end.iso_str(no_seconds=False), None)
     return _res
Exemplo n.º 5
0
 def _write_start(self, event, tzid):
     # write the DTSTART/DURATION property for a recurrent event
     _start=bptime.BPTime(event.start)
     _end=bptime.BPTime(event.end)
     if event.allday:
         # all day event, can only handle sameday allday event (for now)
         _params=('VALUE=DATE',)
         _res=out_line('DTSTART', _params,
                       _start.iso_str(no_time=True), None)
         _end+=bptime.timedelta(days=1)
         _res+=out_line('DTEND', _params,
                        _end.iso_str(no_time=True), None)
     else:
         # can only handle 24hr-long event (for now)
         _new_end=_start+(_end-_start).seconds
         _params=('TZID=%s'%tzid,)
         _res=out_line('DTSTART', _params, _start.iso_str(no_seconds=False), None)
         _res+=out_line('DTEND',  _params, _new_end.iso_str(no_seconds=False), None)
     return _res
Exemplo n.º 6
0
 def _write_start(self, event, tzid):
     # write the DTSTART/DURATION property for a recurrent event
     _start=bptime.BPTime(event.start)
     _end=bptime.BPTime(event.end)
     if event.allday:
         # all day event, can only handle sameday allday event (for now)
         _params=('VALUE=DATE',)
         _res=out_line('DTSTART', _params,
                       _start.iso_str(no_time=True), None)
         _end+=bptime.timedelta(days=1)
         _res+=out_line('DTEND', _params,
                        _end.iso_str(no_time=True), None)
     else:
         # can only handle 24hr-long event (for now)
         _new_end=_start+(_end-_start).seconds
         _params=('TZID=%s'%tzid,)
         _res=out_line('DTSTART', _params, _start.iso_str(no_seconds=False), None)
         _res+=out_line('DTEND',  _params, _new_end.iso_str(no_seconds=False), None)
     return _res