conduit r1904 - in trunk: . conduit/modules



Author: jstowers
Date: Mon Feb 23 21:25:25 2009
New Revision: 1904
URL: http://svn.gnome.org/viewvc/conduit?rev=1904&view=rev

Log:
2009-02-24  John Stowers  <john stowers gmail com>

	* conduit/modules/GoogleBookmarksModule.py:
	Match out coding style better.



Modified:
   trunk/ChangeLog
   trunk/conduit/modules/GoogleBookmarksModule.py

Modified: trunk/conduit/modules/GoogleBookmarksModule.py
==============================================================================
--- trunk/conduit/modules/GoogleBookmarksModule.py	(original)
+++ trunk/conduit/modules/GoogleBookmarksModule.py	Mon Feb 23 21:25:25 2009
@@ -1,20 +1,18 @@
 # Copyright 2009 - Andrew Stomont <andyjstormont googlemail com>
-
+import urllib2
+import xml.dom.minidom
 import logging
-log = logging.getLogger( "modules.GoogleBookmarks" )
+log = logging.getLogger("modules.GoogleBookmarks")
 
 import conduit
 import conduit.dataproviders.DataProvider as DataProvider
 import conduit.datatypes.Bookmark as Bookmark
 
-import urllib2
-from xml.dom.minidom import parse
-
 MODULES = {
     "GoogleBookmarksDataProviderSource" : { "type": "dataprovider" }
 }
 
-class GoogleBookmarksDataProviderSource( DataProvider.DataSource ):
+class GoogleBookmarksDataProviderSource(DataProvider.DataSource):
 
     _name_ = "Google Bookmarks"
     _description_ = "Sync your Google Bookmarks"
@@ -24,43 +22,42 @@
     _icon_ = "applications-internet"
     _configurable_ = True
 
-    def __init__( self ):
-        DataProvider.DataSource.__init__( self )
+    def __init__(self):
+        DataProvider.DataSource.__init__(self)
         self.update_configuration(
             username = "",
             password = ""
         )
-        self.Bookmarks = []
+        self._bookmarks = []
 
-    def refresh( self ):
-        DataProvider.DataSource.refresh( self )
-        self.Bookmarks = []
+    def refresh(self):
+        DataProvider.DataSource.refresh(self)
+        self._bookmarks = []
         auth_handler = urllib2.HTTPBasicAuthHandler()
-        auth_handler.add_password( 'Google Search History', 'www.google.com', self.username, self.password )
-        opener = urllib2.build_opener( auth_handler )
-        bookmark_feed = opener.open( "https://www.google.com/bookmarks/?output=rss"; )
-        for item in parse( bookmark_feed ).documentElement.getElementsByTagName( "item" ):
-            title = item.getElementsByTagName( "title" )[0].childNodes[0].data
-            link = item.getElementsByTagName( "link" )[0].childNodes[0].data
-            bookmark = Bookmark.Bookmark( title, link )
-            bookmark.set_UID( bookmark.get_hash() )
-            self.Bookmarks.append( bookmark )
-        print self.Bookmarks
+        auth_handler.add_password('Google Search History', 'www.google.com', self.username, self.password)
+        opener = urllib2.build_opener(auth_handler)
+        bookmark_feed = opener.open("https://www.google.com/bookmarks/?output=rss";)
+        for item in xml.dom.minidom.parse(bookmark_feed).documentElement.getElementsByTagName("item"):
+            title = item.getElementsByTagName("title")[0].childNodes[0].data
+            link = item.getElementsByTagName("link")[0].childNodes[0].data
+            bookmark = Bookmark.Bookmark(title, link)
+            bookmark.set_UID(bookmark.get_hash())
+            self._bookmarks.append(bookmark)
 
-    def get_all( self ):
-        DataProvider.DataSource.get_all( self )
+    def get_all(self):
+        DataProvider.DataSource.get_all(self)
         retval = []
-        for bookmark in self.Bookmarks:
-            retval.append( bookmark.get_UID() )
+        for bookmark in self._bookmarks:
+            retval.append(bookmark.get_UID())
         return retval
         
-    def get( self, luid ):
-        DataProvider.DataSource.get( self, luid )
-        for bookmark in self.Bookmarks:
+    def get(self, luid):
+        DataProvider.DataSource.get(self, luid)
+        for bookmark in self._bookmarks:
             if bookmark.get_UID() == luid:
                 return bookmark
 
-    def get_UID( self ):
+    def get_UID(self):
         return self.username
 
     def config_setup(self, config):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]