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)
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)
def merge_files(output_filename, *input_filenames): documents = (loadf(filename) for filename in input_filenames) merged = merge(*documents) dumpf(output_filename, merged)
def indent(input_filename=None, output_filename=None): document = loadf(input_filename) dumpf(output_filename, document, pretty_print=True)
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)