Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
blais committed Jun 7, 2008
1 parent 0860cae commit 1d6a8c9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
17 changes: 12 additions & 5 deletions bin/bean-balance
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,23 @@ def main():
parser.add_option('-B', '--at-cost', action='store_true',
help="Compute amounts at cost units instead of in amount units.")

parser.add_option('-a', '--account', action='store',
help="Only show the balance for the specified account, in "
"a format that can be deserialized to build a wallet.")

opts, ledger, args = cmdline.main(parser)

compute_balsheet(ledger, 'local_balance', 'balance', opts.at_cost)
aname = 'local_balance' if opts.local else 'balance'
for acc, branch, line in render_tree(ledger.get_root_account()):
aline = branch + line
print ' %-40s %s' % (aline, getattr(acc, aname).round())
if opts.account is not None:
acc = ledger.get_account(opts.account)
print repr(acc.balance)
else:
aname = 'local_balance' if opts.local else 'balance'
for acc, branch, line in render_tree(ledger.get_root_account()):
aline = branch + line
print ' %-40s %s' % (aline, getattr(acc, aname).round())

if __name__ == '__main__':
main()



6 changes: 5 additions & 1 deletion lib/python/beancount/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ def main(parser):

fn, args = args[0], args[1:]

ledger = load_ledger(fn, opts)
return opts, ledger, args

def load_ledger(fn, opts):
# Parse the file.
if not exists(fn):
parser.error("No such file '%s'." % fn)
Expand Down Expand Up @@ -91,8 +95,8 @@ def main(parser):
f.close()

ledger.run_directives()
return ledger

return opts, ledger, args

def reload(ledger):
"""
Expand Down
4 changes: 2 additions & 2 deletions lib/python/beancount/web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ def server_error(app, ctx):

('@@Style', static('style.css', 'text/css'), '/style.css', None),
('@@Treetable', static('treetable.js', 'text/javascript'), '/treetable.js', None),
('@@FolderOpen', static('folder_open.png', 'text/javascript'), '/folder_open.png', None),
('@@FolderClosed', static('folder_closed.png', 'text/javascript'), '/folder_closed.png', None),
('@@FolderOpen', static('folder_open.png', 'image/png'), '/folder_open.png', None),
('@@FolderClosed', static('folder_closed.png', 'image/png'), '/folder_closed.png', None),
('@@Logo', static("header-universal-dollar.jpg", 'image/jpeg'), '/header.jpg', None),
('@@Home', info, '/', None),
('@@Info', info, '/info', None),
Expand Down

0 comments on commit 1d6a8c9

Please sign in to comment.