accounting.storage package

Submodules

accounting.storage.ledgercli module

class accounting.storage.ledgercli.Ledger(app=None, ledger_file=None, ledger_bin=None)[source]

Bases: accounting.storage.Storage

add_transaction(transaction)[source]

Writes a transaction to the ledger file by opening it in ‘ab’ mode and writing a ledger transaction based on the Transaction instance in transaction.

assemble_arguments()[source]

Returns a list of arguments suitable for subprocess.Popen based on self.ledger_bin and self.ledger_file.

bal()[source]
get_process()[source]

Returns self.ledger_process if it evaluates to True. If self.ledger_process is not set the result of self.init_process() is returned.

get_transactions()[source]
init_process()[source]

Creates a new (presumably) ledger subprocess based on the args from Ledger.assemble_arguments() and then runs Ledger.read_until_prompt() once (which should return the banner text) and discards the output.

locked_process()[source]

Context manager that checks that the ledger process is not already locked, then “locks” the process and yields the process handle and unlocks the process when execution is returned.

Since this decorated as a contextlib.contextmanager() the recommended use is with the with-statement.

with self.locked_process() as p:
    p.stdin.write(b'bal\n')

    output = self.read_until_prompt(p)
read_until_prompt(process)[source]

Reads from the subprocess instance process until it finds a combination of \n]\x20 (the prompt), then returns the output without the prompt.

reg()[source]
send_command(command)[source]
update_transaction(transaction)[source]
accounting.storage.ledgercli.main(argv=None)[source]

Module contents

class accounting.storage.Storage(*args, **kw)[source]

Bases: builtins.object

ABC for accounting storage

get_account(*args, **kw)[source]
get_accounts(*args, **kw)[source]
get_transaction(*args, **kw)[source]
get_transactions(*args, **kw)[source]
reverse_transaction(transaction_id)
update_transaction(transaction)

Table Of Contents

Previous topic

accounting package

Next topic

accounting.storage.sql package

This Page