-
Notifications
You must be signed in to change notification settings - Fork 3
/
get_balance_multi.py
executable file
·43 lines (32 loc) · 1.25 KB
/
get_balance_multi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
import click
from golos.account import Account
from golosscripts.decorators import common_options, helper
@click.command()
@common_options
@helper
@click.option('--no-header', default=False, is_flag=True, help='supress header')
@click.option('--no-sum', default=False, is_flag=True, help='supress summary output')
@click.pass_context
def main(ctx, no_header, no_sum):
"""Show multiple users balances."""
if not no_header:
print('{:<20} {:>10} {:>11} {:>11}'.format('Account', 'GBG', 'GOLOS', 'GP'))
print('--------------------')
sum_gbg = float()
sum_golos = float()
sum_gp = float()
for acc in ctx.config['accs']:
account = Account(acc)
balance = account.get_balances()
cv = ctx.helper.converter
gp = cv.vests_to_sp(balance['total']['GESTS'])
print('{:<20} {:>10} {:>10} {:>10.0f}'.format(acc, balance['total']['GBG'], balance['total']['GOLOS'], gp))
sum_gbg += balance['total']['GBG']
sum_golos += balance['total']['GOLOS']
sum_gp += gp
if not no_sum:
print('--------------------')
print('{:<20} {:>10.3f} {:>10.3f} {:>10.0f}'.format('Totals:', sum_gbg, sum_golos, sum_gp))
if __name__ == '__main__':
main()