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.
|
# 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]
|
||||||
|
|
|
||||||
|
|
@ -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,31 +35,27 @@ 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
|
|
||||||
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={}):
|
class StandardStorage(IStorage):
|
||||||
d = {}
|
def __init__(self, path):
|
||||||
if not what in self.config.values:
|
self.config = YamlConfig(path)
|
||||||
self.config.values[what] = {}
|
self.config.load()
|
||||||
else:
|
|
||||||
d = self.config.values[what].get(name, {})
|
|
||||||
|
|
||||||
self.config.values[what][name] = deepcopy(default)
|
def load(self, what, name, default={}):
|
||||||
self.config.values[what][name].update(d)
|
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.values[what][name] = deepcopy(default)
|
||||||
self.config.save()
|
self.config.values[what][name].update(d)
|
||||||
|
|
||||||
def set(self, what, name, *args):
|
def save(self, what, name):
|
||||||
self.config.set(what, name, *args)
|
self.config.save()
|
||||||
|
|
||||||
def get(self, what, name, *args, **kwargs):
|
def set(self, what, name, *args):
|
||||||
return self.config.get(what, name, *args, **kwargs)
|
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