improve caps
This commit is contained in:
parent
0afb45d777
commit
f65ca1c8b6
3 changed files with 4 additions and 10 deletions
|
|
@ -23,10 +23,7 @@ class Backend:
|
||||||
def __init__(self, weboob):
|
def __init__(self, weboob):
|
||||||
self.weboob = weboob
|
self.weboob = weboob
|
||||||
|
|
||||||
def has_caps(self, caps):
|
def has_caps(self, *caps):
|
||||||
if not isinstance(caps, (list,tuple)):
|
|
||||||
caps = (caps,)
|
|
||||||
|
|
||||||
for c in caps:
|
for c in caps:
|
||||||
if isinstance(self, c):
|
if isinstance(self, c):
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,11 @@ class Application(BaseApplication):
|
||||||
self.weboob.load_modules()
|
self.weboob.load_modules()
|
||||||
for name, backend in self.weboob.iter_backends():
|
for name, backend in self.weboob.iter_backends():
|
||||||
print '= Processing backend name = %s' % name
|
print '= Processing backend name = %s' % name
|
||||||
if isinstance(backend, ICapMessages):
|
if backend.has_caps(ICapMessages):
|
||||||
print '== Backend is ICapMessages => print its messages'
|
print '== Backend is ICapMessages => print its messages'
|
||||||
for message in backend.iter_new_messages():
|
for message in backend.iter_new_messages():
|
||||||
print '=== %s' % message
|
print '=== %s' % message
|
||||||
if isinstance(backend, ICapMessagesReply):
|
if backend.has_caps(ICapMessagesReply):
|
||||||
print '== Backend is ICapMessagesReply => TODO'
|
print '== Backend is ICapMessagesReply => TODO'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,7 @@ class Module:
|
||||||
if not self.klass:
|
if not self.klass:
|
||||||
raise ImportError("This is not a backend module (no Backend class found)")
|
raise ImportError("This is not a backend module (no Backend class found)")
|
||||||
|
|
||||||
def has_caps(self, caps):
|
def has_caps(self, *caps):
|
||||||
if not isinstance(caps, (list,tuple)):
|
|
||||||
caps = (caps,)
|
|
||||||
|
|
||||||
for c in caps:
|
for c in caps:
|
||||||
if issubclass(self.klass, c):
|
if issubclass(self.klass, c):
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue