do not catch ImportError

This commit is contained in:
Christophe Benz 2010-07-10 21:54:59 +02:00
commit f60c32db77
2 changed files with 30 additions and 33 deletions

View file

@ -16,6 +16,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import datetime
import logging import logging
from weboob.core.backend import BaseBackend from weboob.core.backend import BaseBackend
@ -43,11 +44,7 @@ class YoutubeBackend(BaseBackend, ICapVideo):
return self.browser.get_video(_id) return self.browser.get_video(_id)
def iter_search_results(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False): def iter_search_results(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
try:
import gdata.youtube.service import gdata.youtube.service
except ImportError:
logging.error('Youtube backend search feature requires python-gdata package.')
return
yt_service = gdata.youtube.service.YouTubeService() yt_service = gdata.youtube.service.YouTubeService()
query = gdata.youtube.service.YouTubeVideoQuery() query = gdata.youtube.service.YouTubeVideoQuery()
query.orderby = ('relevance', 'rating', 'viewCount', 'published')[sortby] query.orderby = ('relevance', 'rating', 'viewCount', 'published')[sortby]

View file

@ -15,9 +15,13 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from copy import deepcopy from copy import deepcopy
from logging import error from logging import error
from .config.yamlconfig import YamlConfig
class IStorage: class IStorage:
def load(self, what, name, default={}): def load(self, what, name, default={}):
raise NotImplementedError() raise NotImplementedError()
@ -31,12 +35,8 @@ class IStorage:
def get(self, what, name, *args, **kwargs): def get(self, what, name, *args, **kwargs):
raise NotImplementedError() raise NotImplementedError()
try:
from .config.yamlconfig import YamlConfig class StandardStorage(IStorage):
except ImportError, e:
error('Import error for weboob.tools.config.yamlconfig: %s' % e)
else:
class StandardStorage(IStorage):
def __init__(self, path): def __init__(self, path):
self.config = YamlConfig(path) self.config = YamlConfig(path)
self.config.load() self.config.load()