ledgerkit 1.0.0.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ledgerkit-1.0.0.dev1/LICENSE +21 -0
- ledgerkit-1.0.0.dev1/MANIFEST.in +5 -0
- ledgerkit-1.0.0.dev1/PKG-INFO +203 -0
- ledgerkit-1.0.0.dev1/README.md +176 -0
- ledgerkit-1.0.0.dev1/ledgerkit/__init__.py +51 -0
- ledgerkit-1.0.0.dev1/ledgerkit/__main__.py +12 -0
- ledgerkit-1.0.0.dev1/ledgerkit/_pandas_compat.py +21 -0
- ledgerkit-1.0.0.dev1/ledgerkit/checks.py +617 -0
- ledgerkit-1.0.0.dev1/ledgerkit/cli.py +448 -0
- ledgerkit-1.0.0.dev1/ledgerkit/commodity_style.py +274 -0
- ledgerkit-1.0.0.dev1/ledgerkit/editor_model.py +193 -0
- ledgerkit-1.0.0.dev1/ledgerkit/loader.py +311 -0
- ledgerkit-1.0.0.dev1/ledgerkit/models.py +459 -0
- ledgerkit-1.0.0.dev1/ledgerkit/parser.py +1547 -0
- ledgerkit-1.0.0.dev1/ledgerkit/reports.py +573 -0
- ledgerkit-1.0.0.dev1/ledgerkit/writer.py +97 -0
- ledgerkit-1.0.0.dev1/ledgerkit.egg-info/PKG-INFO +203 -0
- ledgerkit-1.0.0.dev1/ledgerkit.egg-info/SOURCES.txt +27 -0
- ledgerkit-1.0.0.dev1/ledgerkit.egg-info/dependency_links.txt +1 -0
- ledgerkit-1.0.0.dev1/ledgerkit.egg-info/entry_points.txt +2 -0
- ledgerkit-1.0.0.dev1/ledgerkit.egg-info/requires.txt +3 -0
- ledgerkit-1.0.0.dev1/ledgerkit.egg-info/top_level.txt +1 -0
- ledgerkit-1.0.0.dev1/pyproject.toml +52 -0
- ledgerkit-1.0.0.dev1/setup.cfg +4 -0
- ledgerkit-1.0.0.dev1/tests/test_commodity_style.py +248 -0
- ledgerkit-1.0.0.dev1/tests/test_dataframe.py +267 -0
- ledgerkit-1.0.0.dev1/tests/test_editor_model.py +347 -0
- ledgerkit-1.0.0.dev1/tests/test_reports.py +942 -0
- ledgerkit-1.0.0.dev1/tests/test_writer.py +206 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Cormac O' Sullivan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Exclude AI-workflow files from the source distribution (sdist).
|
|
2
|
+
# The ledgerkit/ package, tests/, docs/ (human docs), README.md,
|
|
3
|
+
# LICENSE, and pyproject.toml are included by setuptools automatically.
|
|
4
|
+
exclude CLAUDE.md CHANGELOG.md ROADMAP.md
|
|
5
|
+
recursive-exclude dev-docs *
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ledgerkit
|
|
3
|
+
Version: 1.0.0.dev1
|
|
4
|
+
Summary: Python parser and library for hledger journal files — CLI tools, DataFrame export, and a clean data model for the Python ecosystem
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/ctosullivan/ledgerkit
|
|
7
|
+
Project-URL: Repository, https://github.com/ctosullivan/ledgerkit
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/ctosullivan/ledgerkit/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/ctosullivan/ledgerkit/blob/main/CHANGELOG.md
|
|
10
|
+
Keywords: hledger,ledger,accounting,plain-text-accounting,finance,pandas
|
|
11
|
+
Classifier: Topic :: Office/Business :: Financial :: Accounting
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
19
|
+
Classifier: Intended Audience :: Developers
|
|
20
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Provides-Extra: pandas
|
|
25
|
+
Requires-Dist: pandas>=1.3; extra == "pandas"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# ledgerkit
|
|
29
|
+
|
|
30
|
+
[](https://github.com/ctosullivan/ledgerkit/actions/workflows/tests.yml)
|
|
31
|
+
|
|
32
|
+
A Python implementation of the [hledger](https://hledger.org) plain-text accounting tool.
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
- Parse `.journal` files compatible with the hledger 1.52 format
|
|
37
|
+
- Comprehensive directive support: `include`, `account`, `commodity`, `payee`,
|
|
38
|
+
`alias`, `P`, `Y`, `D`, `apply account`
|
|
39
|
+
- Core CLI commands: `balance`, `register`, `print`, `accounts`, `stats`, `check`
|
|
40
|
+
- Strict mode (`-s`) and balance assertions
|
|
41
|
+
- Multi-commodity balances with tree rollup
|
|
42
|
+
- Commodity display style inference and `-c` override flag
|
|
43
|
+
- Optional pandas DataFrame export (`pip install ledgerkit[pandas]`)
|
|
44
|
+
- Editor-integration layer: lenient parser, round-trip writer, `EditorDocument`
|
|
45
|
+
- Pure Python — no third-party runtime dependencies
|
|
46
|
+
- Python 3.8–3.12
|
|
47
|
+
|
|
48
|
+
## Requirements
|
|
49
|
+
|
|
50
|
+
- Python 3.8+
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install ledgerkit
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
With optional pandas support:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install ledgerkit[pandas]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Development install
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
git clone https://github.com/ctosullivan/ledgerkit.git
|
|
68
|
+
cd ledgerkit
|
|
69
|
+
pip install -e ".[pandas]"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Usage
|
|
73
|
+
|
|
74
|
+
### CLI
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
ledgerkit balance myfile.journal
|
|
78
|
+
ledgerkit register myfile.journal
|
|
79
|
+
ledgerkit accounts myfile.journal
|
|
80
|
+
ledgerkit print myfile.journal
|
|
81
|
+
ledgerkit stats myfile.journal
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
You can also invoke ledgerkit as a Python module:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
python -m ledgerkit balance myfile.journal
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Python library
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
import ledgerkit
|
|
94
|
+
|
|
95
|
+
journal = ledgerkit.load("myfile.journal")
|
|
96
|
+
accounts = journal.accounts()
|
|
97
|
+
balance = journal.balance()
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
See [docs/python-api.md](docs/python-api.md) for the full library reference.
|
|
101
|
+
|
|
102
|
+
## Documentation
|
|
103
|
+
|
|
104
|
+
| Guide | Description |
|
|
105
|
+
|---|---|
|
|
106
|
+
| [docs/getting-started.md](docs/getting-started.md) | Installation, first run, verification |
|
|
107
|
+
| [docs/usage.md](docs/usage.md) | CLI commands with examples |
|
|
108
|
+
| [docs/journal-format.md](docs/journal-format.md) | Supported journal syntax with annotated examples |
|
|
109
|
+
| [docs/python-api.md](docs/python-api.md) | Python library reference |
|
|
110
|
+
|
|
111
|
+
## Python ecosystem (pandas)
|
|
112
|
+
|
|
113
|
+
Install the optional pandas extra for DataFrame export:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
pip install ledgerkit[pandas]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Then:
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
import ledgerkit
|
|
123
|
+
|
|
124
|
+
journal = ledgerkit.load("myfile.journal")
|
|
125
|
+
|
|
126
|
+
# Export all postings to a DataFrame
|
|
127
|
+
df = journal.to_dataframe()
|
|
128
|
+
print(df.groupby("account")["amount"].sum())
|
|
129
|
+
|
|
130
|
+
# Or export directly from a report object
|
|
131
|
+
balance_df = journal.balance().to_dataframe()
|
|
132
|
+
register_df = journal.register().to_dataframe()
|
|
133
|
+
accounts_df = journal.accounts().to_dataframe()
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Development
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Run all tests
|
|
140
|
+
python -m unittest discover -s tests -t . -v
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
See [dev-docs/architecture.md](dev-docs/architecture.md) for module design and
|
|
144
|
+
[dev-docs/api-spec.md](dev-docs/api-spec.md) for the full API specification.
|
|
145
|
+
|
|
146
|
+
## Hledger Compatibility
|
|
147
|
+
|
|
148
|
+
See [dev-docs/hledger-compatibility.md](dev-docs/hledger-compatibility.md) for which
|
|
149
|
+
hledger journal features are supported in v1.
|
|
150
|
+
|
|
151
|
+
## Contributing
|
|
152
|
+
|
|
153
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for pull request guidelines, commit
|
|
154
|
+
message format, and branch naming. This project follows the
|
|
155
|
+
[Contributor Code of Conduct](CODE_OF_CONDUCT.md).
|
|
156
|
+
|
|
157
|
+
### With AI tooling (Claude Code)
|
|
158
|
+
|
|
159
|
+
Clone the full repository including AI-workflow files:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
git clone https://github.com/ctosullivan/ledgerkit.git
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Without AI tooling
|
|
166
|
+
|
|
167
|
+
Use sparse checkout to clone only the source code, tests, and human docs
|
|
168
|
+
(excludes `CLAUDE.md`, `dev-docs/`, `CHANGELOG.md`, `ROADMAP.md`):
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
git clone --filter=blob:none --sparse https://github.com/ctosullivan/ledgerkit.git
|
|
172
|
+
cd ledgerkit
|
|
173
|
+
git sparse-checkout set ledgerkit tests docs README.md LICENSE pyproject.toml
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Acknowledgements
|
|
177
|
+
|
|
178
|
+
ledgerkit is a Python implementation inspired by two pioneering plain-text
|
|
179
|
+
accounting projects. We gratefully acknowledge their authors and contributors.
|
|
180
|
+
|
|
181
|
+
### Ledger
|
|
182
|
+
|
|
183
|
+
**John Wiegley** created Ledger, the original plain-text double-entry accounting
|
|
184
|
+
tool, which established the journal file format and accounting model that this
|
|
185
|
+
ecosystem is built upon.
|
|
186
|
+
|
|
187
|
+
https://github.com/ledger/ledger
|
|
188
|
+
|
|
189
|
+
### hledger
|
|
190
|
+
|
|
191
|
+
**Simon Michael** created hledger, a Haskell implementation of Ledger's concepts,
|
|
192
|
+
which has since evolved its own rich feature set and extensive documentation.
|
|
193
|
+
ledgerkit's journal format support is modelled primarily on the hledger 1.52
|
|
194
|
+
specification.
|
|
195
|
+
|
|
196
|
+
https://github.com/simonmichael/hledger
|
|
197
|
+
|
|
198
|
+
A full list of hledger contributors can be found at:
|
|
199
|
+
|
|
200
|
+
https://github.com/simonmichael/hledger/blob/main/doc/CREDITS.md
|
|
201
|
+
|
|
202
|
+
Their work — and the broader plain-text accounting community — makes ledgerkit
|
|
203
|
+
possible.
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# ledgerkit
|
|
2
|
+
|
|
3
|
+
[](https://github.com/ctosullivan/ledgerkit/actions/workflows/tests.yml)
|
|
4
|
+
|
|
5
|
+
A Python implementation of the [hledger](https://hledger.org) plain-text accounting tool.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Parse `.journal` files compatible with the hledger 1.52 format
|
|
10
|
+
- Comprehensive directive support: `include`, `account`, `commodity`, `payee`,
|
|
11
|
+
`alias`, `P`, `Y`, `D`, `apply account`
|
|
12
|
+
- Core CLI commands: `balance`, `register`, `print`, `accounts`, `stats`, `check`
|
|
13
|
+
- Strict mode (`-s`) and balance assertions
|
|
14
|
+
- Multi-commodity balances with tree rollup
|
|
15
|
+
- Commodity display style inference and `-c` override flag
|
|
16
|
+
- Optional pandas DataFrame export (`pip install ledgerkit[pandas]`)
|
|
17
|
+
- Editor-integration layer: lenient parser, round-trip writer, `EditorDocument`
|
|
18
|
+
- Pure Python — no third-party runtime dependencies
|
|
19
|
+
- Python 3.8–3.12
|
|
20
|
+
|
|
21
|
+
## Requirements
|
|
22
|
+
|
|
23
|
+
- Python 3.8+
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install ledgerkit
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
With optional pandas support:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install ledgerkit[pandas]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Development install
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
git clone https://github.com/ctosullivan/ledgerkit.git
|
|
41
|
+
cd ledgerkit
|
|
42
|
+
pip install -e ".[pandas]"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
### CLI
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
ledgerkit balance myfile.journal
|
|
51
|
+
ledgerkit register myfile.journal
|
|
52
|
+
ledgerkit accounts myfile.journal
|
|
53
|
+
ledgerkit print myfile.journal
|
|
54
|
+
ledgerkit stats myfile.journal
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
You can also invoke ledgerkit as a Python module:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
python -m ledgerkit balance myfile.journal
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Python library
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
import ledgerkit
|
|
67
|
+
|
|
68
|
+
journal = ledgerkit.load("myfile.journal")
|
|
69
|
+
accounts = journal.accounts()
|
|
70
|
+
balance = journal.balance()
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
See [docs/python-api.md](docs/python-api.md) for the full library reference.
|
|
74
|
+
|
|
75
|
+
## Documentation
|
|
76
|
+
|
|
77
|
+
| Guide | Description |
|
|
78
|
+
|---|---|
|
|
79
|
+
| [docs/getting-started.md](docs/getting-started.md) | Installation, first run, verification |
|
|
80
|
+
| [docs/usage.md](docs/usage.md) | CLI commands with examples |
|
|
81
|
+
| [docs/journal-format.md](docs/journal-format.md) | Supported journal syntax with annotated examples |
|
|
82
|
+
| [docs/python-api.md](docs/python-api.md) | Python library reference |
|
|
83
|
+
|
|
84
|
+
## Python ecosystem (pandas)
|
|
85
|
+
|
|
86
|
+
Install the optional pandas extra for DataFrame export:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pip install ledgerkit[pandas]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Then:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
import ledgerkit
|
|
96
|
+
|
|
97
|
+
journal = ledgerkit.load("myfile.journal")
|
|
98
|
+
|
|
99
|
+
# Export all postings to a DataFrame
|
|
100
|
+
df = journal.to_dataframe()
|
|
101
|
+
print(df.groupby("account")["amount"].sum())
|
|
102
|
+
|
|
103
|
+
# Or export directly from a report object
|
|
104
|
+
balance_df = journal.balance().to_dataframe()
|
|
105
|
+
register_df = journal.register().to_dataframe()
|
|
106
|
+
accounts_df = journal.accounts().to_dataframe()
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Development
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Run all tests
|
|
113
|
+
python -m unittest discover -s tests -t . -v
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
See [dev-docs/architecture.md](dev-docs/architecture.md) for module design and
|
|
117
|
+
[dev-docs/api-spec.md](dev-docs/api-spec.md) for the full API specification.
|
|
118
|
+
|
|
119
|
+
## Hledger Compatibility
|
|
120
|
+
|
|
121
|
+
See [dev-docs/hledger-compatibility.md](dev-docs/hledger-compatibility.md) for which
|
|
122
|
+
hledger journal features are supported in v1.
|
|
123
|
+
|
|
124
|
+
## Contributing
|
|
125
|
+
|
|
126
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for pull request guidelines, commit
|
|
127
|
+
message format, and branch naming. This project follows the
|
|
128
|
+
[Contributor Code of Conduct](CODE_OF_CONDUCT.md).
|
|
129
|
+
|
|
130
|
+
### With AI tooling (Claude Code)
|
|
131
|
+
|
|
132
|
+
Clone the full repository including AI-workflow files:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
git clone https://github.com/ctosullivan/ledgerkit.git
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Without AI tooling
|
|
139
|
+
|
|
140
|
+
Use sparse checkout to clone only the source code, tests, and human docs
|
|
141
|
+
(excludes `CLAUDE.md`, `dev-docs/`, `CHANGELOG.md`, `ROADMAP.md`):
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
git clone --filter=blob:none --sparse https://github.com/ctosullivan/ledgerkit.git
|
|
145
|
+
cd ledgerkit
|
|
146
|
+
git sparse-checkout set ledgerkit tests docs README.md LICENSE pyproject.toml
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Acknowledgements
|
|
150
|
+
|
|
151
|
+
ledgerkit is a Python implementation inspired by two pioneering plain-text
|
|
152
|
+
accounting projects. We gratefully acknowledge their authors and contributors.
|
|
153
|
+
|
|
154
|
+
### Ledger
|
|
155
|
+
|
|
156
|
+
**John Wiegley** created Ledger, the original plain-text double-entry accounting
|
|
157
|
+
tool, which established the journal file format and accounting model that this
|
|
158
|
+
ecosystem is built upon.
|
|
159
|
+
|
|
160
|
+
https://github.com/ledger/ledger
|
|
161
|
+
|
|
162
|
+
### hledger
|
|
163
|
+
|
|
164
|
+
**Simon Michael** created hledger, a Haskell implementation of Ledger's concepts,
|
|
165
|
+
which has since evolved its own rich feature set and extensive documentation.
|
|
166
|
+
ledgerkit's journal format support is modelled primarily on the hledger 1.52
|
|
167
|
+
specification.
|
|
168
|
+
|
|
169
|
+
https://github.com/simonmichael/hledger
|
|
170
|
+
|
|
171
|
+
A full list of hledger contributors can be found at:
|
|
172
|
+
|
|
173
|
+
https://github.com/simonmichael/hledger/blob/main/doc/CREDITS.md
|
|
174
|
+
|
|
175
|
+
Their work — and the broader plain-text accounting community — makes ledgerkit
|
|
176
|
+
possible.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""ledgerkit: a Python implementation of the hledger plain-text accounting tool."""
|
|
2
|
+
|
|
3
|
+
from ledgerkit.loader import load_journal as load
|
|
4
|
+
from ledgerkit.models import (
|
|
5
|
+
BalanceAssertion,
|
|
6
|
+
BalanceRow,
|
|
7
|
+
Query,
|
|
8
|
+
RegisterRow,
|
|
9
|
+
ReportSection,
|
|
10
|
+
ReportSpec,
|
|
11
|
+
ReportSectionResult,
|
|
12
|
+
SourceSpan,
|
|
13
|
+
)
|
|
14
|
+
from ledgerkit.parser import parse_string_lenient, resolve_elision
|
|
15
|
+
from ledgerkit.reports import (
|
|
16
|
+
AccountsResult,
|
|
17
|
+
BalanceResult,
|
|
18
|
+
JournalStats,
|
|
19
|
+
RegisterResult,
|
|
20
|
+
balance_from_spec,
|
|
21
|
+
)
|
|
22
|
+
from ledgerkit.checks import CheckError, check_transaction_autobalanced
|
|
23
|
+
from ledgerkit.writer import journal_to_text, transaction_to_text
|
|
24
|
+
from ledgerkit.editor_model import EditorDocument
|
|
25
|
+
from ledgerkit.commodity_style import CommodityStyle
|
|
26
|
+
|
|
27
|
+
__version__ = "1.0.0.dev1"
|
|
28
|
+
__all__ = [
|
|
29
|
+
"load",
|
|
30
|
+
"AccountsResult",
|
|
31
|
+
"BalanceAssertion",
|
|
32
|
+
"BalanceResult",
|
|
33
|
+
"BalanceRow",
|
|
34
|
+
"CheckError",
|
|
35
|
+
"CommodityStyle",
|
|
36
|
+
"EditorDocument",
|
|
37
|
+
"JournalStats",
|
|
38
|
+
"RegisterResult",
|
|
39
|
+
"RegisterRow",
|
|
40
|
+
"ReportSection",
|
|
41
|
+
"ReportSpec",
|
|
42
|
+
"ReportSectionResult",
|
|
43
|
+
"SourceSpan",
|
|
44
|
+
"balance_from_spec",
|
|
45
|
+
"check_transaction_autobalanced",
|
|
46
|
+
"journal_to_text",
|
|
47
|
+
"parse_string_lenient",
|
|
48
|
+
"resolve_elision",
|
|
49
|
+
"transaction_to_text",
|
|
50
|
+
"__version__",
|
|
51
|
+
]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Lazy import helper for optional pandas dependency."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
import pandas as pd # noqa: F401 — type hints only
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def require_pandas():
|
|
12
|
+
"""Import and return the pandas module, raising ImportError with a helpful
|
|
13
|
+
message if it is not installed."""
|
|
14
|
+
try:
|
|
15
|
+
import pandas as pd
|
|
16
|
+
return pd
|
|
17
|
+
except ImportError:
|
|
18
|
+
raise ImportError(
|
|
19
|
+
"pandas is required for DataFrame export. "
|
|
20
|
+
"Install it with: pip install ledgerkit[pandas]"
|
|
21
|
+
) from None
|