Changeset 1697:a680bd74a37d
- Timestamp:
- 07/10/08 14:33:10 (3 months ago)
- Author:
- klai@…
- Branch:
- default
- Message:
-
Sanity checking on output from bank (from Rik)
- Location:
- src/Tycoon
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r1696
|
r1697
|
|
| 290 | 290 | raise BankClientException(e) |
| 291 | 291 | |
| 292 | | ht = self.__bank_security.parse_receipt(receipt) |
| | 292 | ht = self.__bank_security.parse_receipt(receipt, ('Tx_Amount', 'Transfer_From', 'Transfer_To', 'Tx_comment')) |
| | 293 | for ht_key in ('Tx_Amount', 'Transfer_From', 'Transfer_To', 'Tx_Comment'): |
| | 294 | if ht_key not in ht or ht[ht_key] is None: |
| | 295 | raise BankClientException( |
| | 296 | 'Malformed bank response, results does not contain the '+\ |
| | 297 | '%s key' % ht_key) |
| 293 | 298 | |
| 294 | 299 | #convert the amount to decimal |
-
|
r1403
|
r1697
|
|
| 20 | 20 | # |
| 21 | 21 | import datetime, decimal, os.path, re, time |
| | 22 | from types import TupleType |
| 22 | 23 | from KL.Security.Signer import Signer |
| 23 | 24 | from KL.Network.TimeStampBuffer import TimeStampBuffer |
| … |
… |
|
| 39 | 40 | self.__re = None |
| 40 | 41 | |
| 41 | | def parse_receipt(self, receipt): |
| | 42 | def parse_receipt(self, receipt, keys=None): |
| 42 | 43 | #tokenize the receipt into a hashtable containing the receipt contents |
| 43 | 44 | tokens = receipt.split("|") |
| … |
… |
|
| 47 | 48 | if t != None and len(t) == 2: |
| 48 | 49 | ht[t[0]] = t[1] |
| | 50 | |
| | 51 | if keys is not None and isinstance(keys, TupleType): |
| | 52 | for key in keys: |
| | 53 | if key not in ht: |
| | 54 | ht[key] = None |
| | 55 | |
| 49 | 56 | return ht |
| 50 | 57 | |