{"id":13523220,"url":"https://github.com/LaunchPlatform/beancount-black","last_synced_at":"2025-04-01T00:30:59.412Z","repository":{"id":56953828,"uuid":"477183163","full_name":"LaunchPlatform/beancount-black","owner":"LaunchPlatform","description":"Opinionated code formatter, just like Python's black code formatter but for Beancount","archived":false,"fork":false,"pushed_at":"2025-03-08T21:08:05.000Z","size":142,"stargazers_count":43,"open_issues_count":9,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T11:01:35.394Z","etag":null,"topics":["beancount","formatter","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LaunchPlatform.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-02T22:14:56.000Z","updated_at":"2025-03-30T00:49:11.000Z","dependencies_parsed_at":"2023-12-06T10:54:02.987Z","dependency_job_id":"c229e0fb-4c55-4832-89a2-7421819be132","html_url":"https://github.com/LaunchPlatform/beancount-black","commit_stats":{"total_commits":116,"total_committers":1,"mean_commits":116.0,"dds":0.0,"last_synced_commit":"0533e20185dba8f8f2d293eb0a6e64858cfc8794"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LaunchPlatform%2Fbeancount-black","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LaunchPlatform%2Fbeancount-black/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LaunchPlatform%2Fbeancount-black/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LaunchPlatform%2Fbeancount-black/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LaunchPlatform","download_url":"https://codeload.github.com/LaunchPlatform/beancount-black/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246563315,"owners_count":20797441,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["beancount","formatter","python"],"created_at":"2024-08-01T06:00:57.312Z","updated_at":"2025-04-01T00:30:59.401Z","avatar_url":"https://github.com/LaunchPlatform.png","language":"Python","funding_links":[],"categories":["Tools"],"sub_categories":["Misc"],"readme":"# beancount-black [![CircleCI](https://circleci.com/gh/LaunchPlatform/beancount-black/tree/master.svg?style=svg)](https://circleci.com/gh/LaunchPlatform/beancount-black/tree/master)\nOpinionated Beancount formatter library, just like Python's [black](https://pypi.org/project/black/) code formatter but for Beancount\n\nTry it out online [here](https://app.beanhub.io/tools/beancount-formatter)\n\n\u003e [!WARNING]  \n\u003e Bean-black command-line is deprecated and will remain as is, with no feature updates.\n\u003e It's subject to removal in future versions.\n\u003e In the future, the `beancount-black` package will focus on serving as a Beancount formatter library.\n\u003e Please use [beanhub-cli](https://github.com/LaunchPlatform/beanhub-cli) instead if you need a formatter command-line tool.\n\u003e Newer features like file [traversal](https://beanhub-cli-docs.beanhub.io/commands/format/), [account, or commodity renaming](https://beanhub-cli-docs.beanhub.io/commands/format/#rename-account-and-currency-commodity) are only be available with `beanhub-cli`.\n\n## Features\n\n- **MIT licensed** - based on [beancount-parser](https://github.com/LaunchPlatform/beancount-parser), a [Lark](https://github.com/lark-parser/lark) based LALR(1) Beancount syntax parser\n- **Extremely fast** - 5K+ lines file generated by `bean-example` can be formatted in around 1 second\n- **Section awareness** - entries separated by Emac org symbol mark `*` will be formatted in groups without changing the overall structure\n- **Comment preserving** - comments are preserved and will be formatted as well\n- **Auto column width** - calculate maximum column width and adjust accordingly\n- **Valid beancount file assumed** - please notice that the formatter assumes the given beacnount file is valid, it doesn't not perform any kind of validation\n\n# Sponsor\n\nThe original project beancount-black was meant to be an internal tool built by [Launch Platform LLC](https://launchplatform.com) for \n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://beanhub.io\"\u003e\u003cimg src=\"https://github.com/LaunchPlatform/beancount-black/raw/master/assets/beanhub.svg?raw=true\" alt=\"BeanHub logo\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nA modern accounting book service based on the most popular open source version control system [Git](https://git-scm.com/) and text-based double entry accounting book software [Beancount](https://beancount.github.io/docs/index.html).\nWe realized adding new entries with BeanHub automatically over time makes the beancount file a mess.\nSo, a strong code formatter is needed.\nWhile SaaS businesses won't be required to open-source an internal tool like this, we still love that the service is only possible because of the open-source tool we are using.\nIt would be greatly beneficial for the community to access a tool like this, so we've decided to open-source it under an MIT license. We hope you find this tool useful 😄\n\n## Install\n\nTo install the formatter, simply run\n\n```bash\npip install beancount-black\n```\n\n## Usage\n\nRun\n\n```bash\nbean-black /path/to/file.bean\n```\n\nThen the file will be formatted.\nSince this tool is still in its early stage, a backup file at `\u003cfilepath\u003e.backup` will be created automatically by default just in case.\nThe creation of backup files can be disabled by passing `-n` or `--no-backup` like this\n\n```bash\nbean-black -n /path/to/file.bean\n```\n\nIt's highly recommended to use [BeanHub](https://beanhub.io), Git or other version control system to track your Beancount book files before running the formatter against them without a backup.\n\nIf you want to run the formatter programmatically, you can do this\n\n```python\nimport io\n\nfrom beancount_parser.parser import make_parser\nfrom beancount_black.formatter import Formatter\n\nparser = make_parser()\nformatter = Formatter()\n\ntree = parser.parse(beancount_content)\noutput_file = io.StringIO()\nformatter.format(tree, output_file)\n```\n\n## Stdin mode\n\nYou can run the formatter in STDIN mode by passing `-s` or `--stdin-mode` argument like this:\n\n```bash\nbean-black -s\n```\n\n## Debug\n\nSometimes you might encounter problems when formatting some beancount files.\nTo debug and better understand which line is causing the problem, you can change the log level by passing `-l` argument with `debug` or `verbose`.\nFor example:\n\n```bash\nbean-black -n /path/to/file.bean -l verbose\n```\n\nWith `verbose`, details of the parsed object will be printed.\nWith `debug`, only the line number and type of entry will be printed.\nYou can also use `LOG_LEVEL` environment variable as well.\nThe available log level options are:\n\n- verbose\n- debug\n- info (default)\n- error\n- warning\n- fatal\n\n## Future features\n\n- Add argument for renaming account and commodity\n- Add argument for following other files from `include` statements and also format those files\n \nFeedbacks, bugs reporting or feature requests are welcome 🙌, just please open an issue.\nNo guarantee we have time to deal with them, but will see what we can do.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLaunchPlatform%2Fbeancount-black","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLaunchPlatform%2Fbeancount-black","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLaunchPlatform%2Fbeancount-black/lists"}