def main(): logging.basicConfig(level=logging.INFO, format='%(levelname)-8s: %(message)s') parser = argparse.ArgumentParser(description=__doc__.strip()) parser.add_argument('filename', help="Ledger input filename.") parser.add_argument( 'output', help=("Output filename (if .pbtxt, output as text-formatted protos. " "Otherwise write to a riegeli file.")) parser.add_argument('--num_directives', type=int, default=None, help="Number of entries to print") args = parser.parse_args() export_v2_data(args.filename, args.output + ".v2.pbtxt", args.num_directives) export_v3_data(args.filename, args.output + ".v3.pbtxt", args.num_directives)
from datetime import date from beancount.core import data from beancount.parser import parser, printer from beancount import loader from modules.imports.alipay import Alipay from modules.imports.wechat import WeChat from modules.imports.citic_credit import CITICCredit import re import argparse parser = argparse.ArgumentParser("import") parser.add_argument("path", help = "CSV Path") parser.add_argument("--entry", help = "Entry bean path (default = main.bean)", default = 'main.bean') parser.add_argument("--out", help = "Output bean path", default = 'out.bean') args = parser.parse_args() entries, errors, option_map = loader.load_file(args.entry) importers = [Alipay, WeChat, CITICCredit] instance = None for importer in importers: try: with open(args.path, 'rb') as f: file_bytes = f.read() instance = importer(args.path, file_bytes, entries, option_map) break except: pass if instance == None: print("No suitable importer!")