Permalink
Browse files

Merge pull request #1 from jag3773/master

Added support for excludes
  • Loading branch information...
2 parents b482978 + e5fd43b commit ee99076cb59a62e0c2debd9bcf71dd35a16cb0b3 Sean Reifschneider committed Dec 17, 2011
Showing with 19 additions and 1 deletion.
  1. +3 −0 README
  2. +2 −0 excludes-example
  3. +14 −1 gnome-shell-google-calendar.py
View
@@ -29,6 +29,9 @@
Once logged in, events from all your calendars should appear in
GNOME Shell's calendar.
+
+ To exclude calendars, create a file named "excludes" and put one calendar
+ title per line.
~ Future
View
@@ -0,0 +1,2 @@
+Title of Excluded Calendar 1
+Title of Excluded Calendar 2
@@ -13,6 +13,7 @@
import iso8601
import keyring
import calendar
+import os
# change to "True" to get debugging messages
@@ -57,7 +58,6 @@ def get_month_key(date, first_day_of_week=7):
return ( int(mktime(start_date.timetuple())),
int(mktime(end_date.timetuple())) )
-
class MonthEvents(object):
"""
Caches events of month
@@ -225,9 +225,20 @@ def scheduler(self, timeout):
else:
print 'No need for update'
+ def get_excludes(self, filename):
+ '''Gets a list of calendars to exclude'''
+ excludes = []
+ if os.access(filename, os.F_OK):
+ for line in open(filename, 'r'):
+ excludes.append(line.strip())
+ return excludes
+
def get_calendars(self):
feed = self.client.GetAllCalendarsFeed()
+ # Load excluded calendars from excludes file
+ excludes = self.get_excludes('%s/excludes' % os.getcwd())
+
calendars = []
urls = set()
@@ -237,6 +248,8 @@ def get_calendars(self):
title = calendar.title.text
url = calendar.content.src
+ if title in excludes: continue
+
if not url in urls:
print ' ', title
if debug: print ' ', url

0 comments on commit ee99076

Please sign in to comment.