set not loaded fields to NotAvailable
This commit is contained in:
parent
d27b28d24e
commit
87f34c1961
2 changed files with 14 additions and 9 deletions
|
|
@ -18,7 +18,20 @@
|
||||||
|
|
||||||
from weboob.tools.misc import iter_fields
|
from weboob.tools.misc import iter_fields
|
||||||
|
|
||||||
__all__ = ['IBaseCap', 'NotLoaded', 'LoadingError', 'CapBaseObject']
|
|
||||||
|
__all__ = ['IBaseCap', 'NotAvailable', 'NotLoaded', 'CapBaseObject']
|
||||||
|
|
||||||
|
|
||||||
|
class NotAvailableMeta(type):
|
||||||
|
def __str__(self):
|
||||||
|
return unicode(self).decode('utf-8')
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return u'Not available'
|
||||||
|
|
||||||
|
|
||||||
|
class NotAvailable(object):
|
||||||
|
__metaclass__ = NotAvailableMeta
|
||||||
|
|
||||||
|
|
||||||
class NotLoadedMeta(type):
|
class NotLoadedMeta(type):
|
||||||
|
|
@ -33,18 +46,6 @@ class NotLoaded(object):
|
||||||
__metaclass__ = NotLoadedMeta
|
__metaclass__ = NotLoadedMeta
|
||||||
|
|
||||||
|
|
||||||
class LoadingErrorMeta(type):
|
|
||||||
def __str__(self):
|
|
||||||
return unicode(self).decode('utf-8')
|
|
||||||
|
|
||||||
def __unicode__(self):
|
|
||||||
return u'Loading error'
|
|
||||||
|
|
||||||
|
|
||||||
class LoadingError(object):
|
|
||||||
__metaclass__ = LoadingErrorMeta
|
|
||||||
|
|
||||||
|
|
||||||
class IBaseCap(object):
|
class IBaseCap(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import logging
|
||||||
import optparse
|
import optparse
|
||||||
from optparse import OptionGroup, OptionParser
|
from optparse import OptionGroup, OptionParser
|
||||||
|
|
||||||
|
from weboob.capabilities.base import NotAvailable, NotLoaded
|
||||||
from weboob.core.ouiboube import Weboob
|
from weboob.core.ouiboube import Weboob
|
||||||
from weboob.tools.config.iconfig import ConfigError
|
from weboob.tools.config.iconfig import ConfigError
|
||||||
from weboob.tools.backend import ObjectNotAvailable
|
from weboob.tools.backend import ObjectNotAvailable
|
||||||
|
|
@ -203,6 +204,9 @@ class BaseApplication(object):
|
||||||
backend.fillobj(obj, fields)
|
backend.fillobj(obj, fields)
|
||||||
except ObjectNotAvailable, e:
|
except ObjectNotAvailable, e:
|
||||||
logging.warning(u'Could not retrieve required fields (%s): %s' % (','.join(fields), e))
|
logging.warning(u'Could not retrieve required fields (%s): %s' % (','.join(fields), e))
|
||||||
|
for field in set(fields) - set('*'):
|
||||||
|
if getattr(obj, field) is NotLoaded:
|
||||||
|
setattr(obj, field, NotAvailable)
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def _complete_iter(self, backend, count, fields, res):
|
def _complete_iter(self, backend, count, fields, res):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue