From 168046cf9864efe84e63707d853108c570b6989f Mon Sep 17 00:00:00 2001 From: Abhinav Sarkar Date: Tue, 16 Dec 2008 21:28:17 +0000 Subject: [PATCH] changed the code related to importing ElementTree to support python version > 2.5 --- src/api.py | 5 +++-- src/playlist.py | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/api.py b/src/api.py index b3f7614..2d20cb7 100644 --- a/src/api.py +++ b/src/api.py @@ -372,7 +372,7 @@ class Api(object): from datetime import datetime import md5 -import sys +import platform import time import urllib import urllib2 @@ -391,7 +391,8 @@ from tasteometer import Tasteometer from track import Track from user import User -if sys.version.startswith('2.5'): +python_version = platform.python_version_tuple() +if python_version[0] == 2 and python_version[1] >= 5: import xml.etree.cElementTree as ElementTree else: try: diff --git a/src/playlist.py b/src/playlist.py index d26e635..caff9a8 100644 --- a/src/playlist.py +++ b/src/playlist.py @@ -50,10 +50,11 @@ class Playlist(LastfmBase): return "" % self.url import StringIO -import sys +import platform from error import LastfmInvalidParametersError -if sys.version.startswith('2.5'): +python_version = platform.python_version_tuple() +if python_version[0] == 2 and python_version[1] >= 5: import xml.etree.cElementTree as ElementTree else: try: @@ -62,4 +63,5 @@ else: try: import ElementTree except ImportError: + from error import LastfmError raise LastfmError("Install ElementTree package for using python-lastfm") \ No newline at end of file