changeset 5:f11c5ed0178e

Make using tagpy optional.
author darius@inchoate.localdomain
date Mon, 12 Nov 2007 15:17:20 +1030
parents 65a9f99302cd
children bdb8597191dc
files amakode.py
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/amakode.py	Mon Nov 12 15:01:23 2007 +1030
+++ b/amakode.py	Mon Nov 12 15:17:20 2007 +1030
@@ -60,8 +60,13 @@
 import urllib
 import urlparse
 import re
-import tagpy
 
+try:
+    import tagpy
+    have_tagpy = True
+except ImportError, e:
+    have_tagpy = False
+    
 class tagpywrap(dict):
     textfields = ['album', 'artist', 'title', 'comment', 'genre']
     numfields = ['year', 'track']
@@ -191,7 +196,7 @@
             encoder += self.encode[self.tofmt]
             
             try:
-                if (self.tofmt in self.tagopt):
+                if (have_tagpy and self.tofmt in self.tagopt):
                     taginfo = tagpywrap(self.inurl)
                     for f in taginfo.allfields:
                         if (f in taginfo and f in self.tagopt[self.tofmt]):
@@ -256,7 +261,11 @@
     def __init__(self, args):
         """ Main loop waits for something to do then does it """
         log.debug("Started.")
-
+        if (have_tagpy):
+            log.debug("Using tagpy")
+        else:
+            log.debug("Warning: tagpy is unavailable")
+            
         self.readSettings()
 
         self.queue = QueueMgr(callback = self.notify, maxjobs = 1)