From mboxrd@z Thu Jan 1 00:00:00 1970 From: KANEUCHI Tetsuya Subject: Re: Introducing ical2org Date: Sun, 7 Mar 2010 08:49:25 +0900 Message-ID: <7bccba0d1003061549t6d27465n3c901b7bd6aaba2e@mail.gmail.com> References: <6872D211-111B-445C-8592-CA2C9DDAE927@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1No3kQ-0006AF-1z for emacs-orgmode@gnu.org; Sat, 06 Mar 2010 18:49:30 -0500 Received: from [140.186.70.92] (port=38794 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1No3kP-00069I-0g for emacs-orgmode@gnu.org; Sat, 06 Mar 2010 18:49:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1No3kN-0007KJ-7l for emacs-orgmode@gnu.org; Sat, 06 Mar 2010 18:49:28 -0500 Received: from mail-vw0-f41.google.com ([209.85.212.41]:43989) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1No3kN-0007KC-4i for emacs-orgmode@gnu.org; Sat, 06 Mar 2010 18:49:27 -0500 Received: by vws4 with SMTP id 4so291099vws.0 for ; Sat, 06 Mar 2010 15:49:25 -0800 (PST) In-Reply-To: <6872D211-111B-445C-8592-CA2C9DDAE927@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Doug Hellmann Cc: Emacs Org-mode Hi Doug, On Sat, Feb 13, 2010 at 11:52 PM, Doug Hellmann wrote: > ical2org is a command line tool for exporting data from the Mac OS X > application iCal so it can be used with org-mode. Thank you very much for the very nice tool. I've tried ical2org by installing with MacPorts' pip for Python 2.6 and found 2 problems. And I made a patch for avoiding them for me. 1) Running without -o option, UnicodeEncodeError with non-ascii events. Here is the traceback output. Traceback (most recent call last): File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/ical2org", line 8, in load_entry_point('ical2org==1.0.2', 'console_scripts', 'ical2org')() File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ical2org/app.py", line 183, in main formatter.add_event(event) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ical2org/format.py", line 54, in add_event self.output.write(self.format_event(event)) UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-32: ordinal not in range(128) 2) List index out of range error for description handling(I guess). Here is the traceback output. Traceback (most recent call last): File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/ical2org", line 8, in load_entry_point('ical2org==1.0.2', 'console_scripts', 'ical2org')() File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ical2org/app.py", line 183, in main formatter.add_event(event) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ical2org/format.py", line 54, in add_event self.output.write(self.format_event(event)) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ical2org/org.py", line 63, in format_event lines.append(' - %s' % desc_lines[0]) IndexError: list index out of range ==== It's a patch to avoid these problems. It works for me. diff -u orig/app.py ./app.py --- orig/app.py 2010-03-07 07:29:17.000000000 +0900 +++ ./app.py 2010-03-07 08:19:51.000000000 +0900 @@ -167,7 +167,7 @@ active_only=options.active_only) # Process the calendar data - output = sys.stdout + output = codecs.getwriter('utf-8')(sys.stdout) if options.output_file_name: output = codecs.open(options.output_file_name, 'wt', 'UTF-8') try: Binary files orig/app.pyc and ./app.pyc differ diff -u orig/org.py ./org.py --- orig/org.py 2010-03-07 07:31:49.000000000 +0900 +++ ./org.py 2010-03-07 08:25:27.000000000 +0900 @@ -60,8 +60,9 @@ # Unicode error for PyATL calendar events. if getattr(event, 'description', None): desc_lines = event.description.value.splitlines() - lines.append(' - %s' % desc_lines[0]) - lines.extend([ ' %s' % l for l in desc_lines[1:]]) + if len(desc_lines) > 0: + lines.append(' - %s' % desc_lines[0]) + lines.extend([ ' %s' % l for l in desc_lines[1:]]) lines.append('') return '\n'.join(lines) I hope this helps. -- KANEUCHI Tetsuya