Esempio n. 1
0
def graph(input_filename=None, output_filename=None):
    document = loadf(input_filename)
    flat_accounts = flatten_accounts(document.accounts)
    edges = construct_graph(document.events, flat_accounts)    

    with output_stream(output_filename) as stream:
        print_graph(edges, stream)
Esempio n. 2
0
def graph(input_filename=None, output_filename=None):
    document = loadf(input_filename)
    flat_accounts = flatten_accounts(document.accounts)
    edges = construct_graph(document.events, flat_accounts)

    with output_stream(output_filename) as stream:
        print_graph(edges, stream)
Esempio n. 3
0
def print_earnings_util(input_filename=None, output_filename=None):
    input_filename = argv[1] if len(argv) >= 2 else None

    document = loadf(input_filename)
    earnings = collect_earnings(document.events)

    with output_stream(output_filename) as out:
        print_earnings(document.accounts[2], earnings, out)
Esempio n. 4
0
def print_earnings_util(input_filename=None, output_filename=None):
    input_filename = argv[1] if len(argv) >= 2 else None

    document = loadf(input_filename)
    earnings = collect_earnings(document.events)

    with output_stream(output_filename) as out:
        print_earnings(document.accounts[2], earnings, out)
Esempio n. 5
0
def extract(from_date_str, to_date_str, input_filename=None, output_filename=None):
    from_date = datetime.strptime(from_date_str, DATE_FORMAT).date()
    to_date = datetime.strptime(to_date_str, DATE_FORMAT).date()

    if from_date > to_date:
        raise ValueError("from_date > to_date")

    document = loadf(input_filename)

    inject_balances(document, from_date)
    drop_extra_events(document, from_date, to_date)

    document.begin = from_date
    document.end = to_date

    dumpf(output_filename, document)
Esempio n. 6
0
def extract(from_date_str,
            to_date_str,
            input_filename=None,
            output_filename=None):
    from_date = datetime.strptime(from_date_str, DATE_FORMAT).date()
    to_date = datetime.strptime(to_date_str, DATE_FORMAT).date()

    if from_date > to_date:
        raise ValueError("from_date > to_date")

    document = loadf(input_filename)

    inject_balances(document, from_date)
    drop_extra_events(document, from_date, to_date)

    document.begin = from_date
    document.end = to_date

    dumpf(output_filename, document)
Esempio n. 7
0
def missing_accounts(*input_filenames):
    input_filenames = set(input_filenames)

    documents = ((filename, loadf(filename)) for filename in input_filenames)
    flat_accounts = dict((filename, flatten_accounts(document.accounts)) for (filename, document) in documents)

    all_accounts = dict()
    map(all_accounts.update, flat_accounts.itervalues())
    
    havity = defaultdict(set)
    for account_num, account in all_accounts.iteritems():
        for filename, accounts in flat_accounts.iteritems():
            if account_num in accounts:
                havity[account_num].add(filename)

    for account_num, filenames in havity.iteritems():
        fmt_filenames = " ".join(filenames)

        if filenames == input_filenames:
            if not ONLY:
                print "{account_num}: ALL  {fmt_filenames}".format(**locals())
        else:
            print "{account_num}: ONLY {fmt_filenames}".format(**locals())
Esempio n. 8
0
def missing_accounts(*input_filenames):
    input_filenames = set(input_filenames)

    documents = ((filename, loadf(filename)) for filename in input_filenames)
    flat_accounts = dict((filename, flatten_accounts(document.accounts))
                         for (filename, document) in documents)

    all_accounts = dict()
    map(all_accounts.update, flat_accounts.itervalues())

    havity = defaultdict(set)
    for account_num, account in all_accounts.iteritems():
        for filename, accounts in flat_accounts.iteritems():
            if account_num in accounts:
                havity[account_num].add(filename)

    for account_num, filenames in havity.iteritems():
        fmt_filenames = " ".join(filenames)

        if filenames == input_filenames:
            if not ONLY:
                print "{account_num}: ALL  {fmt_filenames}".format(**locals())
        else:
            print "{account_num}: ONLY {fmt_filenames}".format(**locals())
Esempio n. 9
0
def renumber(input_filename=None, output_filename=None):
    document = loadf(input_filename)
    sort_accounts(document.accounts)
    sort_events(document.events)
    renumber_events(document.events)
    dumpf(output_filename, document)
Esempio n. 10
0
def merge_files(output_filename, *input_filenames):
    documents = (loadf(filename) for filename in input_filenames)
    merged = merge(*documents)
    dumpf(output_filename, merged)
Esempio n. 11
0
def move_entries_util(from_account_num, to_account_num, input_filename=None, output_filename=None):
    from_account_num = int(from_account_num)
    to_account_num = int(to_account_num)
    document = loadf(input_filename)
    move_entries(document.events, from_account_num, to_account_num)
    dumpf(output_filename, document)
Esempio n. 12
0
def indent(input_filename=None, output_filename=None):
    document = loadf(input_filename)
    dumpf(output_filename, document, pretty_print=True)
Esempio n. 13
0
def main():
    from sys import argv
    input_filename = argv[1] if len(argv) >= 2 else None
    document = loadf(input_filename)
    print_accounts(document.accounts)
Esempio n. 14
0
def indent(input_filename=None, output_filename=None):
    document = loadf(input_filename)
    dumpf(output_filename, document, pretty_print=True)
Esempio n. 15
0
def merge_files(output_filename, *input_filenames):
    documents = (loadf(filename) for filename in input_filenames)
    merged = merge(*documents)
    dumpf(output_filename, merged)
Esempio n. 16
0
def renumber(input_filename=None, output_filename=None):
    document = loadf(input_filename)
    sort_accounts(document.accounts)
    sort_events(document.events)
    renumber_events(document.events)
    dumpf(output_filename, document)
Esempio n. 17
0
def main():
    from sys import argv
    input_filename = argv[1] if len(argv) >= 2 else None
    document = loadf(input_filename)
    print_accounts(document.accounts)