-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
""" | ||
Beancount to Ledger converter | ||
""" | ||
|
||
# SPDX-FileCopyrightText: © 2020 Software in the Public Interest, Inc. | ||
# SPDX-FileCopyrightText: © 2020 Martin Michlmayr <tbm@cyrius.com> | ||
|
||
# SPDX-License-Identifier: GPL-2.0-only | ||
|
||
__license__ = "GPL-2.0-only" | ||
|
||
import argparse | ||
import sys | ||
|
||
import beancount2ledger | ||
|
||
|
||
def cli(): | ||
""" | ||
Main function for CLI access. | ||
""" | ||
|
||
if "hledger" in sys.argv[0]: | ||
default = "hledger" | ||
else: | ||
default = "ledger" | ||
|
||
parser = argparse.ArgumentParser(description=__doc__) | ||
parser.add_argument( | ||
'-f', | ||
"--format", | ||
dest="format", | ||
action="store", | ||
choices=("ledger", "hledger"), | ||
default=default, | ||
help=f"output format (default: {default})") | ||
parser.add_argument( | ||
'file', help='beancount file', type=argparse.FileType('r')) | ||
args = parser.parse_args() | ||
|
||
print(beancount2ledger.convert_file(args.file.name, args.format)) | ||
|
||
|
||
if __name__ == "__main__": | ||
cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
beancount2ledger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env python3 | ||
|
||
""" | ||
Beancount to Ledger converter | ||
""" | ||
|
||
# SPDX-FileCopyrightText: © 2020 Software in the Public Interest, Inc. | ||
# SPDX-FileCopyrightText: © 2020 Martin Michlmayr <tbm@cyrius.com> | ||
|
||
# SPDX-License-Identifier: GPL-2.0-only | ||
|
||
from beancount2ledger.cli import cli | ||
|
||
cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
beancount2ledger.1.sdc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
beancount2ledger(1) | ||
|
||
; SPDX-FileCopyrightText: © 2020 Martin Michlmayr <tbm@cyrius.com> | ||
|
||
; SPDX-License-Identifier: GPL-2.0-only | ||
|
||
# NAME | ||
|
||
beancount2ledger - beancount to ledger converter | ||
|
||
# SYNOPSIS | ||
|
||
*beancount2ledger* [options] _input.beancount_ > _output.ledger_ | ||
|
||
# DESCRIPTION | ||
|
||
*beancount2ledger* converts a file in *beancount* format to the *ledger* file format. | ||
|
||
# OPTIONS | ||
|
||
*-f, --format* | ||
Specify the output format. Allowed values are _ledger_ and _hledger_. | ||
|
||
When *beancount2ledger* is called, the default format is _ledger_ whereas the default format is _hledger_ when *beancount2hledger* is called. | ||
|
||
*-h, --help* | ||
Show help message and quit. | ||
|
||
# USAGE | ||
|
||
*beancount2ledger* takes a file argument, loads the file into *beancount* data structures, and converts the data to *ledger* output. | ||
|
||
# BUGS | ||
|
||
If you find any bugs in *beancount2ledger* or believe the conversion from *beancount* to *ledger* could be improved, please open an issue on GitHub: | ||
|
||
https://github.com/beancount/beancount2ledger/issues | ||
|
||
Please include a small test case so we can reproduce the problem. | ||
|
||
# AUTHORS | ||
|
||
Martin Blais, Martin Michlmayr, and others | ||
|
||
# SEE ALSO | ||
|
||
*ledger*(1), *hledger*(1) | ||
|