add documentation on object constants

This commit is contained in:
Romain Bignon 2014-09-03 07:40:13 +02:00
commit 9d4cb49dc5
2 changed files with 37 additions and 12 deletions

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright(C) 2010-2012 Romain Bignon # Copyright(C) 2010-2014 Romain Bignon
# #
# This file is part of weboob. # This file is part of weboob.
# #
@ -71,13 +71,20 @@ class Account(Recipient):
a recipient of a transfer. a recipient of a transfer.
""" """
TYPE_UNKNOWN = 0 TYPE_UNKNOWN = 0
TYPE_CHECKING = 1 # Transaction, everyday transactions TYPE_CHECKING = 1
TYPE_SAVINGS = 2 # Savings/Deposit, can be used for everyday banking "Transaction, everyday transactions"
TYPE_DEPOSIT = 3 # Term or Fixed Deposit, has time/amount constraints TYPE_SAVINGS = 2
"Savings/Deposit, can be used for every banking"
TYPE_DEPOSIT = 3
"Term of Fixed Deposit, has time/amount constraints"
TYPE_LOAN = 4 TYPE_LOAN = 4
TYPE_MARKET = 5 # Stock market or other variable investments "Loan account"
TYPE_JOINT = 6 # Joint account TYPE_MARKET = 5
TYPE_CARD = 7 # Card account "Stock market or other variable investments"
TYPE_JOINT = 6
"Joint account"
TYPE_CARD = 7
"Card account"
type = IntField('Type of account', default=TYPE_UNKNOWN) type = IntField('Type of account', default=TYPE_UNKNOWN)
balance = DecimalField('Balance on this bank account') balance = DecimalField('Balance on this bank account')
@ -116,6 +123,20 @@ class Transaction(BaseObject):
return "<Transaction date=%r label=%r amount=%r>" % (self.date, self.label, self.amount) return "<Transaction date=%r label=%r amount=%r>" % (self.date, self.label, self.amount)
def unique_id(self, seen=None, account_id=None): def unique_id(self, seen=None, account_id=None):
"""
Get an unique ID for the transaction based on date, amount and raw.
:param seen: if given, the method uses this dictionary as a cache to
prevent several transactions with the same values to have the same
unique ID.
:type seen: :class:`dict`
:param account_id: if given, add the account ID in data used to create
the unique ID. Can be useful if you want your ID to be unique across
several accounts.
:type account_id: :class:`str`
:returns: an unique ID encoded in 8 length hexadecimal string (for example ``'a64e1bc9'``)
:rtype: :class:`str`
"""
crc = crc32(str(self.date)) crc = crc32(str(self.date))
crc = crc32(str(self.amount), crc) crc = crc32(str(self.amount), crc)
crc = crc32(re.sub('[ ]+', ' ', self.raw.encode("utf-8")), crc) crc = crc32(re.sub('[ ]+', ' ', self.raw.encode("utf-8")), crc)

View file

@ -44,10 +44,14 @@ class Message(_Message):
""" """
Represents a message read or to send. Represents a message read or to send.
""" """
IS_HTML = 0x001 # The content is HTML formatted IS_HTML = 0x001
IS_UNREAD = 0x002 # The message is unread "The content is HTML formatted"
IS_RECEIVED = 0x004 # The receiver has read this message IS_UNREAD = 0x002
IS_NOT_RECEIVED = 0x008 # The receiver has not read this message "The message is unread"
IS_RECEIVED = 0x004
"The receiver has read this message"
IS_NOT_RECEIVED = 0x008
"The receiver hass not read this message"
thread = Field('Reference to the thread', _Thread) thread = Field('Reference to the thread', _Thread)
title = StringField('Title of message') title = StringField('Title of message')
@ -71,7 +75,7 @@ class Message(_Message):
signature=NotLoaded, signature=NotLoaded,
children=NotLoaded, children=NotLoaded,
flags=0): flags=0):
BaseObject.__init__(self, id) super(Message, self).__init__(id)
self.thread = thread self.thread = thread
self.title = title self.title = title
self.sender = sender self.sender = sender