Skip to main content

Yet another formatter for beancount

Project description

autobean-format

build pypi Test Coverage Maintainability license

Yet another formatter for beancount.

Features

  • Deep cleanup.
    • Normalizes all spacing.
    • Full beancount v2 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 \
    --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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autobean-format-0.1.6.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

autobean_format-0.1.6-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file autobean-format-0.1.6.tar.gz.

File metadata

  • Download URL: autobean-format-0.1.6.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.15.2 CPython/3.10.12 Linux/6.5.0-1021-azure

File hashes

Hashes for autobean-format-0.1.6.tar.gz
Algorithm Hash digest
SHA256 45ee3df82f9e2df7b44cf6169d1415875a001db603001dacf805515fa0a11c80
MD5 05ed1302931e03b6088d3e172a175973
BLAKE2b-256 b8557f6a66c25acffb2b3b3be064790afc2b654bcf9ab7fe54a28d741328b4a9

See more details on using hashes here.

File details

Details for the file autobean_format-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: autobean_format-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.15.2 CPython/3.10.12 Linux/6.5.0-1021-azure

File hashes

Hashes for autobean_format-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f68e2c980330adb4b1917ddf76824783a457e2de3ea615aba9fdecbdc798653e
MD5 c564dad4d1c49e4eedbbb04e173e381d
BLAKE2b-256 67c684f97322a0020a60a5785ff4b949e7c7fa710e4b5c35a9f10ac3b52d9b2f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page