do not catch ImportError
This commit is contained in:
parent
b86e9d8a00
commit
f60c32db77
2 changed files with 30 additions and 33 deletions
|
|
@ -16,6 +16,7 @@
|
|||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
from weboob.core.backend import BaseBackend
|
||||
|
|
@ -43,11 +44,7 @@ class YoutubeBackend(BaseBackend, ICapVideo):
|
|||
return self.browser.get_video(_id)
|
||||
|
||||
def iter_search_results(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||
try:
|
||||
import gdata.youtube.service
|
||||
except ImportError:
|
||||
logging.error('Youtube backend search feature requires python-gdata package.')
|
||||
return
|
||||
import gdata.youtube.service
|
||||
yt_service = gdata.youtube.service.YouTubeService()
|
||||
query = gdata.youtube.service.YouTubeVideoQuery()
|
||||
query.orderby = ('relevance', 'rating', 'viewCount', 'published')[sortby]
|
||||
|
|
|
|||
|
|
@ -15,9 +15,13 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
from copy import deepcopy
|
||||
from logging import error
|
||||
|
||||
from .config.yamlconfig import YamlConfig
|
||||
|
||||
|
||||
class IStorage:
|
||||
def load(self, what, name, default={}):
|
||||
raise NotImplementedError()
|
||||
|
|
@ -31,31 +35,27 @@ class IStorage:
|
|||
def get(self, what, name, *args, **kwargs):
|
||||
raise NotImplementedError()
|
||||
|
||||
try:
|
||||
from .config.yamlconfig import YamlConfig
|
||||
except ImportError, e:
|
||||
error('Import error for weboob.tools.config.yamlconfig: %s' % e)
|
||||
else:
|
||||
class StandardStorage(IStorage):
|
||||
def __init__(self, path):
|
||||
self.config = YamlConfig(path)
|
||||
self.config.load()
|
||||
|
||||
def load(self, what, name, default={}):
|
||||
d = {}
|
||||
if not what in self.config.values:
|
||||
self.config.values[what] = {}
|
||||
else:
|
||||
d = self.config.values[what].get(name, {})
|
||||
class StandardStorage(IStorage):
|
||||
def __init__(self, path):
|
||||
self.config = YamlConfig(path)
|
||||
self.config.load()
|
||||
|
||||
self.config.values[what][name] = deepcopy(default)
|
||||
self.config.values[what][name].update(d)
|
||||
def load(self, what, name, default={}):
|
||||
d = {}
|
||||
if not what in self.config.values:
|
||||
self.config.values[what] = {}
|
||||
else:
|
||||
d = self.config.values[what].get(name, {})
|
||||
|
||||
def save(self, what, name):
|
||||
self.config.save()
|
||||
self.config.values[what][name] = deepcopy(default)
|
||||
self.config.values[what][name].update(d)
|
||||
|
||||
def set(self, what, name, *args):
|
||||
self.config.set(what, name, *args)
|
||||
def save(self, what, name):
|
||||
self.config.save()
|
||||
|
||||
def get(self, what, name, *args, **kwargs):
|
||||
return self.config.get(what, name, *args, **kwargs)
|
||||
def set(self, what, name, *args):
|
||||
self.config.set(what, name, *args)
|
||||
|
||||
def get(self, what, name, *args, **kwargs):
|
||||
return self.config.get(what, name, *args, **kwargs)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue