atrep 0.3.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.
- atrep-0.3.0/.github/workflows/publish-pypi.yml +127 -0
- atrep-0.3.0/.gitignore +6 -0
- atrep-0.3.0/Cargo.lock +319 -0
- atrep-0.3.0/Cargo.toml +26 -0
- atrep-0.3.0/LICENSE-APACHE +202 -0
- atrep-0.3.0/LICENSE-MIT +21 -0
- atrep-0.3.0/PKG-INFO +100 -0
- atrep-0.3.0/README.md +80 -0
- atrep-0.3.0/pyproject.toml +29 -0
- atrep-0.3.0/src/lib.rs +204 -0
- atrep-0.3.0/tests/test_atrep.py +120 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
name: "Publish atrep-py to PyPI (dist: atrep)"
|
|
2
|
+
|
|
3
|
+
# Triggers on `v*` tag pushes to this GitHub mirror. Builds the full
|
|
4
|
+
# wheel matrix (5 platforms + sdist) and publishes atomically to PyPI
|
|
5
|
+
# using OIDC trusted publishing — no API token secret needed on the
|
|
6
|
+
# GitHub side.
|
|
7
|
+
#
|
|
8
|
+
# One-time setup required before the first publish:
|
|
9
|
+
#
|
|
10
|
+
# 1. On PyPI (https://pypi.org/manage/project/atrep/settings/publishing/):
|
|
11
|
+
# Add a Trusted Publisher with:
|
|
12
|
+
# Owner: deyanovich
|
|
13
|
+
# Repository: atrep-py
|
|
14
|
+
# Workflow: publish-pypi.yml
|
|
15
|
+
# Environment: pypi
|
|
16
|
+
#
|
|
17
|
+
# 2. On GitHub (Settings → Environments on this repo):
|
|
18
|
+
# Create an environment named `pypi`. Optional protection rules
|
|
19
|
+
# (e.g. require approval for deployment) can be added there.
|
|
20
|
+
#
|
|
21
|
+
# Adapted from the kaiv-py publish workflow (itself from the
|
|
22
|
+
# production-proven obcrypt-rs line); atrep-py is a root-crate repo,
|
|
23
|
+
# so no --manifest-path, and the trigger is the repo's plain `v*` tag.
|
|
24
|
+
|
|
25
|
+
on:
|
|
26
|
+
push:
|
|
27
|
+
tags:
|
|
28
|
+
- "v*"
|
|
29
|
+
|
|
30
|
+
permissions:
|
|
31
|
+
contents: read
|
|
32
|
+
|
|
33
|
+
jobs:
|
|
34
|
+
build-wheels:
|
|
35
|
+
name: Build wheels (${{ matrix.target }})
|
|
36
|
+
runs-on: ${{ matrix.os }}
|
|
37
|
+
strategy:
|
|
38
|
+
fail-fast: false
|
|
39
|
+
matrix:
|
|
40
|
+
include:
|
|
41
|
+
- os: ubuntu-latest
|
|
42
|
+
target: x86_64-unknown-linux-gnu
|
|
43
|
+
- os: ubuntu-24.04-arm
|
|
44
|
+
target: aarch64-unknown-linux-gnu
|
|
45
|
+
- os: macos-14
|
|
46
|
+
target: aarch64-apple-darwin
|
|
47
|
+
- os: macos-latest
|
|
48
|
+
target: x86_64-apple-darwin
|
|
49
|
+
- os: windows-latest
|
|
50
|
+
target: x86_64-pc-windows-msvc
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@v4
|
|
53
|
+
|
|
54
|
+
- name: Set up Python 3.12
|
|
55
|
+
uses: actions/setup-python@v5
|
|
56
|
+
with:
|
|
57
|
+
python-version: "3.12"
|
|
58
|
+
|
|
59
|
+
- name: Set up Rust
|
|
60
|
+
uses: dtolnay/rust-toolchain@stable
|
|
61
|
+
with:
|
|
62
|
+
targets: ${{ matrix.target }}
|
|
63
|
+
|
|
64
|
+
- name: Build wheel
|
|
65
|
+
uses: PyO3/maturin-action@v1
|
|
66
|
+
with:
|
|
67
|
+
target: ${{ matrix.target }}
|
|
68
|
+
args: >-
|
|
69
|
+
--release
|
|
70
|
+
--strip
|
|
71
|
+
--out dist
|
|
72
|
+
manylinux: auto
|
|
73
|
+
python-version: "3.12"
|
|
74
|
+
|
|
75
|
+
- name: Upload wheel artifact
|
|
76
|
+
uses: actions/upload-artifact@v4
|
|
77
|
+
with:
|
|
78
|
+
name: wheels-${{ matrix.target }}
|
|
79
|
+
path: dist/*.whl
|
|
80
|
+
|
|
81
|
+
build-sdist:
|
|
82
|
+
name: Build sdist
|
|
83
|
+
runs-on: ubuntu-latest
|
|
84
|
+
steps:
|
|
85
|
+
- uses: actions/checkout@v4
|
|
86
|
+
|
|
87
|
+
- name: Set up Python 3.12
|
|
88
|
+
uses: actions/setup-python@v5
|
|
89
|
+
with:
|
|
90
|
+
python-version: "3.12"
|
|
91
|
+
|
|
92
|
+
- name: Build sdist
|
|
93
|
+
uses: PyO3/maturin-action@v1
|
|
94
|
+
with:
|
|
95
|
+
command: sdist
|
|
96
|
+
args: >-
|
|
97
|
+
--out dist
|
|
98
|
+
|
|
99
|
+
- name: Upload sdist artifact
|
|
100
|
+
uses: actions/upload-artifact@v4
|
|
101
|
+
with:
|
|
102
|
+
name: sdist
|
|
103
|
+
path: dist/*.tar.gz
|
|
104
|
+
|
|
105
|
+
publish:
|
|
106
|
+
name: Publish to PyPI
|
|
107
|
+
needs: [build-wheels, build-sdist]
|
|
108
|
+
runs-on: ubuntu-latest
|
|
109
|
+
environment: pypi
|
|
110
|
+
permissions:
|
|
111
|
+
id-token: write
|
|
112
|
+
steps:
|
|
113
|
+
- name: Download all artifacts
|
|
114
|
+
uses: actions/download-artifact@v4
|
|
115
|
+
with:
|
|
116
|
+
path: artifacts
|
|
117
|
+
|
|
118
|
+
- name: Collect dist files
|
|
119
|
+
run: |
|
|
120
|
+
mkdir dist
|
|
121
|
+
find artifacts -type f \( -name "*.whl" -o -name "*.tar.gz" \) -exec cp {} dist/ \;
|
|
122
|
+
ls -la dist/
|
|
123
|
+
|
|
124
|
+
- name: Publish to PyPI
|
|
125
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
126
|
+
with:
|
|
127
|
+
packages-dir: dist
|
atrep-0.3.0/.gitignore
ADDED
atrep-0.3.0/Cargo.lock
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "atrep"
|
|
7
|
+
version = "0.3.0"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "1e42648a90e4d7dbe76ccf0689994b441c829484edf6c0d471b7c608afe33fbf"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"serde",
|
|
12
|
+
"serde_json",
|
|
13
|
+
"sha2",
|
|
14
|
+
"unicode-normalization",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "atrep-py"
|
|
19
|
+
version = "0.3.0"
|
|
20
|
+
dependencies = [
|
|
21
|
+
"atrep",
|
|
22
|
+
"pyo3",
|
|
23
|
+
"unicode-normalization",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[[package]]
|
|
27
|
+
name = "block-buffer"
|
|
28
|
+
version = "0.10.4"
|
|
29
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
30
|
+
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
|
31
|
+
dependencies = [
|
|
32
|
+
"generic-array",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[[package]]
|
|
36
|
+
name = "cfg-if"
|
|
37
|
+
version = "1.0.4"
|
|
38
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
39
|
+
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
|
40
|
+
|
|
41
|
+
[[package]]
|
|
42
|
+
name = "cpufeatures"
|
|
43
|
+
version = "0.2.17"
|
|
44
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
45
|
+
checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
|
|
46
|
+
dependencies = [
|
|
47
|
+
"libc",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[[package]]
|
|
51
|
+
name = "crypto-common"
|
|
52
|
+
version = "0.1.7"
|
|
53
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
54
|
+
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
|
|
55
|
+
dependencies = [
|
|
56
|
+
"generic-array",
|
|
57
|
+
"typenum",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
[[package]]
|
|
61
|
+
name = "digest"
|
|
62
|
+
version = "0.10.7"
|
|
63
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
64
|
+
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
|
65
|
+
dependencies = [
|
|
66
|
+
"block-buffer",
|
|
67
|
+
"crypto-common",
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
[[package]]
|
|
71
|
+
name = "generic-array"
|
|
72
|
+
version = "0.14.7"
|
|
73
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
74
|
+
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
|
75
|
+
dependencies = [
|
|
76
|
+
"typenum",
|
|
77
|
+
"version_check",
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
[[package]]
|
|
81
|
+
name = "heck"
|
|
82
|
+
version = "0.5.0"
|
|
83
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
84
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
85
|
+
|
|
86
|
+
[[package]]
|
|
87
|
+
name = "itoa"
|
|
88
|
+
version = "1.0.18"
|
|
89
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
90
|
+
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
|
91
|
+
|
|
92
|
+
[[package]]
|
|
93
|
+
name = "libc"
|
|
94
|
+
version = "0.2.189"
|
|
95
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
96
|
+
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
|
97
|
+
|
|
98
|
+
[[package]]
|
|
99
|
+
name = "memchr"
|
|
100
|
+
version = "2.8.3"
|
|
101
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
102
|
+
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
103
|
+
|
|
104
|
+
[[package]]
|
|
105
|
+
name = "once_cell"
|
|
106
|
+
version = "1.21.4"
|
|
107
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
108
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
109
|
+
|
|
110
|
+
[[package]]
|
|
111
|
+
name = "portable-atomic"
|
|
112
|
+
version = "1.14.0"
|
|
113
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
114
|
+
checksum = "3d20d5497ef88037a52ff98267d066e7f11fcc5e99bbfbd58a42336193aacec3"
|
|
115
|
+
|
|
116
|
+
[[package]]
|
|
117
|
+
name = "proc-macro2"
|
|
118
|
+
version = "1.0.107"
|
|
119
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
120
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
121
|
+
dependencies = [
|
|
122
|
+
"unicode-ident",
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
[[package]]
|
|
126
|
+
name = "pyo3"
|
|
127
|
+
version = "0.29.1"
|
|
128
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
129
|
+
checksum = "fc153f5fd745cc038b5eed86622125969f8a39834a57bc96beaaf2512b1da729"
|
|
130
|
+
dependencies = [
|
|
131
|
+
"libc",
|
|
132
|
+
"once_cell",
|
|
133
|
+
"portable-atomic",
|
|
134
|
+
"pyo3-build-config",
|
|
135
|
+
"pyo3-ffi",
|
|
136
|
+
"pyo3-macros",
|
|
137
|
+
]
|
|
138
|
+
|
|
139
|
+
[[package]]
|
|
140
|
+
name = "pyo3-build-config"
|
|
141
|
+
version = "0.29.1"
|
|
142
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
143
|
+
checksum = "bb77d9aa6d647507b55c69ee714d266d84c526c78ff0bc6dd8757f58591e64d1"
|
|
144
|
+
dependencies = [
|
|
145
|
+
"target-lexicon",
|
|
146
|
+
]
|
|
147
|
+
|
|
148
|
+
[[package]]
|
|
149
|
+
name = "pyo3-ffi"
|
|
150
|
+
version = "0.29.1"
|
|
151
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
152
|
+
checksum = "3160087aa5733bce7d9a729f8c55f85a2a53b74742a09613178eeebff0722253"
|
|
153
|
+
dependencies = [
|
|
154
|
+
"libc",
|
|
155
|
+
"pyo3-build-config",
|
|
156
|
+
]
|
|
157
|
+
|
|
158
|
+
[[package]]
|
|
159
|
+
name = "pyo3-macros"
|
|
160
|
+
version = "0.29.1"
|
|
161
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
162
|
+
checksum = "91f9d455db760a9a0b0ddeaac25f1390b8a36ba73dfbda9f127cac6fc340d4d5"
|
|
163
|
+
dependencies = [
|
|
164
|
+
"proc-macro2",
|
|
165
|
+
"pyo3-macros-backend",
|
|
166
|
+
"quote",
|
|
167
|
+
"syn 2.0.119",
|
|
168
|
+
]
|
|
169
|
+
|
|
170
|
+
[[package]]
|
|
171
|
+
name = "pyo3-macros-backend"
|
|
172
|
+
version = "0.29.1"
|
|
173
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
174
|
+
checksum = "e343bcec300ff262f5806a33a4e51b6d097a8a46435f512fcb83e95592581625"
|
|
175
|
+
dependencies = [
|
|
176
|
+
"heck",
|
|
177
|
+
"proc-macro2",
|
|
178
|
+
"quote",
|
|
179
|
+
"syn 2.0.119",
|
|
180
|
+
]
|
|
181
|
+
|
|
182
|
+
[[package]]
|
|
183
|
+
name = "quote"
|
|
184
|
+
version = "1.0.47"
|
|
185
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
186
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
187
|
+
dependencies = [
|
|
188
|
+
"proc-macro2",
|
|
189
|
+
]
|
|
190
|
+
|
|
191
|
+
[[package]]
|
|
192
|
+
name = "serde"
|
|
193
|
+
version = "1.0.229"
|
|
194
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
195
|
+
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
|
|
196
|
+
dependencies = [
|
|
197
|
+
"serde_core",
|
|
198
|
+
"serde_derive",
|
|
199
|
+
]
|
|
200
|
+
|
|
201
|
+
[[package]]
|
|
202
|
+
name = "serde_core"
|
|
203
|
+
version = "1.0.229"
|
|
204
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
205
|
+
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
|
206
|
+
dependencies = [
|
|
207
|
+
"serde_derive",
|
|
208
|
+
]
|
|
209
|
+
|
|
210
|
+
[[package]]
|
|
211
|
+
name = "serde_derive"
|
|
212
|
+
version = "1.0.229"
|
|
213
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
214
|
+
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
|
215
|
+
dependencies = [
|
|
216
|
+
"proc-macro2",
|
|
217
|
+
"quote",
|
|
218
|
+
"syn 3.0.3",
|
|
219
|
+
]
|
|
220
|
+
|
|
221
|
+
[[package]]
|
|
222
|
+
name = "serde_json"
|
|
223
|
+
version = "1.0.151"
|
|
224
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
225
|
+
checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
|
|
226
|
+
dependencies = [
|
|
227
|
+
"itoa",
|
|
228
|
+
"memchr",
|
|
229
|
+
"serde",
|
|
230
|
+
"serde_core",
|
|
231
|
+
"zmij",
|
|
232
|
+
]
|
|
233
|
+
|
|
234
|
+
[[package]]
|
|
235
|
+
name = "sha2"
|
|
236
|
+
version = "0.10.9"
|
|
237
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
238
|
+
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
|
|
239
|
+
dependencies = [
|
|
240
|
+
"cfg-if",
|
|
241
|
+
"cpufeatures",
|
|
242
|
+
"digest",
|
|
243
|
+
]
|
|
244
|
+
|
|
245
|
+
[[package]]
|
|
246
|
+
name = "syn"
|
|
247
|
+
version = "2.0.119"
|
|
248
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
249
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
250
|
+
dependencies = [
|
|
251
|
+
"proc-macro2",
|
|
252
|
+
"quote",
|
|
253
|
+
"unicode-ident",
|
|
254
|
+
]
|
|
255
|
+
|
|
256
|
+
[[package]]
|
|
257
|
+
name = "syn"
|
|
258
|
+
version = "3.0.3"
|
|
259
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
260
|
+
checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3"
|
|
261
|
+
dependencies = [
|
|
262
|
+
"proc-macro2",
|
|
263
|
+
"quote",
|
|
264
|
+
"unicode-ident",
|
|
265
|
+
]
|
|
266
|
+
|
|
267
|
+
[[package]]
|
|
268
|
+
name = "target-lexicon"
|
|
269
|
+
version = "0.13.5"
|
|
270
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
271
|
+
checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
|
272
|
+
|
|
273
|
+
[[package]]
|
|
274
|
+
name = "tinyvec"
|
|
275
|
+
version = "1.12.0"
|
|
276
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
277
|
+
checksum = "bb4ebadaa0af04fab11ae01eb5f9fdb5f9c5b875506e210e71c07873528baa7f"
|
|
278
|
+
dependencies = [
|
|
279
|
+
"tinyvec_macros",
|
|
280
|
+
]
|
|
281
|
+
|
|
282
|
+
[[package]]
|
|
283
|
+
name = "tinyvec_macros"
|
|
284
|
+
version = "0.1.1"
|
|
285
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
286
|
+
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
|
287
|
+
|
|
288
|
+
[[package]]
|
|
289
|
+
name = "typenum"
|
|
290
|
+
version = "1.20.1"
|
|
291
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
292
|
+
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
|
|
293
|
+
|
|
294
|
+
[[package]]
|
|
295
|
+
name = "unicode-ident"
|
|
296
|
+
version = "1.0.24"
|
|
297
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
298
|
+
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
|
299
|
+
|
|
300
|
+
[[package]]
|
|
301
|
+
name = "unicode-normalization"
|
|
302
|
+
version = "0.1.25"
|
|
303
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
304
|
+
checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8"
|
|
305
|
+
dependencies = [
|
|
306
|
+
"tinyvec",
|
|
307
|
+
]
|
|
308
|
+
|
|
309
|
+
[[package]]
|
|
310
|
+
name = "version_check"
|
|
311
|
+
version = "0.9.5"
|
|
312
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
313
|
+
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
|
314
|
+
|
|
315
|
+
[[package]]
|
|
316
|
+
name = "zmij"
|
|
317
|
+
version = "1.0.23"
|
|
318
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
319
|
+
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
atrep-0.3.0/Cargo.toml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "atrep-py"
|
|
3
|
+
# The bindings version IS the PyPI version (maturin reads it);
|
|
4
|
+
# aligned with the atrep core it wraps, starting at 0.3.0.
|
|
5
|
+
version = "0.3.0"
|
|
6
|
+
edition = "2021"
|
|
7
|
+
# This crate ships to PyPI as wheels (maturin), never to
|
|
8
|
+
# crates.io — the registry surface for the library is the core
|
|
9
|
+
# `atrep` crate itself.
|
|
10
|
+
publish = false
|
|
11
|
+
license = "MIT OR Apache-2.0"
|
|
12
|
+
repository = "https://gitlab.com/atrep/atrep-py"
|
|
13
|
+
description = "Python bindings for Atrep semantic markup: check, respellings, outline, endo importers, dialektoi"
|
|
14
|
+
readme = "README.md"
|
|
15
|
+
|
|
16
|
+
[lib]
|
|
17
|
+
name = "atrep"
|
|
18
|
+
crate-type = ["cdylib"]
|
|
19
|
+
|
|
20
|
+
[dependencies]
|
|
21
|
+
# The published core, offline: default features (net, bundle) off
|
|
22
|
+
# keeps the dependency closure pure Rust. The std dialektoi are
|
|
23
|
+
# embedded; non-std ones resolve from the path's directory.
|
|
24
|
+
atrep = { version = "0.3.0", default-features = false }
|
|
25
|
+
unicode-normalization = "0.1"
|
|
26
|
+
pyo3 = { version = "0.29.0", features = ["extension-module", "abi3-py39"] }
|
|
@@ -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 2026 Bojan Đuričković
|
|
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.
|
atrep-0.3.0/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bojan Đuričković
|
|
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.
|
atrep-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: atrep
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Classifier: Development Status :: 4 - Beta
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Programming Language :: Rust
|
|
8
|
+
Classifier: Topic :: Text Processing :: Markup
|
|
9
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
10
|
+
License-File: LICENSE-MIT
|
|
11
|
+
License-File: LICENSE-APACHE
|
|
12
|
+
Summary: Python bindings for Atrep semantic markup: check, respellings, outline, endo importers, dialektoi
|
|
13
|
+
Keywords: atrep,markup,semantic,document,dialect
|
|
14
|
+
Author: Bojan Đuričković
|
|
15
|
+
License-Expression: MIT OR Apache-2.0
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
18
|
+
Project-URL: Repository, https://gitlab.com/atrep/atrep-py
|
|
19
|
+
|
|
20
|
+
# atrep — Python bindings
|
|
21
|
+
|
|
22
|
+
Python bindings for [atrep](https://gitlab.com/atrep), an
|
|
23
|
+
extensible semantic markup language designed with literary
|
|
24
|
+
applications in mind. The same Rust core the
|
|
25
|
+
[CLI](https://pypi.org/project/atrep-cli/) wraps
|
|
26
|
+
([`atrep` on crates.io](https://crates.io/crates/atrep)),
|
|
27
|
+
surfaced pythonically: strings in, strings out, exceptions
|
|
28
|
+
instead of exit codes.
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
pip install atrep
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Checking and the two spellings
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import atrep
|
|
38
|
+
|
|
39
|
+
doc = open("apology.atd").read()
|
|
40
|
+
|
|
41
|
+
# Parse and validate; routes on the declaration.
|
|
42
|
+
atrep.check(doc) # -> "document" | "dialektos"
|
|
43
|
+
|
|
44
|
+
# The two spellings: brachygraphic (sim symbols; canonical)
|
|
45
|
+
# and plerographic (sim names in braces). Both parse to the
|
|
46
|
+
# identical structure.
|
|
47
|
+
names = atrep.plero(doc) # @# ... -> @{section} ...
|
|
48
|
+
symbols = atrep.brachy(names) # ... and back
|
|
49
|
+
localized = atrep.plero(doc, lang="el") # glossa sim names
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## The structural outline
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
o = atrep.outline(doc)
|
|
56
|
+
o["dialektos"] # "litogramma"
|
|
57
|
+
o["blocks"] # [{"kind", "symbol", "name", "depth",
|
|
58
|
+
# "start", "end", "lemma", "onym",
|
|
59
|
+
# "genoses"}, ...]
|
|
60
|
+
o["milestones"] # [{"key": "steph:17a", "line": 4}, ...]
|
|
61
|
+
o["onyms"] # located onym anchors
|
|
62
|
+
o["deixes"] # located deixis references
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Endo importers
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
# Foreign formats -> canonical atrep: markdown | html | rst |
|
|
69
|
+
# org | djot | docbook | bibtex | jats | tei | usfm | usx | osis.
|
|
70
|
+
a = atrep.endo("markdown", open("notes.md").read())
|
|
71
|
+
|
|
72
|
+
# Versification milestone scheme (usfm/usx/osis only).
|
|
73
|
+
a = atrep.endo("usfm", open("john.usfm").read(), scheme="std")
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Dialektoi
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
# Resolve a dialektos and get its canonical serialization.
|
|
80
|
+
# The std dialektoi are embedded; `dir` resolves from disk,
|
|
81
|
+
# `sources` from in-memory artifacts.
|
|
82
|
+
lekt = atrep.dialektos("koine")
|
|
83
|
+
lekt = atrep.dialektos("demo", sources={"demo.lektos": dia})
|
|
84
|
+
atrep.std_dialektoi() # ["at-djot", "koine", ..., "litogramma"]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Errors raise `atrep.AtrepError`, with `file:line:col` locations
|
|
88
|
+
in the message where the source provides them. `atrep.version()`
|
|
89
|
+
reports the bindings/core version.
|
|
90
|
+
|
|
91
|
+
Resolution is offline: non-std dialektoi resolve from the
|
|
92
|
+
directory of the `path` argument (default `doc.atd`, i.e. the
|
|
93
|
+
process working directory). Remote fetching (kanonizo) and the
|
|
94
|
+
multi-document operations (morphisms, exo rendering, collation)
|
|
95
|
+
belong to the [CLI](https://pypi.org/project/atrep-cli/).
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
MIT or Apache-2.0, at your option.
|
|
100
|
+
|
atrep-0.3.0/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# atrep — Python bindings
|
|
2
|
+
|
|
3
|
+
Python bindings for [atrep](https://gitlab.com/atrep), an
|
|
4
|
+
extensible semantic markup language designed with literary
|
|
5
|
+
applications in mind. The same Rust core the
|
|
6
|
+
[CLI](https://pypi.org/project/atrep-cli/) wraps
|
|
7
|
+
([`atrep` on crates.io](https://crates.io/crates/atrep)),
|
|
8
|
+
surfaced pythonically: strings in, strings out, exceptions
|
|
9
|
+
instead of exit codes.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pip install atrep
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Checking and the two spellings
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
import atrep
|
|
19
|
+
|
|
20
|
+
doc = open("apology.atd").read()
|
|
21
|
+
|
|
22
|
+
# Parse and validate; routes on the declaration.
|
|
23
|
+
atrep.check(doc) # -> "document" | "dialektos"
|
|
24
|
+
|
|
25
|
+
# The two spellings: brachygraphic (sim symbols; canonical)
|
|
26
|
+
# and plerographic (sim names in braces). Both parse to the
|
|
27
|
+
# identical structure.
|
|
28
|
+
names = atrep.plero(doc) # @# ... -> @{section} ...
|
|
29
|
+
symbols = atrep.brachy(names) # ... and back
|
|
30
|
+
localized = atrep.plero(doc, lang="el") # glossa sim names
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## The structural outline
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
o = atrep.outline(doc)
|
|
37
|
+
o["dialektos"] # "litogramma"
|
|
38
|
+
o["blocks"] # [{"kind", "symbol", "name", "depth",
|
|
39
|
+
# "start", "end", "lemma", "onym",
|
|
40
|
+
# "genoses"}, ...]
|
|
41
|
+
o["milestones"] # [{"key": "steph:17a", "line": 4}, ...]
|
|
42
|
+
o["onyms"] # located onym anchors
|
|
43
|
+
o["deixes"] # located deixis references
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Endo importers
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
# Foreign formats -> canonical atrep: markdown | html | rst |
|
|
50
|
+
# org | djot | docbook | bibtex | jats | tei | usfm | usx | osis.
|
|
51
|
+
a = atrep.endo("markdown", open("notes.md").read())
|
|
52
|
+
|
|
53
|
+
# Versification milestone scheme (usfm/usx/osis only).
|
|
54
|
+
a = atrep.endo("usfm", open("john.usfm").read(), scheme="std")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Dialektoi
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
# Resolve a dialektos and get its canonical serialization.
|
|
61
|
+
# The std dialektoi are embedded; `dir` resolves from disk,
|
|
62
|
+
# `sources` from in-memory artifacts.
|
|
63
|
+
lekt = atrep.dialektos("koine")
|
|
64
|
+
lekt = atrep.dialektos("demo", sources={"demo.lektos": dia})
|
|
65
|
+
atrep.std_dialektoi() # ["at-djot", "koine", ..., "litogramma"]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Errors raise `atrep.AtrepError`, with `file:line:col` locations
|
|
69
|
+
in the message where the source provides them. `atrep.version()`
|
|
70
|
+
reports the bindings/core version.
|
|
71
|
+
|
|
72
|
+
Resolution is offline: non-std dialektoi resolve from the
|
|
73
|
+
directory of the `path` argument (default `doc.atd`, i.e. the
|
|
74
|
+
process working directory). Remote fetching (kanonizo) and the
|
|
75
|
+
multi-document operations (morphisms, exo rendering, collation)
|
|
76
|
+
belong to the [CLI](https://pypi.org/project/atrep-cli/).
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
MIT or Apache-2.0, at your option.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["maturin>=1.7,<2.0"]
|
|
3
|
+
build-backend = "maturin"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "atrep"
|
|
7
|
+
description = "Python bindings for Atrep semantic markup: check, respellings, outline, endo importers, dialektoi"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
license = "MIT OR Apache-2.0"
|
|
10
|
+
license-files = ["LICENSE-MIT", "LICENSE-APACHE"]
|
|
11
|
+
authors = [{ name = "Bojan Đuričković" }]
|
|
12
|
+
requires-python = ">=3.9"
|
|
13
|
+
keywords = ["atrep", "markup", "semantic", "document", "dialect"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Rust",
|
|
19
|
+
"Topic :: Text Processing :: Markup",
|
|
20
|
+
"Topic :: Software Development :: Libraries",
|
|
21
|
+
]
|
|
22
|
+
dynamic = ["version"]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Repository = "https://gitlab.com/atrep/atrep-py"
|
|
26
|
+
|
|
27
|
+
[tool.maturin]
|
|
28
|
+
module-name = "atrep"
|
|
29
|
+
features = ["pyo3/extension-module"]
|
atrep-0.3.0/src/lib.rs
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
//! Python bindings for Atrep — the same core crate the CLI wraps,
|
|
2
|
+
//! surfaced pythonically: strings in, strings out, exceptions
|
|
3
|
+
//! instead of exit codes. Resolution is offline: the std dialektoi
|
|
4
|
+
//! are embedded, non-std ones resolve from the path's directory
|
|
5
|
+
//! (no `net`, no `bundle`).
|
|
6
|
+
|
|
7
|
+
use std::collections::HashMap;
|
|
8
|
+
use std::path::Path;
|
|
9
|
+
|
|
10
|
+
use pyo3::create_exception;
|
|
11
|
+
use pyo3::exceptions::PyException;
|
|
12
|
+
use pyo3::prelude::*;
|
|
13
|
+
use pyo3::types::{PyDict, PyList};
|
|
14
|
+
use unicode_normalization::UnicodeNormalization;
|
|
15
|
+
|
|
16
|
+
create_exception!(atrep, AtrepError, PyException, "An atrep error.");
|
|
17
|
+
|
|
18
|
+
fn aerr(e: impl std::fmt::Display) -> PyErr {
|
|
19
|
+
AtrepError::new_err(e.to_string())
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/// The parsed document behind `text`, or an error for definition
|
|
23
|
+
/// sources — the document operations (brachy, plero, outline) do
|
|
24
|
+
/// not apply to dialektos definitions.
|
|
25
|
+
fn parse_doc(text: &str, path: &str) -> PyResult<::atrep::Document> {
|
|
26
|
+
match ::atrep::check_source(text, Path::new(path)).map_err(aerr)? {
|
|
27
|
+
::atrep::Checked::Document(doc) => Ok(doc),
|
|
28
|
+
::atrep::Checked::Dialektos(_) => Err(aerr(
|
|
29
|
+
"definition source: this operation applies to documents",
|
|
30
|
+
)),
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/// The dialektos a document declares, resolved from the path's
|
|
35
|
+
/// directory with the embedded std dialektoi as fallback.
|
|
36
|
+
fn resolve_dial(doc: &::atrep::Document, path: &str) -> PyResult<::atrep::dialektos::Dialektos> {
|
|
37
|
+
let dir = Path::new(path).parent().unwrap_or(Path::new("."));
|
|
38
|
+
::atrep::dialektos::resolve(dir, &doc.dialect_id).map_err(aerr)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// The bindings (and wrapped core) version.
|
|
42
|
+
#[pyfunction]
|
|
43
|
+
fn version() -> &'static str {
|
|
44
|
+
env!("CARGO_PKG_VERSION")
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/// Parse and validate a document or dialektos definition, routed
|
|
48
|
+
/// on the declaration; returns "document" or "dialektos". `path`
|
|
49
|
+
/// is where the source nominally lives: non-std dialektoi and
|
|
50
|
+
/// imports resolve from its directory and errors locate there.
|
|
51
|
+
#[pyfunction]
|
|
52
|
+
#[pyo3(signature = (text, path="doc.atd"))]
|
|
53
|
+
fn check(text: &str, path: &str) -> PyResult<&'static str> {
|
|
54
|
+
match ::atrep::check_source(text, Path::new(path)).map_err(aerr)? {
|
|
55
|
+
::atrep::Checked::Document(_) => Ok("document"),
|
|
56
|
+
::atrep::Checked::Dialektos(_) => Ok("dialektos"),
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/// Rewrite a document in the brachygraphic spelling (sim symbols;
|
|
61
|
+
/// the canonical spelling).
|
|
62
|
+
#[pyfunction]
|
|
63
|
+
#[pyo3(signature = (text, path="doc.atd"))]
|
|
64
|
+
fn brachy(text: &str, path: &str) -> PyResult<String> {
|
|
65
|
+
let doc = parse_doc(text, path)?;
|
|
66
|
+
Ok(::atrep::dendron::serialize(&doc))
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/// Rewrite a document in the plerographic spelling (sim names in
|
|
70
|
+
/// braces). `lang` spells sim names from that language's glossa
|
|
71
|
+
/// (`<dialektos>.<lang>.glossa`), falling back to primary names
|
|
72
|
+
/// where the glossa is silent.
|
|
73
|
+
#[pyfunction]
|
|
74
|
+
#[pyo3(signature = (text, lang=None, path="doc.atd"))]
|
|
75
|
+
fn plero(text: &str, lang: Option<&str>, path: &str) -> PyResult<String> {
|
|
76
|
+
let doc = parse_doc(text, path)?;
|
|
77
|
+
let dial = resolve_dial(&doc, path)?;
|
|
78
|
+
::atrep::dendron::serialize_plerographic_in(&doc, &dial, lang).map_err(aerr)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/// The document's structural outline as plain dicts and lists:
|
|
82
|
+
/// blocks with line spans, and located milestones, onyms, and
|
|
83
|
+
/// deixes (`{"key": ..., "line": ...}` each).
|
|
84
|
+
#[pyfunction]
|
|
85
|
+
#[pyo3(signature = (text, path="doc.atd"))]
|
|
86
|
+
fn outline(py: Python<'_>, text: &str, path: &str) -> PyResult<Py<PyDict>> {
|
|
87
|
+
let normalized: String = text.nfc().collect();
|
|
88
|
+
let (doc, blocks, dial) =
|
|
89
|
+
::atrep::parser::parse_document_outline(&normalized, Path::new(path)).map_err(aerr)?;
|
|
90
|
+
let o = ::atrep::outline::assemble(&doc, blocks, &normalized, &dial);
|
|
91
|
+
|
|
92
|
+
let points = |pts: &[::atrep::outline::OutlinePoint]| -> PyResult<Py<PyList>> {
|
|
93
|
+
let list = PyList::empty(py);
|
|
94
|
+
for p in pts {
|
|
95
|
+
let d = PyDict::new(py);
|
|
96
|
+
d.set_item("key", &p.key)?;
|
|
97
|
+
d.set_item("line", p.line)?;
|
|
98
|
+
list.append(d)?;
|
|
99
|
+
}
|
|
100
|
+
Ok(list.unbind())
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
let blocks_list = PyList::empty(py);
|
|
104
|
+
for b in &o.blocks {
|
|
105
|
+
let d = PyDict::new(py);
|
|
106
|
+
d.set_item("kind", b.kind)?;
|
|
107
|
+
d.set_item("symbol", b.symbol.as_deref())?;
|
|
108
|
+
d.set_item("name", b.name.as_deref())?;
|
|
109
|
+
d.set_item("depth", b.depth)?;
|
|
110
|
+
d.set_item("start", b.start)?;
|
|
111
|
+
d.set_item("end", b.end)?;
|
|
112
|
+
d.set_item("lemma", &b.lemma)?;
|
|
113
|
+
d.set_item("onym", b.onym.as_deref())?;
|
|
114
|
+
d.set_item("genoses", &b.genoses)?;
|
|
115
|
+
blocks_list.append(d)?;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
let out = PyDict::new(py);
|
|
119
|
+
out.set_item("dialektos", &o.dialektos)?;
|
|
120
|
+
out.set_item("blocks", blocks_list)?;
|
|
121
|
+
out.set_item("milestones", points(&o.milestones)?)?;
|
|
122
|
+
out.set_item("onyms", points(&o.onyms)?)?;
|
|
123
|
+
out.set_item("deixes", points(&o.deixes)?)?;
|
|
124
|
+
Ok(out.unbind())
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/// Foreign format -> canonical atrep (brachygraphic spelling).
|
|
128
|
+
/// Formats: markdown | html | rst | org | djot | docbook | bibtex
|
|
129
|
+
/// | jats | tei | usfm | usx | osis. `scheme` applies a
|
|
130
|
+
/// versification milestone scheme (usfm/usx/osis only).
|
|
131
|
+
#[pyfunction]
|
|
132
|
+
#[pyo3(signature = (format, text, scheme=None))]
|
|
133
|
+
fn endo(format: &str, text: &str, scheme: Option<&str>) -> PyResult<String> {
|
|
134
|
+
use ::atrep::endo as e;
|
|
135
|
+
let mut doc = match format {
|
|
136
|
+
"markdown" => e::markdown_to_document(text),
|
|
137
|
+
"html" => e::html_to_document(text),
|
|
138
|
+
"rst" => e::rst_to_document(text),
|
|
139
|
+
"org" => e::org_to_document(text),
|
|
140
|
+
"djot" => e::djot_to_document(text),
|
|
141
|
+
"docbook" => e::docbook_to_document(text),
|
|
142
|
+
"bibtex" => e::bibtex_to_document(text),
|
|
143
|
+
"jats" => e::jats_to_document(text),
|
|
144
|
+
"tei" => e::tei_to_document(text),
|
|
145
|
+
"usfm" => e::usfm_to_document(text),
|
|
146
|
+
"usx" => e::usx_to_document(text),
|
|
147
|
+
"osis" => e::osis_to_document(text),
|
|
148
|
+
other => return Err(aerr(format!("unsupported endo format: {other}"))),
|
|
149
|
+
}
|
|
150
|
+
.map_err(aerr)?;
|
|
151
|
+
if let Some(s) = scheme {
|
|
152
|
+
match format {
|
|
153
|
+
"usfm" | "usx" | "osis" => e::usfm_apply_scheme(&mut doc, s),
|
|
154
|
+
_ => return Err(aerr("scheme applies to usfm/usx/osis only")),
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
Ok(::atrep::dendron::serialize(&doc))
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/// Resolve a dialektos by id and return its canonical
|
|
161
|
+
/// serialization. `dir` resolves from a directory on disk;
|
|
162
|
+
/// `sources` resolves from a dict of in-memory artifacts keyed by
|
|
163
|
+
/// file name (e.g. `{"demo.lektos": "..."}`). The two are
|
|
164
|
+
/// mutually exclusive; with neither, only the embedded std
|
|
165
|
+
/// dialektoi resolve.
|
|
166
|
+
#[pyfunction]
|
|
167
|
+
#[pyo3(signature = (id, dir=None, sources=None))]
|
|
168
|
+
fn dialektos(id: &str, dir: Option<&str>, sources: Option<HashMap<String, String>>) -> PyResult<String> {
|
|
169
|
+
let d = match (dir, sources) {
|
|
170
|
+
(Some(_), Some(_)) => {
|
|
171
|
+
return Err(aerr("dir and sources are mutually exclusive"));
|
|
172
|
+
}
|
|
173
|
+
(Some(dir), None) => ::atrep::dialektos::resolve(Path::new(dir), id),
|
|
174
|
+
(None, sources) => {
|
|
175
|
+
let mut ms = ::atrep::source::MemorySource::new();
|
|
176
|
+
for (name, text) in sources.unwrap_or_default() {
|
|
177
|
+
ms.insert(name, text);
|
|
178
|
+
}
|
|
179
|
+
::atrep::dialektos::resolve_from(&ms, id)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
.map_err(aerr)?;
|
|
183
|
+
Ok(::atrep::dialektos::serialize(&d))
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/// The ids of the embedded std dialektoi.
|
|
187
|
+
#[pyfunction]
|
|
188
|
+
fn std_dialektoi() -> Vec<&'static str> {
|
|
189
|
+
::atrep::dialektos::std_ids()
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
#[pymodule]
|
|
193
|
+
fn atrep(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
194
|
+
m.add_function(wrap_pyfunction!(version, m)?)?;
|
|
195
|
+
m.add_function(wrap_pyfunction!(check, m)?)?;
|
|
196
|
+
m.add_function(wrap_pyfunction!(brachy, m)?)?;
|
|
197
|
+
m.add_function(wrap_pyfunction!(plero, m)?)?;
|
|
198
|
+
m.add_function(wrap_pyfunction!(outline, m)?)?;
|
|
199
|
+
m.add_function(wrap_pyfunction!(endo, m)?)?;
|
|
200
|
+
m.add_function(wrap_pyfunction!(dialektos, m)?)?;
|
|
201
|
+
m.add_function(wrap_pyfunction!(std_dialektoi, m)?)?;
|
|
202
|
+
m.add("AtrepError", py.get_type::<AtrepError>())?;
|
|
203
|
+
Ok(())
|
|
204
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""Binding-surface tests: signatures, return types, exception
|
|
2
|
+
mapping. Format semantics live in the spec repo's conformance
|
|
3
|
+
tree, run by atrep-rs — not here.
|
|
4
|
+
|
|
5
|
+
The samples are lifted from atrep-rs's own test suite
|
|
6
|
+
(tests/outline.rs, tests/metagraphe.rs), not invented."""
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
|
|
10
|
+
import atrep
|
|
11
|
+
|
|
12
|
+
DOC = (
|
|
13
|
+
'@@@!litogramma\n\n'
|
|
14
|
+
'@# The Charges\n'
|
|
15
|
+
'@("steph:17a")How you have been affected@^!(n1).\n\n'
|
|
16
|
+
'@^!\nThe famous opening.\n!^@(n1)\n\n'
|
|
17
|
+
'@## First Accusers\nMore prose here.\n##@\n'
|
|
18
|
+
'#@\n\n'
|
|
19
|
+
'@# The Defence\n'
|
|
20
|
+
'@("steph:18a")From the beginning.\n#@\n'
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
DIA = (
|
|
24
|
+
'@@@!atrep\n\n'
|
|
25
|
+
'@=== section\n@= [lemma]\ngrammata\n=@\n===@\n\n'
|
|
26
|
+
'@=== emphasis\n@/ grammata /@\n===@\n\n'
|
|
27
|
+
'@=== verse\n@|(n)\n===@\n'
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_version():
|
|
32
|
+
assert atrep.version() == "0.3.0"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_check_document():
|
|
36
|
+
assert atrep.check(DOC) == "document"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_check_definition():
|
|
40
|
+
assert atrep.check(DIA) == "dialektos"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_check_error_locates():
|
|
44
|
+
with pytest.raises(atrep.AtrepError) as e:
|
|
45
|
+
atrep.check("@@@!litogramma\n\n@# Unclosed\nProse.\n")
|
|
46
|
+
assert "doc.atd" in str(e.value)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_brachy_is_idempotent():
|
|
50
|
+
b = atrep.brachy(DOC)
|
|
51
|
+
assert atrep.brachy(b) == b
|
|
52
|
+
assert "@#" in b
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def test_plero_round_trips():
|
|
56
|
+
p = atrep.plero(DOC)
|
|
57
|
+
assert "@{" in p
|
|
58
|
+
assert atrep.brachy(p) == atrep.brachy(DOC)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def test_plero_rejects_definition():
|
|
62
|
+
with pytest.raises(atrep.AtrepError):
|
|
63
|
+
atrep.plero(DIA)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_outline_shape():
|
|
67
|
+
o = atrep.outline(DOC)
|
|
68
|
+
assert o["dialektos"] == "litogramma"
|
|
69
|
+
assert set(o) == {"dialektos", "blocks", "milestones", "onyms", "deixes"}
|
|
70
|
+
first = o["blocks"][0]
|
|
71
|
+
assert first["name"] == "section"
|
|
72
|
+
assert first["depth"] == 0
|
|
73
|
+
assert first["start"] == 3
|
|
74
|
+
keys = {m["key"] for m in o["milestones"]}
|
|
75
|
+
assert "steph:17a" in keys and "steph:18a" in keys
|
|
76
|
+
assert any(p["key"] == "n1" for p in o["onyms"])
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def test_endo_markdown():
|
|
80
|
+
a = atrep.endo("markdown", "# Title\n\nSome prose.\n")
|
|
81
|
+
assert atrep.check(a) == "document"
|
|
82
|
+
assert "Title" in a
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_endo_unknown_format():
|
|
86
|
+
with pytest.raises(atrep.AtrepError):
|
|
87
|
+
atrep.endo("latex", "\\section{x}")
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def test_endo_scheme_misuse():
|
|
91
|
+
with pytest.raises(atrep.AtrepError):
|
|
92
|
+
atrep.endo("markdown", "# Title\n", scheme="steph")
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def test_dialektos_std():
|
|
96
|
+
lekt = atrep.dialektos("koine")
|
|
97
|
+
assert atrep.check(lekt) == "dialektos"
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def test_dialektos_sources():
|
|
101
|
+
lekt = atrep.dialektos("demo", sources={"demo.lektos": DIA})
|
|
102
|
+
assert "section" in lekt
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def test_dialektos_params_exclusive():
|
|
106
|
+
with pytest.raises(atrep.AtrepError):
|
|
107
|
+
atrep.dialektos("demo", dir=".", sources={"demo.lektos": DIA})
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def test_std_dialektoi():
|
|
111
|
+
ids = atrep.std_dialektoi()
|
|
112
|
+
assert "litogramma" in ids
|
|
113
|
+
assert "koine" in ids
|
|
114
|
+
assert len(ids) >= 14
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def test_errors_are_atrep_error():
|
|
118
|
+
assert issubclass(atrep.AtrepError, Exception)
|
|
119
|
+
with pytest.raises(atrep.AtrepError):
|
|
120
|
+
atrep.check("@@@!no-such-dialektos\n\ntext\n")
|