def format_posting(posting: Posting, indent: str = ' ') -> str: printer = beancount.parser.printer.EntryPrinter() flag_account, position_str, weight_str = printer.render_posting_strings( posting) oss = io.StringIO() oss.write(('%s%s %s' % (indent, flag_account, position_str)).rstrip() + '\n') if posting.meta: printer.write_metadata(posting.meta, oss, ' ' + indent) return oss.getvalue()
def get_posting_line(posting): printer = beancount.parser.printer.EntryPrinter() flag_account, position_str, _ = printer.render_posting_strings(posting) return (' %s %s' % (flag_account, position_str)).rstrip()