merge do_caps() and do_backends() into do() (optional keyword params 'backends' and 'caps')
This commit is contained in:
parent
5d33778986
commit
fc4badf88e
13 changed files with 53 additions and 103 deletions
|
|
@ -284,33 +284,3 @@ class ConsoleApplication(BaseApplication):
|
|||
except Exception, e:
|
||||
logging.warning(u'Could not retrieve required fields (%s): %s' % (','.join(fields), e))
|
||||
yield backend, result
|
||||
|
||||
def do_caps(self, caps, function, *args, **kwargs):
|
||||
"""
|
||||
Call Weboob.do_caps(), after having filled the yielded object, if selected fields are given by user.
|
||||
"""
|
||||
for i, (backend, result) in enumerate(self.weboob.do_caps(caps, function, *args, **kwargs)):
|
||||
if self.options.count and i == self.options.count:
|
||||
break
|
||||
fields = set(self.selected_fields) - set('*')
|
||||
if fields:
|
||||
try:
|
||||
backend.browser.fillobj(result, fields)
|
||||
except Exception, e:
|
||||
logging.warning(u'Could not retrieve required fields (%s): %s' % (','.join(fields), e))
|
||||
yield backend, result
|
||||
|
||||
def do_backends(self, backends, function, *args, **kwargs):
|
||||
"""
|
||||
Call Weboob.do_backends(), after having filled the yielded object, if selected fields are given by user.
|
||||
"""
|
||||
for i, (backend, result) in enumerate(self.weboob.do_backends(backends, function, *args, **kwargs)):
|
||||
if self.options.count and i == self.options.count:
|
||||
break
|
||||
fields = set(self.selected_fields) - set('*')
|
||||
if fields:
|
||||
try:
|
||||
backend.browser.fillobj(result, fields)
|
||||
except Exception, e:
|
||||
logging.warning(u'Could not retrieve required fields (%s): %s' % (','.join(fields), e))
|
||||
yield backend, result
|
||||
|
|
|
|||
|
|
@ -99,23 +99,9 @@ class QtDo(QObject):
|
|||
self.connect(self, SIGNAL('cb'), self.local_cb)
|
||||
self.connect(self, SIGNAL('eb'), self.local_eb)
|
||||
|
||||
def run_thread(func):
|
||||
def inner(self, *args, **kwargs):
|
||||
self.process = func(self, *args, **kwargs)
|
||||
self.process.callback_thread(self.thread_cb, self.thread_eb)
|
||||
return inner
|
||||
|
||||
@run_thread
|
||||
def do(self, *args, **kwargs):
|
||||
return self.weboob.do(*args, **kwargs)
|
||||
|
||||
@run_thread
|
||||
def do_caps(self, *args, **kwargs):
|
||||
return self.weboob.do_caps(*args, **kwargs)
|
||||
|
||||
@run_thread
|
||||
def do_backends(self, *args, **kwargs):
|
||||
return self.weboob.do_backends(*args, **kwargs)
|
||||
self.process = self.weboob.do(*args, **kwargs)
|
||||
self.process.callback_thread(self.thread_cb, self.thread_eb)
|
||||
|
||||
def default_eb(self, backend, error, backtrace):
|
||||
# TODO display a messagebox
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue