line too long

This commit is contained in:
juke 2011-02-08 20:13:44 +01:00 committed by Romain Bignon
commit 9fb8b150f2
2 changed files with 17 additions and 10 deletions

View file

@ -21,7 +21,8 @@ from datetime import datetime, date
from .base import IBaseCap, CapBaseObject from .base import IBaseCap, CapBaseObject
__all__ = ['Account', 'AccountNotFound', 'TransferError', 'ICapBank', 'Operation'] __all__ = ['Account', 'AccountNotFound', 'TransferError', 'ICapBank',
'Operation']
class AccountNotFound(Exception): class AccountNotFound(Exception):
@ -48,20 +49,21 @@ class Account(CapBaseObject):
class Operation(CapBaseObject): class Operation(CapBaseObject):
def __init__(self, id): def __init__(self, id):
CapBaseObject.__init__(self, id) CapBaseObject.__init__(self, id)
self.add_field('date', (basestring,datetime,date)) self.add_field('date', (basestring, datetime, date))
self.add_field('label', unicode) self.add_field('label', unicode)
self.add_field('amount', float) self.add_field('amount', float)
def __repr__(self): def __repr__(self):
return "<Operation date='%s' label='%s' amount=%s>" % (self.date, self.label, self.amount) return "<Operation date='%s' label='%s' amount=%s>" % (self.date,
self.label, self.amount)
class Transfer(CapBaseObject): class Transfer(CapBaseObject):
def __init__(self, id): def __init__(self, id):
CapBaseObject.__init__(self, id) CapBaseObject.__init__(self, id)
self.add_field('amount', float) self.add_field('amount', float)
self.add_field('date', (basestring,datetime,date)) self.add_field('date', (basestring, datetime, date))
self.add_field('origin', (int,long,basestring)) self.add_field('origin', (int, long, basestring))
self.add_field('recipient', (int,long,basestring)) self.add_field('recipient', (int, long, basestring))
class ICapBank(IBaseCap): class ICapBank(IBaseCap):
def iter_accounts(self): def iter_accounts(self):

View file

@ -19,12 +19,14 @@
from weboob.tools.misc import iter_fields from weboob.tools.misc import iter_fields
__all__ = ['FieldNotFound', 'IBaseCap', 'NotAvailable', 'NotLoaded', 'CapBaseObject'] __all__ = ['FieldNotFound', 'IBaseCap', 'NotAvailable', 'NotLoaded',
'CapBaseObject']
class FieldNotFound(Exception): class FieldNotFound(Exception):
def __init__(self, obj, field): def __init__(self, obj, field):
Exception.__init__(self, u'Field "%s" not found for object %s' % (field, obj)) Exception.__init__(self,
u'Field "%s" not found for object %s' % (field, obj))
class NotAvailableMeta(type): class NotAvailableMeta(type):
@ -133,7 +135,8 @@ class CapBaseObject(object):
if self._attribs is not None and name in self._attribs: if self._attribs is not None and name in self._attribs:
return self._attribs[name].value return self._attribs[name].value
else: else:
raise AttributeError, "'%s' object has no attribute '%s'" % (self.__class__.__name__, name) raise AttributeError, "'%s' object has no attribute '%s'" % (
self.__class__.__name__, name)
def __setattr__(self, name, value): def __setattr__(self, name, value):
try: try:
@ -145,5 +148,7 @@ class CapBaseObject(object):
value is not NotLoaded and \ value is not NotLoaded and \
value is not NotAvailable and \ value is not NotAvailable and \
value is not None: value is not None:
raise ValueError('Value for "%s" needs to be of type %r, not %r' % (name, attr.type, type(value))) raise ValueError(
'Value for "%s" needs to be of type %r, not %r' % (
name, attr.type, type(value)))
attr.value = value attr.value = value