From mmacnair at gmail.com Sat Aug 16 19:48:57 2008 From: mmacnair at gmail.com (Michael Macnair) Date: Sat, 16 Aug 2008 18:48:57 +0100 Subject: [icalendar-dev] icalendar UTF-8 troubles Message-ID: Hello, If anyone could enlighten me as to what I'm doing wrong here, it would be much appreciated. Essentially I can't read a calendar with a utf8 character in it. Minimal example calendar available at http://macnair.org/utf8.ics wget "http://macnair.org/utf8.ics" python2.6 >>> import icalendar >>> import codecs >>> f = codecs.open('utf8.ics', 'r', 'utf-8') >>> ical = icalendar.Calendar.from_string(f.read()) Traceback (most recent call last): File "", line 1, in File "..../icalendar/cal.py", line 341, in from_string for line in Contentlines.from_string(st): # raw parsing File "..../icalendar/parser.py", line 494, in from_string raise ValueError, 'Expected StringType with content lines' ValueError: Expected StringType with content lines Removing the error handler in parser.py shows: File "", line 1, in File "..../icalendar/cal.py", line 341, in from_string for line in Contentlines.from_string(st): # raw parsing File "..../icalendar/parser.py", line 489, in from_string lines = [Contentline(line) for line in unfolded.splitlines() if line] File "..../icalendar/parser.py", line 369, in __new__ self = str.__new__(cls, st) UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 31: ordinal not in range(128) Cheers, Mike From matt-icalendar at mosuki.com Mon Aug 18 07:23:36 2008 From: matt-icalendar at mosuki.com (Matt Chisholm) Date: Sun, 17 Aug 2008 22:23:36 -0700 Subject: [icalendar-dev] icalendar UTF-8 troubles In-Reply-To: References: Message-ID: <20080818052336.GC9966@devsuki.com> Wow. I just read through the iCalendar spec, and it says almost nothing about how to encode non-ASCII. This is all it says, on page 24: The following example makes use of the Quoted-Printable encoding in order to represent non-ASCII characters. LOCATION;LANGUAGE=da:K=F8benhavn LOCATION;LANGUAGE=en:Copenhagen I was going to suggest that you check that your iCalendar file was encoding according to the spec, but since the spec doesn't really say anything about it, nevermind that. :) The code is tracing back because str() won't accept any UTF-8 data, period. Opening the file with codecs.open() is pointless. No matter what you do with that ics file you've got, at some point the description will get passed to str() and str() will die because it's getting a UTF-8 control character. Someone should check to see what Apple, Gcal, Outlook, etc. does with non-ASCII characters when writing iCalendar files. If there's an implicit convention, or a few, then the icalendar library should be upgraded to decode them properly and return only unicode objects for "strings." I say "should" because I doubt anybody has the time for this. I certainly don't. :) -matt On Aug 16 2008, 18:48, Michael Macnair wrote: >Hello, > >If anyone could enlighten me as to what I'm doing wrong here, it would >be much appreciated. >Essentially I can't read a calendar with a utf8 character in it. >Minimal example calendar available at http://macnair.org/utf8.ics > >wget "http://macnair.org/utf8.ics" >python2.6 >>>> import icalendar >>>> import codecs >>>> f = codecs.open('utf8.ics', 'r', 'utf-8') >>>> ical = icalendar.Calendar.from_string(f.read()) >Traceback (most recent call last): > File "", line 1, in > File "..../icalendar/cal.py", line 341, in from_string > for line in Contentlines.from_string(st): # raw parsing > File "..../icalendar/parser.py", line 494, in from_string > raise ValueError, 'Expected StringType with content lines' >ValueError: Expected StringType with content lines > > >Removing the error handler in parser.py shows: > > File "", line 1, in > File "..../icalendar/cal.py", line 341, in from_string > for line in Contentlines.from_string(st): # raw parsing > File "..../icalendar/parser.py", line 489, in from_string > lines = [Contentline(line) for line in unfolded.splitlines() if line] > File "..../icalendar/parser.py", line 369, in __new__ > self = str.__new__(cls, st) >UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in >position 31: ordinal not in range(128) > > >Cheers, >Mike >_______________________________________________ >icalendar-dev mailing list >icalendar-dev at codespeak.net >http://codespeak.net/mailman/listinfo/icalendar-dev From jvisinand at gmail.com Mon Aug 18 12:49:12 2008 From: jvisinand at gmail.com (Julien Visinand) Date: Mon, 18 Aug 2008 12:49:12 +0200 Subject: [icalendar-dev] vGeo bug? Message-ID: Hi, When parsing: GEO:45.9167\;6.86667 I get an ValueError: Expected 'float;float' , got: 51.9225\;4.47917 If I output a GEO with icalendar, it prints out the GEO with \;. Shouldn't you support vText formatting for this field? Thanks, -- Julien Visinand +41786299300 www.mixin.com/users/julien/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/icalendar-dev/attachments/20080818/282e5a75/attachment.htm From grant.b.edwards at gmail.com Fri Aug 22 00:45:37 2008 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 21 Aug 2008 17:45:37 -0500 Subject: [icalendar-dev] iCalendar 2.01 choking on Exchange meeting.ics w/ year 1601 Message-ID: <20080821224525.GA21180@grante> When I try to read in a meeting.ics file created by MS Exchange using Calendar.from_string(ics_text), I get an exception because the file contains years before 1900 (specifically, it contains the year 1601 in records having something to do with standard vs. daylight savings time. Here's the beginning of the meeting.ics file: BEGIN:VCALENDAR METHOD:REQUEST PRODID:Microsoft CDO for Microsoft Exchange VERSION:2.0 BEGIN:VTIMEZONE TZID:(GMT-06.00) Central Time (US & Canada) X-MICROSOFT-CDO-TZID:11 BEGIN:STANDARD DTSTART:16010101T020000 TZOFFSETFROM:-0500 TZOFFSETTO:-0600 RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=11;BYDAY=1SU END:STANDARD BEGIN:DAYLIGHT DTSTART:16010101T020000 TZOFFSETFROM:-0600 TZOFFSETTO:-0500 RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=2SU END:DAYLIGHT END:VTIMEZONE BEGIN:VEVENT DTSTAMP:20080821T212545Z DTSTART;TZID="(GMT-06.00) Central Time (US & Canada)":20080822T090000 [...] Here's the exception traceback: Traceback (most recent call last): File "./ical.py", line 10, in print cal File "/usr/lib/python2.5/site-packages/icalendar/cal.py", line 405, in __str__ return self.as_string() File "/usr/lib/python2.5/site-packages/icalendar/cal.py", line 400, in as_string return str(self.content_lines()) File "/usr/lib/python2.5/site-packages/icalendar/cal.py", line 394, in content_lines contentlines.append(Contentline.from_parts((name, params, values))) File "/usr/lib/python2.5/site-packages/icalendar/parser.py", line 375, in from_parts (name, params, values) = [str(p) for p in parts] File "/usr/lib/python2.5/site-packages/icalendar/prop.py", line 602, in __str__ return self.ical() File "/usr/lib/python2.5/site-packages/icalendar/prop.py", line 582, in ical return vDatetime(dt).ical() File "/usr/lib/python2.5/site-packages/icalendar/prop.py", line 304, in ical return self.dt.strftime("%Y%m%dT%H%M%S") ValueError: year=1601 is before 1900; the datetime strftime() methods require year >= 1900 Any ideas on how to handle this? I could just change all occurances in the .ics file of "^DT1601" to "^DT1901", but that seems a bit hackish. -- Grant Edwards grant.b.edwards at gmail.com From grant.b.edwards at gmail.com Fri Aug 22 02:41:15 2008 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 21 Aug 2008 19:41:15 -0500 Subject: [icalendar-dev] iCalendar 2.01 choking on Exchange meeting.ics w/ year 1601 In-Reply-To: <20080821224525.GA21180@grante> References: <20080821224525.GA21180@grante> Message-ID: <20080822004114.GA6559@grante.dsl.visi.com> On Thu, Aug 21, 2008 at 05:45:37PM -0500, Grant Edwards wrote: > When I try to read in a meeting.ics file created by MS Exchange > using Calendar.from_string(ics_text), I get an exception > because the file contains years before 1900 (specifically, it > contains the year 1601 in records having something to do with > standard vs. daylight savings time. Here's the beginning of > the meeting.ics file: > DTSTART:16010101T020000 > DTSTART:16010101T020000 > [...] > Any ideas on how to handle this? I could just change all > occurances in the .ics file of "^DT1601" to "^DT1901", but that > seems a bit hackish. This makes it work... ics_text = ics_text.replace("\nDTSTART:1601","\nDTSTART:1901") -- Grant From grant.b.edwards at gmail.com Fri Aug 22 15:51:04 2008 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Fri, 22 Aug 2008 08:51:04 -0500 Subject: [icalendar-dev] iCalendar 2.01 choking on Exchange meeting.ics w/ year 1601 In-Reply-To: <48AE6E6A.5040508@mxm.dk> References: <20080821224525.GA21180@grante> <48AE6E6A.5040508@mxm.dk> Message-ID: <20080822135103.GA7797@grante> On Fri, Aug 22, 2008 at 09:44:42AM +0200, Max M wrote: > Grant Edwards skrev: > >> ValueError: year=1601 is before 1900; the datetime strftime() methods >> require year >= 1900 >> Any ideas on how to handle this? I could just change all >> occurances in the .ics file of "^DT1601" to "^DT1901", but that >> seems a bit hackish. > > As far as I remember it is a limitation with microsofts > implementation of the c library. It's a limitation of Python's DateTime module. > It will probably work in *nix. It won't. The failure I observed is on Gentoo Linux. A lower limit of year 1900 is part of the DateTime module: http://docs.python.org/lib/strftime-behavior.html#strftime-behavior The exact range of years for which strftime() works also varies across platforms. Regardless of platform, years before 1900 cannot be used. > Doing a string replace is an acceptable workaround and not > likely to break. I agree, but it seems like something that ought to be fixed in the library: 1) There's nothing in RFC 2445 that requires year values to be greater than 1900. 2) MS Exchange is probably one of the most widely deployed VCALENDAR applications, and it produces year values < 1900. Before calling strftime, the library should probably limit the input string value to values that are within the DateTime modules limits. I could submit a patch if desired... -- Grant From regebro at gmail.com Fri Aug 29 19:59:23 2008 From: regebro at gmail.com (Lennart Regebro) Date: Fri, 29 Aug 2008 19:59:23 +0200 Subject: [icalendar-dev] icalendar UTF-8 troubles In-Reply-To: <20080818052336.GC9966@devsuki.com> References: <20080818052336.GC9966@devsuki.com> Message-ID: <319e029f0808291059j30d0848esf7a8218886f65224@mail.gmail.com> On Mon, Aug 18, 2008 at 07:23, Matt Chisholm wrote: > Wow. I just read through the iCalendar spec, and it says almost nothing about > how to encode non-ASCII. I'm pretty sure it' explicitly says you HAVE to use UTF-8. Always. -- Lennart Regebro: Zope and Plone consulting. http://www.colliberty.com/ +33 661 58 14 64 From regebro at gmail.com Fri Aug 29 20:04:08 2008 From: regebro at gmail.com (Lennart Regebro) Date: Fri, 29 Aug 2008 20:04:08 +0200 Subject: [icalendar-dev] icalendar UTF-8 troubles In-Reply-To: References: Message-ID: <319e029f0808291104j3644153ew5623c595c264582f@mail.gmail.com> On Sat, Aug 16, 2008 at 19:48, Michael Macnair wrote: >>>> import codecs >>>> f = codecs.open('utf8.ics', 'r', 'utf-8') This is unessecary. All icalendar files are UTF8. Just open it. >>> import icalendar >>> f = open('utf8.ics') >>> icalendar.Calendar.from_string(f.read()) -- Lennart Regebro: Zope and Plone consulting. http://www.colliberty.com/ +33 661 58 14 64 From regebro at gmail.com Fri Aug 29 20:07:26 2008 From: regebro at gmail.com (Lennart Regebro) Date: Fri, 29 Aug 2008 20:07:26 +0200 Subject: [icalendar-dev] iCalendar 2.01 choking on Exchange meeting.ics w/ year 1601 In-Reply-To: <20080822135103.GA7797@grante> References: <20080821224525.GA21180@grante> <48AE6E6A.5040508@mxm.dk> <20080822135103.GA7797@grante> Message-ID: <319e029f0808291107n14f91c0bsda0c93081a7c09fa@mail.gmail.com> On Fri, Aug 22, 2008 at 15:51, Grant Edwards wrote: > 2) MS Exchange is probably one of the most widely deployed > VCALENDAR applications, and it produces year values < 1900. How weird. > Before calling strftime, the library should probably limit the > input string value to values that are within the DateTime > modules limits. > > I could submit a patch if desired... Please do. -- Lennart Regebro: Zope and Plone consulting. http://www.colliberty.com/ +33 661 58 14 64 From Grant.B.Edwards at gmail.com Fri Aug 29 20:19:36 2008 From: Grant.B.Edwards at gmail.com (Grant Edwards) Date: Fri, 29 Aug 2008 13:19:36 -0500 Subject: [icalendar-dev] iCalendar 2.01 choking on Exchange meeting.ics w/ year 1601 In-Reply-To: <319e029f0808291107n14f91c0bsda0c93081a7c09fa@mail.gmail.com> References: <20080821224525.GA21180@grante> <48AE6E6A.5040508@mxm.dk> <20080822135103.GA7797@grante> <319e029f0808291107n14f91c0bsda0c93081a7c09fa@mail.gmail.com> Message-ID: <20080829181936.GA1632@grante.homeip.net> On Fri, Aug 29, 2008 at 08:07:26PM +0200, Lennart Regebro wrote: > On Fri, Aug 22, 2008 at 15:51, Grant Edwards wrote: > > 2) MS Exchange is probably one of the most widely deployed > > VCALENDAR applications, and it produces year values < 1900. > > How weird. I could be a quirk in the way that particular server is configured. It's the only Exchange server to which I have access, so I don't know if they all do the same thing or not. > > Before calling strftime, the library should probably limit the > > input string value to values that are within the DateTime > > modules limits. > > > > I could submit a patch if desired... > > Please do. I'll start working on it. -- Grant Edwards grant.b.edwards at gmail.com From Jaggojaggo+Py at gmail.com Sat Aug 30 23:33:40 2008 From: Jaggojaggo+Py at gmail.com (OmerT) Date: Sun, 31 Aug 2008 00:33:40 +0300 Subject: [icalendar-dev] "Expected [-3], read [10]" error at Google Message-ID: <515008f10808301433x5ad2bb06v3e211b9e995de7f7@mail.gmail.com> Hello! (Here's for hoping this list is still active,) I'm attempting to write a script that generates an iCal file, to be published on the Google Calendar. Although it sometimes works, on other times I get a strange error message: Failed to import events: Unable to process your iCal/CSV file. The file is not properly formatted.. Error at line 76: Expected [-3], read [10] Line 76 contains the DTSTART part of an event line. I tried manually removing the ending T from the date. I tried to shuffle around the lines inside the event: Google kept claiming the error is on line 76. I need to stress that this doesn't always happen: more like once every 5, 6 events. Has anyone any idea what can I do to solve this? Thank you, Omer. From regebro at gmail.com Sun Aug 31 07:56:25 2008 From: regebro at gmail.com (Lennart Regebro) Date: Sun, 31 Aug 2008 07:56:25 +0200 Subject: [icalendar-dev] "Expected [-3], read [10]" error at Google In-Reply-To: <515008f10808301433x5ad2bb06v3e211b9e995de7f7@mail.gmail.com> References: <515008f10808301433x5ad2bb06v3e211b9e995de7f7@mail.gmail.com> Message-ID: <319e029f0808302256v593e130qa27c36d170aa0851@mail.gmail.com> On Sat, Aug 30, 2008 at 23:33, OmerT wrote: > I'm attempting to write a script that generates an iCal file, to be > published on the Google Calendar. You probably need to ask some google calendar users what that error message actually means, because it makes absolutely no sense to me. -- Lennart Regebro: Zope and Plone consulting. http://www.colliberty.com/ +33 661 58 14 64 From Jaggojaggo+Py at gmail.com Sun Aug 31 07:58:31 2008 From: Jaggojaggo+Py at gmail.com (OmerT) Date: Sun, 31 Aug 2008 08:58:31 +0300 Subject: [icalendar-dev] "Expected [-3], read [10]" error at Google In-Reply-To: <319e029f0808302256v593e130qa27c36d170aa0851@mail.gmail.com> References: <515008f10808301433x5ad2bb06v3e211b9e995de7f7@mail.gmail.com> <319e029f0808302256v593e130qa27c36d170aa0851@mail.gmail.com> Message-ID: <515008f10808302258v4bac0965yecc3ebe12c360cb4@mail.gmail.com> Alright, Thank you for the response. Have you [or has anyone here] got any experience in successful Google-Calendar integration? Omer On Sun, Aug 31, 2008 at 8:56 AM, Lennart Regebro wrote: > On Sat, Aug 30, 2008 at 23:33, OmerT wrote: >> I'm attempting to write a script that generates an iCal file, to be >> published on the Google Calendar. > > You probably need to ask some google calendar users what that error > message actually means, because it makes absolutely no sense to me. > > -- > Lennart Regebro: Zope and Plone consulting. > http://www.colliberty.com/ > +33 661 58 14 64 > From regebro at gmail.com Sun Aug 31 14:38:22 2008 From: regebro at gmail.com (Lennart Regebro) Date: Sun, 31 Aug 2008 14:38:22 +0200 Subject: [icalendar-dev] "Expected [-3], read [10]" error at Google In-Reply-To: <515008f10808302258v4bac0965yecc3ebe12c360cb4@mail.gmail.com> References: <515008f10808301433x5ad2bb06v3e211b9e995de7f7@mail.gmail.com> <319e029f0808302256v593e130qa27c36d170aa0851@mail.gmail.com> <515008f10808302258v4bac0965yecc3ebe12c360cb4@mail.gmail.com> Message-ID: <319e029f0808310538t1f02e23ayb6c2df682585a357@mail.gmail.com> On Sun, Aug 31, 2008 at 07:58, OmerT wrote: > Alright, > Thank you for the response. > > Have you [or has anyone here] got any experience in successful > Google-Calendar integration? I have imported ics files created with icalendar into google calendar, yes. It just worked. -- Lennart Regebro: Zope and Plone consulting. http://www.colliberty.com/ +33 661 58 14 64