extf 0.1.0__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.
extf-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
extf-0.1.0/MANIFEST.in ADDED
@@ -0,0 +1,3 @@
1
+ # The tests of the sdist need their helpers and golden files too.
2
+ graft tests
3
+ global-exclude __pycache__ *.py[cod]
extf-0.1.0/NOTICE ADDED
@@ -0,0 +1,9 @@
1
+ extf
2
+ Copyright 2026 ext.dev GmbH
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ extf has no runtime dependencies.
7
+
8
+ DATEV is a trademark of DATEV eG. extf reads and writes files in the DATEV format; it is
9
+ not affiliated with or endorsed by DATEV eG.
extf-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.4
2
+ Name: extf
3
+ Version: 0.1.0
4
+ Summary: Read and write files in the DATEV format (EXTF): bookings, account labels, personal accounts.
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Source, https://github.com/extdev-gmbh/extf
7
+ Project-URL: Changelog, https://github.com/extdev-gmbh/extf/blob/main/CHANGELOG.md
8
+ Keywords: datev,extf,accounting,buchungsstapel
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Topic :: Office/Business :: Financial :: Accounting
13
+ Classifier: Typing :: Typed
14
+ Requires-Python: >=3.12
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ License-File: NOTICE
18
+ Provides-Extra: dev
19
+ Requires-Dist: hypothesis==6.170.14; extra == "dev"
20
+ Requires-Dist: mypy==2.4.1; extra == "dev"
21
+ Requires-Dist: pip-audit==2.10.1; extra == "dev"
22
+ Requires-Dist: pytest==9.2.0; extra == "dev"
23
+ Requires-Dist: ruff==0.17.3; extra == "dev"
24
+ Dynamic: license-file
25
+
26
+ # extf
27
+
28
+ **extf** reads and writes files in the DATEV format (header marker `EXTF`): Buchungsstapel
29
+ (category 21), Kontenbeschriftungen (20), Debitoren/Kreditoren (16), plus the reader side for
30
+ trial balances and fixed-asset lists. Pure Python, no dependencies, Windows-1252, format
31
+ version 700, **byte-deterministic** output, strict validation.
32
+
33
+ extf works with files in the DATEV format; it is **not affiliated with or endorsed by DATEV eG**.
34
+ DATEV is a trademark of DATEV eG.
35
+
36
+ **Limits.** extf is a format library. It is **not tax advice**, has **no GoBD certification**,
37
+ and knows nothing about charts of accounts: account numbers are strings and their length comes
38
+ from the header. Whether a booking is right is the caller's question; whether a file is
39
+ well-formed is extf's.
40
+
41
+ ```bash
42
+ pip install extf
43
+ ```
44
+
45
+ ## Writing
46
+
47
+ ```python
48
+ from datetime import date, datetime
49
+ from decimal import Decimal
50
+
51
+ import extf
52
+
53
+ header = extf.ExportHeader(
54
+ advisor_number=1234567,
55
+ client_number=10001,
56
+ fiscal_year_start=date(2026, 1, 1),
57
+ account_length=4,
58
+ origin="XT",
59
+ exported_by="my software",
60
+ chart="03",
61
+ created=datetime(2026, 8, 3, 9, 15), # stated, never the clock: same input, same bytes
62
+ date_from=date(2026, 7, 1),
63
+ date_to=date(2026, 7, 31),
64
+ )
65
+ records = [
66
+ extf.Record(
67
+ amount=Decimal("119.00"),
68
+ account="4806",
69
+ contra_account="70049",
70
+ tax_key="9",
71
+ booking_date=date(2026, 7, 3),
72
+ document_number=extf.document_number("H 2026.07"), # H-2026-07
73
+ text=extf.clean_text("Wartung Juli"),
74
+ )
75
+ ]
76
+ data: bytes = extf.write_bookings(header, records, allowed_keys={"9"})
77
+ labels: bytes = extf.write_account_labels(header, [extf.Label("4806", "Wartungskosten")])
78
+ accounts: bytes = extf.write_personal_accounts(header, [extf.Personal("70049", "Muster Service GmbH")])
79
+ ```
80
+
81
+ Every writer validates first. `extf.validate(header, records, labels, personal)` does so alone.
82
+ Either raises `extf.ExtfError`, whose `errors` name every bad line; nothing is written then.
83
+ Kontenbeschriftungen whose written file would be valid UTF-8 beyond ASCII, such as the label
84
+ `über` alone, are refused too: their text would be read back as UTF-8, which the reader refuses
85
+ (see Hostile input). The file as a whole decides, so one label such as `Büro` next to it is fine.
86
+ `Record` writes euro amounts only, on the debit side (`S`), with a Generalumkehr as `reversal=True`.
87
+ Tax keys `20` to `29` are refused: the reader takes them as the old notation of a Generalumkehr
88
+ (`29` cancels an entry with tax key 9), so they would not come back as written. State the key and
89
+ `reversal=True` instead; other keys, such as `2`, `200` or `2000`, are not affected.
90
+
91
+ ## Reading
92
+
93
+ ```python
94
+ booking_file = extf.read_bookings(data)
95
+ for booking in booking_file.bookings:
96
+ print(booking.booking_date, booking.debit_account, booking.credit_account, booking.amount)
97
+
98
+ header, labels = extf.read_account_labels(some_bytes)
99
+ header, personal = extf.read_personal_accounts(some_bytes) # category 16 or the Kanzlei-Rechnungswesen list
100
+ balances = extf.read_trial_balance(some_bytes, account_length=4) # CSV lists have no header to say so
101
+ assets = extf.read_fixed_assets(some_bytes, account_length=4)
102
+ ```
103
+
104
+ Inputs are `bytes`, outputs are frozen dataclasses: `Decimal` amounts, `date` dates, account numbers
105
+ as strings. A file with one bad line is refused as a whole with `extf.DatevFormatError`, a subclass
106
+ of `ExtfError`, naming up to 200 bad lines. Records with Skonto, for example, are refused rather
107
+ than rebuilt.
108
+
109
+ ## Hostile input
110
+
111
+ Readers treat every input as hostile. The library does no network or file access, evaluates
112
+ nothing from the input and keeps no global state. Refused with `DatevFormatError`:
113
+
114
+ - more than `MAX_INPUT_BYTES` (64 MiB), `MAX_LINES` (1,000,000) lines, `MAX_COLUMNS` (512) columns
115
+ in a line or `MAX_FIELD_LENGTH` (4096) characters in a field;
116
+ - a row of more than 4,195,841 characters, line ends included, before it is parsed. That is the
117
+ longest row within those two limits, every cell quoted and every character a doubled quote, so
118
+ this refuses no row they allow; the message names both limits, as the reader does not know which
119
+ of them was broken;
120
+ - a CSV list without its header row within `MAX_HEADER_SEARCH` (1 MiB) characters, the header row
121
+ included, where a separator and a line end count as one each. So a file without a header row is
122
+ refused after a bounded amount of work, and a later violation of a limit is not reported;
123
+ - a DATEV-format file that is not Windows-1252, including one that is valid UTF-8, even if its
124
+ bytes are also valid Windows-1252; `validate` keeps the writers from producing such a file;
125
+ - a wrong category, a format version outside `FORMAT_VERSIONS` (500 to 700), an account length
126
+ outside 4 to 8, and fields longer than their column.
127
+
128
+ On any bytes, a reader returns a value or raises `DatevFormatError`; property tests hold it to
129
+ that. `parse_amount` is a plain helper on a `str` and raises `ValueError`.
130
+
131
+ Rows are read one at a time, and reading stops at the first limit or at the 200th bad line. The
132
+ input is still decoded and buffered as a whole, and the values of an accepted file are held until
133
+ they are returned. Peak memory to plan for, measured in `python:3.12-slim` with the interpreter
134
+ included. The decoded text takes twice the memory as soon as it holds one character outside
135
+ Latin-1, such as `€` or `–`, and four times as soon as it holds one beyond the Basic Multilingual
136
+ Plane, such as an emoji. Only a CSV list can do the latter, as it may be UTF-8; the DATEV format is
137
+ Windows-1252. A file in plain ASCII stays below the higher figures:
138
+
139
+ - for a file at `MAX_INPUT_BYTES` that is refused early or has no valid records, roughly 470 MiB in
140
+ ASCII, roughly 590 MiB with characters such as `€` and roughly 850 MiB for a CSV list with a
141
+ character beyond the Basic Multilingual Plane;
142
+ - roughly 900 MiB for an accepted file at `MAX_LINES` with short records; when its records also
143
+ fill `MAX_INPUT_BYTES` with short fields, up to roughly 1.2 GiB in ASCII and roughly 1.4 GiB with
144
+ such characters in those fields;
145
+ - as much as for an accepted file when a file is refused only near its end: what is valid up to
146
+ there is held until then.
147
+
148
+ A caller who cannot afford this limits the input before calling.
149
+
150
+ ## Stability
151
+
152
+ What `extf` exports at the package root is the public API, under
153
+ [semantic versioning](https://semver.org/); every other module is private. The bytes a writer
154
+ produces are part of the contract: golden-file tests guard each one.
155
+
156
+ ## Verifying a release
157
+
158
+ Releases are built by GitHub Actions and published to PyPI by trusted publishing, with SLSA
159
+ provenance and a CycloneDX SBOM attested:
160
+
161
+ ```bash
162
+ gh attestation verify extf-0.1.0-py3-none-any.whl --repo extdev-gmbh/extf
163
+ ```
164
+
165
+ ## License
166
+
167
+ Licensed under the [Apache License 2.0](LICENSE). Report security issues as described in
168
+ [SECURITY.md](SECURITY.md).
extf-0.1.0/README.md ADDED
@@ -0,0 +1,143 @@
1
+ # extf
2
+
3
+ **extf** reads and writes files in the DATEV format (header marker `EXTF`): Buchungsstapel
4
+ (category 21), Kontenbeschriftungen (20), Debitoren/Kreditoren (16), plus the reader side for
5
+ trial balances and fixed-asset lists. Pure Python, no dependencies, Windows-1252, format
6
+ version 700, **byte-deterministic** output, strict validation.
7
+
8
+ extf works with files in the DATEV format; it is **not affiliated with or endorsed by DATEV eG**.
9
+ DATEV is a trademark of DATEV eG.
10
+
11
+ **Limits.** extf is a format library. It is **not tax advice**, has **no GoBD certification**,
12
+ and knows nothing about charts of accounts: account numbers are strings and their length comes
13
+ from the header. Whether a booking is right is the caller's question; whether a file is
14
+ well-formed is extf's.
15
+
16
+ ```bash
17
+ pip install extf
18
+ ```
19
+
20
+ ## Writing
21
+
22
+ ```python
23
+ from datetime import date, datetime
24
+ from decimal import Decimal
25
+
26
+ import extf
27
+
28
+ header = extf.ExportHeader(
29
+ advisor_number=1234567,
30
+ client_number=10001,
31
+ fiscal_year_start=date(2026, 1, 1),
32
+ account_length=4,
33
+ origin="XT",
34
+ exported_by="my software",
35
+ chart="03",
36
+ created=datetime(2026, 8, 3, 9, 15), # stated, never the clock: same input, same bytes
37
+ date_from=date(2026, 7, 1),
38
+ date_to=date(2026, 7, 31),
39
+ )
40
+ records = [
41
+ extf.Record(
42
+ amount=Decimal("119.00"),
43
+ account="4806",
44
+ contra_account="70049",
45
+ tax_key="9",
46
+ booking_date=date(2026, 7, 3),
47
+ document_number=extf.document_number("H 2026.07"), # H-2026-07
48
+ text=extf.clean_text("Wartung Juli"),
49
+ )
50
+ ]
51
+ data: bytes = extf.write_bookings(header, records, allowed_keys={"9"})
52
+ labels: bytes = extf.write_account_labels(header, [extf.Label("4806", "Wartungskosten")])
53
+ accounts: bytes = extf.write_personal_accounts(header, [extf.Personal("70049", "Muster Service GmbH")])
54
+ ```
55
+
56
+ Every writer validates first. `extf.validate(header, records, labels, personal)` does so alone.
57
+ Either raises `extf.ExtfError`, whose `errors` name every bad line; nothing is written then.
58
+ Kontenbeschriftungen whose written file would be valid UTF-8 beyond ASCII, such as the label
59
+ `über` alone, are refused too: their text would be read back as UTF-8, which the reader refuses
60
+ (see Hostile input). The file as a whole decides, so one label such as `Büro` next to it is fine.
61
+ `Record` writes euro amounts only, on the debit side (`S`), with a Generalumkehr as `reversal=True`.
62
+ Tax keys `20` to `29` are refused: the reader takes them as the old notation of a Generalumkehr
63
+ (`29` cancels an entry with tax key 9), so they would not come back as written. State the key and
64
+ `reversal=True` instead; other keys, such as `2`, `200` or `2000`, are not affected.
65
+
66
+ ## Reading
67
+
68
+ ```python
69
+ booking_file = extf.read_bookings(data)
70
+ for booking in booking_file.bookings:
71
+ print(booking.booking_date, booking.debit_account, booking.credit_account, booking.amount)
72
+
73
+ header, labels = extf.read_account_labels(some_bytes)
74
+ header, personal = extf.read_personal_accounts(some_bytes) # category 16 or the Kanzlei-Rechnungswesen list
75
+ balances = extf.read_trial_balance(some_bytes, account_length=4) # CSV lists have no header to say so
76
+ assets = extf.read_fixed_assets(some_bytes, account_length=4)
77
+ ```
78
+
79
+ Inputs are `bytes`, outputs are frozen dataclasses: `Decimal` amounts, `date` dates, account numbers
80
+ as strings. A file with one bad line is refused as a whole with `extf.DatevFormatError`, a subclass
81
+ of `ExtfError`, naming up to 200 bad lines. Records with Skonto, for example, are refused rather
82
+ than rebuilt.
83
+
84
+ ## Hostile input
85
+
86
+ Readers treat every input as hostile. The library does no network or file access, evaluates
87
+ nothing from the input and keeps no global state. Refused with `DatevFormatError`:
88
+
89
+ - more than `MAX_INPUT_BYTES` (64 MiB), `MAX_LINES` (1,000,000) lines, `MAX_COLUMNS` (512) columns
90
+ in a line or `MAX_FIELD_LENGTH` (4096) characters in a field;
91
+ - a row of more than 4,195,841 characters, line ends included, before it is parsed. That is the
92
+ longest row within those two limits, every cell quoted and every character a doubled quote, so
93
+ this refuses no row they allow; the message names both limits, as the reader does not know which
94
+ of them was broken;
95
+ - a CSV list without its header row within `MAX_HEADER_SEARCH` (1 MiB) characters, the header row
96
+ included, where a separator and a line end count as one each. So a file without a header row is
97
+ refused after a bounded amount of work, and a later violation of a limit is not reported;
98
+ - a DATEV-format file that is not Windows-1252, including one that is valid UTF-8, even if its
99
+ bytes are also valid Windows-1252; `validate` keeps the writers from producing such a file;
100
+ - a wrong category, a format version outside `FORMAT_VERSIONS` (500 to 700), an account length
101
+ outside 4 to 8, and fields longer than their column.
102
+
103
+ On any bytes, a reader returns a value or raises `DatevFormatError`; property tests hold it to
104
+ that. `parse_amount` is a plain helper on a `str` and raises `ValueError`.
105
+
106
+ Rows are read one at a time, and reading stops at the first limit or at the 200th bad line. The
107
+ input is still decoded and buffered as a whole, and the values of an accepted file are held until
108
+ they are returned. Peak memory to plan for, measured in `python:3.12-slim` with the interpreter
109
+ included. The decoded text takes twice the memory as soon as it holds one character outside
110
+ Latin-1, such as `€` or `–`, and four times as soon as it holds one beyond the Basic Multilingual
111
+ Plane, such as an emoji. Only a CSV list can do the latter, as it may be UTF-8; the DATEV format is
112
+ Windows-1252. A file in plain ASCII stays below the higher figures:
113
+
114
+ - for a file at `MAX_INPUT_BYTES` that is refused early or has no valid records, roughly 470 MiB in
115
+ ASCII, roughly 590 MiB with characters such as `€` and roughly 850 MiB for a CSV list with a
116
+ character beyond the Basic Multilingual Plane;
117
+ - roughly 900 MiB for an accepted file at `MAX_LINES` with short records; when its records also
118
+ fill `MAX_INPUT_BYTES` with short fields, up to roughly 1.2 GiB in ASCII and roughly 1.4 GiB with
119
+ such characters in those fields;
120
+ - as much as for an accepted file when a file is refused only near its end: what is valid up to
121
+ there is held until then.
122
+
123
+ A caller who cannot afford this limits the input before calling.
124
+
125
+ ## Stability
126
+
127
+ What `extf` exports at the package root is the public API, under
128
+ [semantic versioning](https://semver.org/); every other module is private. The bytes a writer
129
+ produces are part of the contract: golden-file tests guard each one.
130
+
131
+ ## Verifying a release
132
+
133
+ Releases are built by GitHub Actions and published to PyPI by trusted publishing, with SLSA
134
+ provenance and a CycloneDX SBOM attested:
135
+
136
+ ```bash
137
+ gh attestation verify extf-0.1.0-py3-none-any.whl --repo extdev-gmbh/extf
138
+ ```
139
+
140
+ ## License
141
+
142
+ Licensed under the [Apache License 2.0](LICENSE). Report security issues as described in
143
+ [SECURITY.md](SECURITY.md).
@@ -0,0 +1,75 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "extf"
7
+ dynamic = ["version"]
8
+ description = "Read and write files in the DATEV format (EXTF): bookings, account labels, personal accounts."
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ license-files = ["LICENSE", "NOTICE"]
12
+ requires-python = ">=3.12"
13
+ dependencies = []
14
+ keywords = ["datev", "extf", "accounting", "buchungsstapel"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Topic :: Office/Business :: Financial :: Accounting",
20
+ "Typing :: Typed",
21
+ ]
22
+
23
+ [project.optional-dependencies]
24
+ dev = [
25
+ "hypothesis==6.170.14",
26
+ "mypy==2.4.1",
27
+ "pip-audit==2.10.1",
28
+ "pytest==9.2.0",
29
+ "ruff==0.17.3",
30
+ ]
31
+
32
+ [project.urls]
33
+ Source = "https://github.com/extdev-gmbh/extf"
34
+ Changelog = "https://github.com/extdev-gmbh/extf/blob/main/CHANGELOG.md"
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = ["src"]
38
+
39
+ [tool.setuptools.dynamic]
40
+ version = { attr = "extf.__version__" }
41
+
42
+ [tool.setuptools.package-data]
43
+ extf = ["py.typed"]
44
+
45
+ [tool.pytest.ini_options]
46
+ testpaths = ["tests"]
47
+ pythonpath = ["src"]
48
+ filterwarnings = ["ignore:The database setting is not configured"]
49
+
50
+ [tool.mypy]
51
+ strict = true
52
+ files = ["src", "tests", "ci"]
53
+ mypy_path = ["src", "tests"]
54
+
55
+ [[tool.mypy.overrides]]
56
+ module = ["public_tree"]
57
+ ignore_missing_imports = true
58
+
59
+ [tool.ruff]
60
+ line-length = 160
61
+ target-version = "py312"
62
+ src = ["src"]
63
+
64
+ [tool.ruff.lint]
65
+ select = ["E", "F", "I", "B", "UP", "S", "RUF"]
66
+ ignore = ["RUF001", "RUF002", "RUF003"] # German text and typography are intended
67
+
68
+ [tool.ruff.lint.isort]
69
+ known-third-party = ["synthetic"]
70
+
71
+ [tool.ruff.lint.per-file-ignores]
72
+ "tests/*" = ["S101", "S106", "S603", "S607"]
73
+ "ci/*" = ["S603", "S607"]
74
+ "src/extf/_writer.py" = ["S101"] # internal invariants, checked by validate first
75
+ "src/extf/_reader.py" = ["S101"]
extf-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+