Felix Geller avatar Felix Geller committed 88b7cd0

Update documention for new featrues, provide examples.

Comments (0)

Files changed (1)

 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 #
-# Queries Google Calendar for entries in that are at most 30 days in
-# the past or future, then prints each entry into a org-entry to a
-# given file.
+# There are two main usages:
+# - updating a the title of a single event in default calendar,
+# - downloading calendar entries for a given calendar that are at most
+#   30 days in the past or future and printing them as a org-entry to
+#   a given file.
+#
+# The first is mainly useful for me, or rather how I use org-mode. I
+# use it in connection with the following ELisp snippet to update
+# tasks from TODO to DONE. If I toggle the TODO state of an entry and
+# if it has a property named GCalId, this script is invoked to publish
+# the new title.
+#
+# (defun fg/publish-state-entry-state-change-to-gcal ()
+#   (let ((new-title (org-get-heading))
+# 	(gcal-id (org-entry-get nil "GCalId")))
+#     (when gcal-id
+#       (start-process 
+#        "push2gcal" "*push2gcal*" 
+#        "gcal2org.py" "me@gmail.com" "update" gcal-id "text" new-title))))
+# (add-hook 'org-after-todo-state-change-hook
+# 	  'fg/publish-state-entry-state-change-to-gcal) 
+#
+# Invoke without arguments for usage examples. Or scroll down.
 #
 # N.B.: Uses authinfo_pw to retrieve a password from an encrypted
 # file. Please change this according to your preferences.
 #
-# Usage:
-#  > gcal2org.py email@gmail.com org-file
+# Acknowledgment: Thanks to Rasmus for adding the capability of
+# specifying other calendar URIs.
 
 import gdata.calendar.client
 from datetime import date, datetime, timedelta
 from time import strftime, strptime, mktime, localtime, sleep
 import sys, re, os, getopt
 
+
+USAGE = """Download default calendar:
+ > gcal2org.py download me@gmail.com file.org
+
+Download other (kitty's) calendar:
+ > gcal2org.py download me@gmail.com file.org "http://www.google.com/calendar/feeds/kitty@gmail.com/private/full/"
+
+Update single event:
+ > gcal2org.py me@gmail.com update strange-event-id title new-title"""
+
 EVENT_URI_PREFIX = 'http://www.google.com/calendar/feeds/default/private/full/'
 
 PREAMBLE = """#+STARTUP: overview
       fields[fs[i]] = fs[i+1]
   return fields
 
-def print_usage(msg):
-  print >>sys.stderr, msg
-  print >>sys.stderr, 'Please invoke script w/o args for general usage info.'
-
 def main(retry_count=5):
   try:
-    if 4 > len(sys.argv): raise Usage('Please supply at least 3 args')
+    if 4 > len(sys.argv): raise Usage(USAGE)
     else:
       client = create_calendar_client(sys.argv[1])
       op = sys.argv[2]
       else: raise Usage('Operation "%s" not supported.' % op)
 
   except Usage, err:
-     return print_usage(err.msg)
+    print >>sys.stderr, msg
+    return 2
   except gdata.client.RedirectError, err:
     if retry_count > 0:
       print >>sys.stderr, ("gcal2org: Retry #%s" % (5 - retry_count))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.