From 9d4cb49dc50f79bab32bfe2c6c31e3e91f515231 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Wed, 3 Sep 2014 07:40:13 +0200 Subject: [PATCH] add documentation on object constants --- weboob/capabilities/bank.py | 35 ++++++++++++++++++++++++++------- weboob/capabilities/messages.py | 14 ++++++++----- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/weboob/capabilities/bank.py b/weboob/capabilities/bank.py index 038ec8b9..2518223f 100644 --- a/weboob/capabilities/bank.py +++ b/weboob/capabilities/bank.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright(C) 2010-2012 Romain Bignon +# Copyright(C) 2010-2014 Romain Bignon # # This file is part of weboob. # @@ -71,13 +71,20 @@ class Account(Recipient): a recipient of a transfer. """ TYPE_UNKNOWN = 0 - TYPE_CHECKING = 1 # Transaction, everyday transactions - TYPE_SAVINGS = 2 # Savings/Deposit, can be used for everyday banking - TYPE_DEPOSIT = 3 # Term or Fixed Deposit, has time/amount constraints + TYPE_CHECKING = 1 + "Transaction, everyday transactions" + 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_MARKET = 5 # Stock market or other variable investments - TYPE_JOINT = 6 # Joint account - TYPE_CARD = 7 # Card account + "Loan account" + TYPE_MARKET = 5 + "Stock market or other variable investments" + TYPE_JOINT = 6 + "Joint account" + TYPE_CARD = 7 + "Card account" type = IntField('Type of account', default=TYPE_UNKNOWN) balance = DecimalField('Balance on this bank account') @@ -116,6 +123,20 @@ class Transaction(BaseObject): return "" % (self.date, self.label, self.amount) 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.amount), crc) crc = crc32(re.sub('[ ]+', ' ', self.raw.encode("utf-8")), crc) diff --git a/weboob/capabilities/messages.py b/weboob/capabilities/messages.py index 97b1ea70..f459834a 100644 --- a/weboob/capabilities/messages.py +++ b/weboob/capabilities/messages.py @@ -44,10 +44,14 @@ class Message(_Message): """ Represents a message read or to send. """ - IS_HTML = 0x001 # The content is HTML formatted - IS_UNREAD = 0x002 # The message is unread - IS_RECEIVED = 0x004 # The receiver has read this message - IS_NOT_RECEIVED = 0x008 # The receiver has not read this message + IS_HTML = 0x001 + "The content is HTML formatted" + IS_UNREAD = 0x002 + "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) title = StringField('Title of message') @@ -71,7 +75,7 @@ class Message(_Message): signature=NotLoaded, children=NotLoaded, flags=0): - BaseObject.__init__(self, id) + super(Message, self).__init__(id) self.thread = thread self.title = title self.sender = sender