client-barcode: Split Status.commit() up into sub-functions

This commit is contained in:
Sebastian Pipping 2011-10-26 17:50:57 +02:00
parent 27962ad107
commit 156a0df88d
1 changed files with 51 additions and 46 deletions

View File

@ -267,7 +267,7 @@ class Status:
def commit(self):
assert(self.logged_in())
# Compress DepositCommands
def compress_deposit_commands():
dummy, initial_balance = self.transfers[0]
balance_before = initial_balance
compressed_deposit = DepositCommand(Decimal('0'))
@ -282,10 +282,10 @@ class Status:
others.append((compressed_deposit, balance_before))
self.transfers = others
def process_buy_commands_combined():
# Compress BuyCommands, use a single bulkbuy
dummy, initial_balance = self.transfers[0]
balance_before = initial_balance
buy_commands = list()
non_buy_commands = list()
total_buy_diff = 0
@ -305,7 +305,7 @@ class Status:
else:
self.transfers = non_buy_commands
# Process remaining command queue
def process_commands():
for (command, balance_backup) in list(self.transfers):
try:
command.run(self.login_name)
@ -316,6 +316,7 @@ class Status:
else:
self.transfers.pop(0)
def finish():
if not self.transfers:
# Show final balance for some time
clear()
@ -324,6 +325,10 @@ class Status:
self.logout()
compress_deposit_commands()
process_buy_commands_combined()
process_commands()
finish()
def find(self, barcode):
try: