generated from felixm/defaultpy
Include ldg files instead of appending
Do not use dcontext for precision for now. It does not seem to be necessary.
This commit is contained in:
@@ -25,7 +25,6 @@ def load_and_write_back(filename):
|
||||
|
||||
def beancount_entry_to_string(entry) -> str:
|
||||
buf = io.StringIO()
|
||||
# beancount.parser.printer.print_entry(entry, dcontext=options_map['dcontext'], file=buf)
|
||||
beancount.parser.printer.print_entry(entry, file=buf)
|
||||
return buf.getvalue().strip()
|
||||
|
||||
@@ -59,9 +58,9 @@ def main():
|
||||
else:
|
||||
remove_if_exists(config.output_file)
|
||||
write_meta(config)
|
||||
process_ldg_files(config)
|
||||
process_csv_files(config)
|
||||
load_and_write_back(config.output_file)
|
||||
process_ldg_files(config)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import csv
|
||||
import datetime
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
@@ -12,10 +13,11 @@ from toldg.models import Config, CsvConfig, Mapping, Transaction
|
||||
|
||||
|
||||
def process_ldg_files(config: Config):
|
||||
for ldg_file in toldg.utils.get_ldg_files(config.input_directory):
|
||||
with open(ldg_file, "r") as f_in:
|
||||
with open(config.output_file, "a") as f_out:
|
||||
f_out.write(f_in.read())
|
||||
f_out.write("\n")
|
||||
for ldg_file in toldg.utils.get_ldg_files(config.input_directory):
|
||||
ldg_rel = os.path.relpath(ldg_file, os.path.dirname(config.output_file))
|
||||
f_out.write(f"include \"{ldg_rel}\"\n")
|
||||
|
||||
|
||||
def get_csv_config(csv_file: str, csv_configs: list[CsvConfig]) -> CsvConfig:
|
||||
|
||||
Reference in New Issue
Block a user