source: remit/util/add_accounts @ 3e372da

client
Last change on this file since 3e372da was 8132e8c, checked in by Alex Dehnert <adehnert@…>, 15 years ago

The executable bit is shiny

  • Property mode set to 100755
File size: 1.1 KB
Line 
1#!/usr/bin/python
2import sys
3import os
4
5if __name__ == '__main__':
6    cur_file = os.path.abspath(__file__)
7    django_dir = os.path.abspath(os.path.join(os.path.dirname(cur_file), '..'))
8    sys.path.append(django_dir)
9    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
10
11import finance_core.models
12import finance_core.util
13
14if __name__ == '__main__':
15    print sys.argv
16    if len(sys.argv) > 1:
17        base = finance_core.models.BudgetArea.get_by_pathstr(sys.argv[1])
18    accounts = []
19    for line in sys.stdin:
20        data = line.strip().split('\t')
21        if len(data) == 0:
22            # Can this happen?
23            # If it does, skip
24            pass
25        elif len(data) == 1:
26            # Just a name. Append None for no account
27            data.append(None)
28            accounts.append(data)
29        elif len(data) == 2:
30            name, number = data
31            accounts.append((name, int(number)))
32        else:
33            raise ValueError("Must pass one or two values per line")
34    finance_core.util.mass_add_accounts(base, accounts, writeto=sys.stdout)
Note: See TracBrowser for help on using the repository browser.