Package: cycle Version: 0.3.1-2 Severity: wishlist Hi,
The attached patch and image (also available at http://people.debian.org/~piman/cycle/) lets cycle export years to iCal format, so they can be imported by e.g. Evolution. BEGIN, LAST, BIRTH, PROG, and OVUL marks are exported. A better image would be appreciated; I have no GIMP talent. -- Joe Wreschnig <[EMAIL PROTECTED]>
--- cycle-0.3.1.orig/cal_year.py
+++ cycle-0.3.1/cal_year.py
@@ -631,6 +630,52 @@
print s
return s
+def report_year_ical(year, fileobj):
+ import socket
+ hostname = socket.gethostname()
+
+ def get_string(mark):
+ if mark & MARK_LAST: return _("Conception")
+ elif mark & MARK_BEGIN: return _("Beginning of cycle")
+ elif mark & MARK_PROG: return _("Probable beginning of cycle")
+ elif mark & MARK_TABLET: return _("1-st tablet")
+ elif mark & MARK_OVUL: return _("Ovulation")
+ elif mark & MARK_BIRTH: return _("Birth")
+ else: return ""
+
+ def make_event(description, mark, date):
+ date2 = date + wx.TimeSpan.Days(1)
+ datestr = "%04d%02d%02d" % (
+ date.GetYear(), date.GetMonth() + 1, date.GetDay())
+ datestr2 = "%04d%02d%02d" % (
+ date2.GetYear(), date2.GetMonth() + 1, date2.GetDay())
+ uid = "UID:[EMAIL PROTECTED]" % (mark, datestr, hostname)
+ return ["BEGIN:VEVENT", uid,
+ "DTSTART;VALUE=DATE:" + datestr,
+ "DTEND;VALUE=DATE:" + datestr2,
+ "SUMMARY:" + description,
+ "DESCRIPTION:" + description,
+ "CLASS:PUBLIC",
+ "END:VEVENT"]
+
+ s = ["BEGIN:VCALENDAR",
+ "CALSCALE:GREGORIAN",
+ "PRODID:-//Cycle//NONSGML Cycle//EN",
+ "VERSION:2.0"]
+
+ days = cycle.mark.items()
+ days.sort()
+ for day, marks in days:
+ if get_string(marks):
+ d = wx.DateTime()
+ d.SetYear(year)
+ d.SetToYearDay(day)
+ s.extend(make_event(get_string(marks), marks, d))
+
+ s.append("END:VCALENDAR")
+
+ print >>fileobj, "\n".join(s)
+
#-------------------- Add import --------------------
from dialogs import Note_Dlg
--- cycle-0.3.1.orig/cycle.py
+++ cycle-0.3.1/cycle.py
@@ -104,10 +104,13 @@
tb.SetToolSeparation(50)
tb.AddSeparator()
-
+
SetToolPath(self, tb, 40, os.path.join(bitmaps_dir,'legend.png'), _('Legend'))
wx.EVT_TOOL(self, 40, self.Legend)
+ SetToolPath(self, tb, 45, os.path.join(bitmaps_dir,'export.png'), _('Export to iCal'))
+ wx.EVT_TOOL(self, 45, self.Export)
+
SetToolPath(self, tb, 50, os.path.join(bitmaps_dir,'set.png'), _('Settings'))
wx.EVT_TOOL(self, 50, self.Settings)
@@ -136,6 +139,18 @@
dlg = Legend_Dlg(self)
dlg.ShowModal()
dlg.Destroy()
+
+ def Export(self, event):
+ dlg = wx.FileDialog(self, _("Export to iCal"),
+ style=wx.SAVE)
+
+ if dlg.ShowModal() == wx.ID_OK:
+ try:
+ fileobj = file(dlg.GetPath(), "w")
+ report_year_ical(self.cal.year, fileobj)
+ except (IOError, OSError), err:
+ wx.MessageDialog(
+ self, str(err), _("Unable to export"), style=wx.OK).ShowModal()
def Settings(self,event):
dlg = Settings_Dlg(self)
export.png
Description: PNG image
signature.asc
Description: This is a digitally signed message part

