Ah, thanks for the pointers to autobean-format, that does indeed do what I
need.  Should have asked first, heh heh.

I will add a deprecation notice to my repo and a reference and
recommendation to that instead.

cheers,
Simon

On Wed, 18 Jun 2025 at 18:49, Red S <[email protected]> wrote:

> Same here. OP,  wondering if you came across SEIAROTg's repo below
> <https://github.com/SEIAROTg/autobean-format#examples>, and if you did,
> if it didn't meet your needs?
>
> On Tuesday, June 17, 2025 at 6:11:37 AM UTC-7 Brian Lalor wrote:
>
> I’ve found autobean-format to be extremely useful.
> https://github.com/SEIAROTg/autobean-format#examples
> —
> Brian Lalor (he/him)
> [email protected]
>
> On Jun 17, 2025, at 1:58 AM, Paul Walker <[email protected]> wrote:
>
> Interesting! I had my own need for this recently, but with a requirement
> to "fix" currency columns/spacing. The script gets pretty short if you
> leverage some internal methods, but this also ends up stripping comments
> and filling in empty/inferred posting amounts. It looks like yours would
> preserve more context by more or less splitting on date. I ended up with
> this plus some messy logic to regextract my fava currency-column option:
>
> import sys
> from beancount.loader import load_file
> from beancount.parser import printer
> from beancount.scripts import format
>
> def main(file):
>     entries, errors, options = load_file(file)
>
>     entries_sorted = sorted(entries, key=lambda x: x.date)
>
>     # Or if you don't need formatting, just
> printer.print_entries(entries_sorted, file=file)
>     with open(file, 'w') as f:
>         # Enumerate to get "last" entry to skip extra inter-directive
> newline
>         for i, entry in enumerate(entries_sorted):
>             printed = printer.format_entry(entry)
>             # Align the printed entry with a currency column, set or grab
> from options (e.g. Fava)
>             formatted = format.align_beancount(printed, currency_column=61)
>             f.write(formatted)
>             if i != len(entries_sorted) - 1:
>                 f.write('\n')
>
> if __name__ == "__main__":
>     if len(sys.argv) != 2:
>         print("Usage: python bean-sort.py <beancount-file>")
>         sys.exit(1)
>     main(sys.argv[1])
>
> Thanks for sharing!
> Paul
>
> On Monday, June 16, 2025 at 9:56:26 PM UTC-4 Simon Guest wrote:
>
> And now the repo is public. 🤭
>
> On Tue, 17 Jun 2025 at 12:23, Simon Guest <[email protected]> wrote:
>
> I made a naive sorting utility for Beancount.  I hunted for such a thing
> and failed to find one, which surprised me.
>
> Anyway, it was quicker to write a few lines of Python than keep wondering
> whether or why this hadn't been done before.
>
> Here in case it helps anyone else.
>
> https://github.com/tesujimath/bean-sort
>
> cheers,
> Simon
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Beancount" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion visit
> https://groups.google.com/d/msgid/beancount/4dc9dbe6-31f8-4ed3-909b-9bf053b48b94n%40googlegroups.com
> <https://groups.google.com/d/msgid/beancount/4dc9dbe6-31f8-4ed3-909b-9bf053b48b94n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Beancount" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion visit
> https://groups.google.com/d/msgid/beancount/855e88f9-974d-40a6-ac35-74444fa0b41fn%40googlegroups.com
> <https://groups.google.com/d/msgid/beancount/855e88f9-974d-40a6-ac35-74444fa0b41fn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/beancount/CAFhGSbtyAXuNrBne-or0%2Buhr9w40wUjuc4z%3D5e0y-U5Cnt%2BABw%40mail.gmail.com.

Reply via email to