[rhythmbox/wip/python3] various python3 fixes



commit 49fc56b22dbd017225f18666d8e989324b59f0b9
Author: Jonathan Matthew <jonathan d14n org>
Date:   Mon Apr 15 22:09:48 2013 +1000

    various python3 fixes

 plugins/artsearch/musicbrainz.py     | 5 +++--
 plugins/context/AlbumTab.py          | 6 +++---
 plugins/context/ArtistTab.py         | 4 ++--
 plugins/context/ContextView.py       | 2 +-
 plugins/context/LinksTab.py          | 8 ++++----
 plugins/context/LyricsTab.py         | 2 +-
 plugins/context/tmpl/album-tmpl.html | 4 ++--
 plugins/magnatune/MagnatuneSource.py | 8 ++++----
 plugins/rbzeitgeist/rbzeitgeist.py   | 4 ++--
 9 files changed, 22 insertions(+), 21 deletions(-)
---
diff --git a/plugins/artsearch/musicbrainz.py b/plugins/artsearch/musicbrainz.py
index 41ff232..077c51b 100644
--- a/plugins/artsearch/musicbrainz.py
+++ b/plugins/artsearch/musicbrainz.py
@@ -26,7 +26,8 @@
 
 import xml.dom.minidom as dom
 
-import rb, urllib
+import urllib.parse
+import rb
 from gi.repository import RB
 
 # musicbrainz URLs
@@ -97,7 +98,7 @@ class MusicBrainzSearch(object):
                        return
 
                query = MUSICBRAINZ_SEARCH_QUERY % (artist.lower(), album.lower())
-               url = MUSICBRAINZ_SEARCH_URL % (urllib.quote(query, safe=':'),)
+               url = MUSICBRAINZ_SEARCH_URL % (urllib.parse.quote(query, safe=':'),)
 
                loader = rb.Loader()
                loader.get_url(url, self.get_release_cb, (key, store, callback, args))
diff --git a/plugins/context/AlbumTab.py b/plugins/context/AlbumTab.py
index ac66bb1..7d24f97 100644
--- a/plugins/context/AlbumTab.py
+++ b/plugins/context/AlbumTab.py
@@ -176,7 +176,7 @@ class AlbumDataSource (GObject.GObject):
             return
 
         self.artist = artist
-        qartist = urllib.quote_plus (artist)
+        qartist = urllib.parse.quote_plus(artist)
         self.error  = None
         url = "%sartist.gettopalbums&artist=%s&api_key=%s" % (LastFM.URL_PREFIX,
                                                               qartist,
@@ -225,8 +225,8 @@ class AlbumDataSource (GObject.GObject):
         return self.albums
 
     def fetch_album_info (self, artist, album, index):
-        qartist = urllib.quote_plus (artist)
-        qalbum = urllib.quote_plus (album.encode('utf-8'))
+        qartist = urllib.parse.quote_plus(artist)
+        qalbum = urllib.parse.quote_plus(album.encode('utf-8'))
         cachekey = "lastfm:album:getinfo:%s:%s" % (qartist, qalbum)
         url = "%salbum.getinfo&artist=%s&album=%s&api_key=%s" % (LastFM.URL_PREFIX,
                                                                  qartist,
diff --git a/plugins/context/ArtistTab.py b/plugins/context/ArtistTab.py
index a333f42..77a6de9 100644
--- a/plugins/context/ArtistTab.py
+++ b/plugins/context/ArtistTab.py
@@ -212,7 +212,7 @@ class ArtistDataSource (GObject.GObject):
         if LastFM.user_has_account() is False:
             return
 
-        artist = urllib.quote_plus (artist)
+        artist = urllib.parse.quote_plus(artist)
         function = self.artist['top_tracks']['function']
         cache = self.artist['top_tracks']['cache']
         cachekey = "lastfm:artist:%s:%s" % (function, artist)
@@ -234,7 +234,7 @@ class ArtistDataSource (GObject.GObject):
             return
 
         self.error = None
-        artist = urllib.quote_plus (artist)
+        artist = urllib.parse.quote_plus(artist)
         for key, value in self.artist.items():
             cachekey = "lastfm:artist:%s:%s" % (value['function'], artist)
             url = '%sartist.%s&artist=%s&api_key=%s' % (LastFM.URL_PREFIX,
diff --git a/plugins/context/ContextView.py b/plugins/context/ContextView.py
index 86bcb42..b1c9c71 100644
--- a/plugins/context/ContextView.py
+++ b/plugins/context/ContextView.py
@@ -186,7 +186,7 @@ class ContextView (GObject.GObject):
     def playing_changed_cb (self, playing, user_data):
         # this sometimes happens on a streaming thread, so we need to
         # move it to the main thread
-        GObject.idle_add (self.playing_changed_idle_cb)
+        GLib.idle_add (self.playing_changed_idle_cb)
 
     def playing_changed_idle_cb (self):
         if self.sp is None:
diff --git a/plugins/context/LinksTab.py b/plugins/context/LinksTab.py
index 7fd42c4..ff1e28c 100644
--- a/plugins/context/LinksTab.py
+++ b/plugins/context/LinksTab.py
@@ -26,7 +26,7 @@
 
 import os
 import cgi
-import urllib
+import urllib.request, urllib.parse
 import rb
 
 from gi.repository import GObject, Gtk
@@ -100,7 +100,7 @@ class LinksView (GObject.GObject):
         self.file     = ""
 
         plugindir = plugin.plugin_info.get_data_dir()
-        self.basepath = "file://" + urllib.pathname2url (plugindir)
+        self.basepath = "file://" + urllib.request.pathname2url(plugindir)
 
     def load_links (self, ds):
         print("Loading links into webview")
@@ -152,7 +152,7 @@ class LinksDataSource (GObject.GObject):
         artist = self.get_artist()
         if artist is not "" and artist is not None:
             wpartist = artist.replace(" ", "_")
-            artist = urllib.quote_plus (artist)
+            artist = urllib.parse.quote_plus(artist)
             artist_links = {
                 "Wikipedia" : "http://www.wikipedia.org/wiki/%s"; % wpartist,
                 "Discogs"  : "http://www.discogs.com/artist/%s"; % artist,
@@ -169,7 +169,7 @@ class LinksDataSource (GObject.GObject):
         album = self.get_album()
         if album is not "" and album is not None:
             wpalbum = album.replace(" ", "_")
-            album = urllib.quote_plus (album)
+            album = urllib.parse.quote_plus(album)
             album_links = {
                 "Wikipedia" : "http://www.wikipedia.org/wiki/%s"; % wpalbum,
                 "Discogs" : "http://www.discogs.com/search?type=album&q=%s&f=html"; % album,
diff --git a/plugins/context/LyricsTab.py b/plugins/context/LyricsTab.py
index 4fed759..7aa0bae 100644
--- a/plugins/context/LyricsTab.py
+++ b/plugins/context/LyricsTab.py
@@ -87,7 +87,7 @@ class LyricsView (GObject.GObject):
         self.plugin  = plugin
         self.file    = ""
         plugindir = plugin.plugin_info.get_data_dir()
-        self.basepath = "file://" + urllib.pathname2url (plugindir)
+        self.basepath = "file://" + urllib.request.pathname2url(plugindir)
 
         self.load_tmpl ()
         self.connect_signals ()
diff --git a/plugins/context/tmpl/album-tmpl.html b/plugins/context/tmpl/album-tmpl.html
index 2a27d39..90b736a 100644
--- a/plugins/context/tmpl/album-tmpl.html
+++ b/plugins/context/tmpl/album-tmpl.html
@@ -3,7 +3,7 @@
 <%!
     import re
     import cgi
-    import rfc822
+    import email.utils
     from gettext import ngettext
 
     def cleanup(text):
@@ -22,7 +22,7 @@
 
     def format_year(date):
         try:
-            parsed = rfc822.parsedate(date)
+            parsed = email.utils.parsedate(date)
         except Exception as e:
             return ""
         if parsed is None:
diff --git a/plugins/magnatune/MagnatuneSource.py b/plugins/magnatune/MagnatuneSource.py
index 3e9bb9b..774eaa0 100644
--- a/plugins/magnatune/MagnatuneSource.py
+++ b/plugins/magnatune/MagnatuneSource.py
@@ -69,7 +69,7 @@ class MagnatuneSource(RB.BrowserSource):
                # source state
                self.__activated = False
                self.__db = None
-               self.__notify_id = 0 # GObject.idle_add id for status notifications
+               self.__notify_id = 0 # GLib.idle_add id for status notifications
                self.__info_screen = None # the loading screen
 
                # track data
@@ -80,7 +80,7 @@ class MagnatuneSource(RB.BrowserSource):
                # catalogue stuff
                self.__updating = True # whether we're loading the catalog right now
                self.__has_loaded = False # whether the catalog has been loaded yet
-               self.__update_id = 0 # GObject.idle_add id for catalog updates
+               self.__update_id = 0 # GLib.idle_add id for catalog updates
                self.__catalogue_loader = None
                self.__catalogue_check = None
                self.__load_progress = (0, 0) # (complete, total)
@@ -157,11 +157,11 @@ class MagnatuneSource(RB.BrowserSource):
 
        def do_delete_thyself(self):
                if self.__update_id != 0:
-                       GObject.source_remove(self.__update_id)
+                       GLib.source_remove(self.__update_id)
                        self.__update_id = 0
 
                if self.__notify_id != 0:
-                       GObject.source_remove(self.__notify_id)
+                       GLib.source_remove(self.__notify_id)
                        self.__notify_id = 0
 
                if self.__catalogue_loader is not None:
diff --git a/plugins/rbzeitgeist/rbzeitgeist.py b/plugins/rbzeitgeist/rbzeitgeist.py
index d9f0973..984fd5b 100644
--- a/plugins/rbzeitgeist/rbzeitgeist.py
+++ b/plugins/rbzeitgeist/rbzeitgeist.py
@@ -91,7 +91,7 @@ class ZeitgeistPlugin(GObject.Object, Peas.Activatable):
             self.send_to_zeitgeist_async(entry, Interpretation.ACCESS_EVENT)
 
         self.__current_song = entry
-        GObject.idle_add(self.reset_manual_switch)
+        GLib.idle_add(self.reset_manual_switch)
 
     def reset_manual_switch(self):
         """
@@ -111,7 +111,7 @@ class ZeitgeistPlugin(GObject.Object, Peas.Activatable):
         """
        shell = self.object
         db = shell.props.db
-        GObject.idle_add(self.send_to_zeitgeist, db, entry, event_type)
+        GLib.idle_add(self.send_to_zeitgeist, db, entry, event_type)
 
     def send_to_zeitgeist(self, db, entry, event_type):
         song = self.get_song_info(db, entry)


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