Skip to main content

autobean-format

build pypi Code Coverage Maintainability license

Yet another formatter for beancount.

Features

  • Deep cleanup.
    • Normalizes all spacing.
    • Full beancount syntax support (except out-of-line tags / links in transaction).
  • Currency / cost aligning.
    • Works for open, balance, price and posting.
  • Entry sorting.
    • Honors pushtag / pushmeta.
    • Honors time meta (HH:MM / HH:MM:SS / epoch seconds / epoch ms / epoch us).
    • Preserves comments.
    • Preserves existing structure and ordering whenever possible.
  • Thousands separator normalization.
    • Adds / removes / keeps thousands separators.
  • Recursive formatting.
    • Recursively formats included files.
    • Honors glob includes.
  • Flexible output.
    • Prints results / prints diff / writes back to file.
  • Typed and extensible.
    • For example, the code for thousands separators is as simple as this.

Usage

pip install autobean-format

# format and print results
autobean-format foo.bean
# format and write back to file
autobean-format foo.bean --output-mode=inplace
# format and print the diff
autobean-format foo.bean --output-mode=diff

# sort entries by date and time
autobean-format foo.bean --sort

# recursively format all included files
autobean-format foo.bean --recursive

# add thousands separators to all numbers
autobean-format foo.bean --thousands-separator=add

# see more options
autobean-format -h

Examples

autobean-format foo.bean \
    --indent='    ' \
    --currency-column=30 \
    --cost-column=35 \
    --inline-comment-column=0 \
    --thousands-separator=add \
    --spaces-in-braces \
    --sort \
    --recursive \
    --output-mode=inplace
Before After

foo.bean:

2000-01-01 open Assets:Foo USD,XXX
2000-01-01  *  "foo"   ^aa  #bb
  meta:123
     Assets:Foo  -1.23*4000USD    ;X
    Assets:Foo 1000 XXX {4.92  USD}
   meta:456


include "price.*"
2000-01-02 balance Assets:Foo -4920USD
2000-01-02 balance Assets:Foo 1000XXX

price.bean:

2021-01-01 price EUR 1.21 USD
 ;inner comment
2021-01-04 price GBP  1.36 USD  ; Y
;leading comment
2021-01-01 price JPY  0.009 USD

2020-01-01 price EUR  1.12 USD
2020-01-02 price GBP  1.32USD
2020-01-01 price JPY  0.009 USD

foo.bean:

2000-01-01 open Assets:Foo    USD, XXX

2000-01-01 * "foo" ^aa #bb
    meta: 123
    Assets:Foo  -1.23 * 4,000 USD ; X
    Assets:Foo          1,000 XXX  { 4.92 USD }
        meta: 456

include "price.*"

2000-01-02 balance Assets:Foo -4,920 USD
2000-01-02 balance Assets:Foo 1,000 XXX

price.bean:

2020-01-01 price EUR     1.12 USD
2020-01-01 price JPY    0.009 USD
2020-01-02 price GBP     1.32 USD

2021-01-01 price EUR     1.21 USD
    ; inner comment
; leading comment
2021-01-01 price JPY    0.009 USD
2021-01-04 price GBP     1.36 USD ; Y

Metadata

Release files for autobean-format 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autobean-format 0.1.8
File Size Uploaded
autobean_format-0.1.8.tar.gz 13.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autobean-format 0.1.8
File Interpreter ABI Platform
autobean_format-0.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 32.4 kB

Release files / autobean_format-0.1.8.tar.gz

Download URL autobean_format-0.1.8.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
699cf055457b70666b1d648b60cece6ddae17bcc74992ed595df19eebb49cdc7
BLAKE2b-256 checksum
How to use checksums
12c639224b0469a3d978cdaef4a7bef5af2ba12e385c5248f632e9166bd958ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.26.9 CPython/3.12.3 Linux/6.17.0-1013-azure

Release files / autobean_format-0.1.8-py3-none-any.whl

Download URL autobean_format-0.1.8-py3-none-any.whl
Size 19.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb0b818f1572a7c69e74da327ca441a911f0656a3ba365b7e3e5ee006cf4704a
BLAKE2b-256 checksum
How to use checksums
61cdeca11eb518e791ab77dceeab92a63e551e4aa08c104cf472904478b37ddc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.26.9 CPython/3.12.3 Linux/6.17.0-1013-azure

Release history Release notifications | RSS feed

This release

0.1.8 This release

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page