emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: KANEUCHI Tetsuya <kaneuchi@gmail.com>
To: Doug Hellmann <doug.hellmann@gmail.com>
Cc: Emacs Org-mode <emacs-orgmode@gnu.org>
Subject: Re: Introducing ical2org
Date: Sun, 7 Mar 2010 08:49:25 +0900	[thread overview]
Message-ID: <7bccba0d1003061549t6d27465n3c901b7bd6aaba2e@mail.gmail.com> (raw)
In-Reply-To: <6872D211-111B-445C-8592-CA2C9DDAE927@gmail.com>

Hi Doug,

On Sat, Feb 13, 2010 at 11:52 PM, Doug Hellmann <doug.hellmann@gmail.com> 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 <module>
    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 <module>
    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

      parent reply	other threads:[~2010-03-06 23:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-13 14:52 Introducing ical2org Doug Hellmann
2010-02-16  4:53 ` Carsten Dominik
2010-03-06 23:49 ` KANEUCHI Tetsuya [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7bccba0d1003061549t6d27465n3c901b7bd6aaba2e@mail.gmail.com \
    --to=kaneuchi@gmail.com \
    --cc=doug.hellmann@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).