ObjectNotSupported is now an assertion
This commit is contained in:
parent
7df5136b5f
commit
d81f5dac7a
3 changed files with 5 additions and 10 deletions
|
|
@ -23,7 +23,7 @@ from optparse import OptionGroup, OptionParser
|
|||
|
||||
from weboob.core.ouiboube import Weboob
|
||||
from weboob.tools.config.iconfig import ConfigError
|
||||
from weboob.tools.backend import ObjectNotAvailable, ObjectNotSupported
|
||||
from weboob.tools.backend import ObjectNotAvailable
|
||||
from weboob.tools.misc import iter_fields
|
||||
|
||||
|
||||
|
|
@ -201,7 +201,7 @@ class BaseApplication(object):
|
|||
fields = [k for k, v in iter_fields(obj)]
|
||||
try:
|
||||
backend.fillobj(obj, fields)
|
||||
except (ObjectNotAvailable, ObjectNotSupported), e:
|
||||
except ObjectNotAvailable, e:
|
||||
logging.warning(u'Could not retrieve required fields (%s): %s' % (','.join(fields), e))
|
||||
return obj
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import sys
|
|||
|
||||
from weboob.core import CallErrors
|
||||
from weboob.core.backends import BackendsConfig
|
||||
from weboob.tools.backend import ObjectNotSupported
|
||||
|
||||
from .base import BackendNotFound, BaseApplication
|
||||
from .formatters.load import formatters, load_formatter
|
||||
|
|
|
|||
|
|
@ -24,17 +24,13 @@ from logging import debug
|
|||
from weboob.capabilities.base import IBaseCap, NotLoaded
|
||||
|
||||
|
||||
__all__ = ['BaseBackend', 'ObjectNotAvailable', 'ObjectNotSupported']
|
||||
__all__ = ['BaseBackend', 'ObjectNotAvailable']
|
||||
|
||||
|
||||
class ObjectNotAvailable(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class ObjectNotSupported(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class BackendStorage(object):
|
||||
def __init__(self, name, storage):
|
||||
self.name = name
|
||||
|
|
@ -222,9 +218,9 @@ class BaseBackend(object):
|
|||
if not missing_fields:
|
||||
return obj
|
||||
|
||||
assert obj in self.OBJECTS, 'The object of type %s is not supported by the backend %s' % (type(obj), self)
|
||||
|
||||
for key, value in self.OBJECTS.iteritems():
|
||||
if isinstance(obj, key):
|
||||
debug(u'Fill %r with fields: %s' % (obj, missing_fields))
|
||||
return value(self, obj, missing_fields) or obj
|
||||
|
||||
raise ObjectNotSupported('The object of type %s is not supported by the backend %s' % (type(obj), self))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue