prelude-parser 0.3.2__tar.gz → 0.4.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.
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/.github/workflows/pypi_publish.yml +21 -22
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/.github/workflows/release-drafter.yml +1 -1
- prelude_parser-0.4.0/.github/workflows/testing.yml +63 -0
- prelude_parser-0.4.0/.pre-commit-config.yaml +20 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/Cargo.lock +172 -52
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/Cargo.toml +8 -4
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/PKG-INFO +2 -2
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/prelude_parser/_prelude_parser.pyi +4 -3
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/prelude_parser/parser.py +3 -4
- prelude_parser-0.4.0/prelude_parser/types.py +5 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/pyproject.toml +19 -23
- prelude_parser-0.4.0/requirements-dev.txt +8 -0
- prelude_parser-0.4.0/src/errors.rs +18 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/src/lib.rs +28 -39
- prelude_parser-0.4.0/src/utils.rs +31 -0
- prelude_parser-0.3.2/.github/workflows/testing.yml +0 -63
- prelude_parser-0.3.2/.pre-commit-config.yaml +0 -25
- prelude_parser-0.3.2/requirements-dev.txt +0 -8
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/.github/dependabot.yml +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/.github/release-draft-template.yml +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/.gitignore +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/CONTRIBUTING.md +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/LICENSE +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/README.md +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/justfile +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/prelude_parser/__init__.py +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/prelude_parser/pandas.py +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/prelude_parser/polars.py +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/prelude_parser/py.typed +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/tests/__init__.py +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/tests/assets/test1.xml +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/tests/assets/test2.xml +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/tests/assets/test3.xml +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/tests/assets/test4.xml +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/tests/conftest.py +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/tests/test_pandas.py +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/tests/test_parser.py +0 -0
- {prelude_parser-0.3.2 → prelude_parser-0.4.0}/tests/test_polars.py +0 -0
|
@@ -3,7 +3,7 @@ name: PyPi Publish
|
|
|
3
3
|
on:
|
|
4
4
|
release:
|
|
5
5
|
types:
|
|
6
|
-
|
|
6
|
+
- published
|
|
7
7
|
|
|
8
8
|
permissions:
|
|
9
9
|
contents: read
|
|
@@ -16,20 +16,20 @@ jobs:
|
|
|
16
16
|
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
|
|
17
17
|
steps:
|
|
18
18
|
- uses: actions/checkout@v4
|
|
19
|
-
- uses: actions/setup-python@
|
|
19
|
+
- uses: actions/setup-python@v5
|
|
20
20
|
with:
|
|
21
|
-
python-version:
|
|
21
|
+
python-version: "3.11"
|
|
22
22
|
- name: Build wheels
|
|
23
23
|
uses: PyO3/maturin-action@v1
|
|
24
24
|
with:
|
|
25
25
|
target: ${{ matrix.target }}
|
|
26
26
|
args: --release --out dist --find-interpreter
|
|
27
|
-
sccache:
|
|
27
|
+
sccache: "true"
|
|
28
28
|
manylinux: auto
|
|
29
29
|
- name: Upload wheels
|
|
30
|
-
uses: actions/upload-artifact@
|
|
30
|
+
uses: actions/upload-artifact@v4
|
|
31
31
|
with:
|
|
32
|
-
name: wheels
|
|
32
|
+
name: wheels-linux-${{ matrix.target }}
|
|
33
33
|
path: dist
|
|
34
34
|
|
|
35
35
|
windows:
|
|
@@ -39,20 +39,20 @@ jobs:
|
|
|
39
39
|
target: [x64, x86]
|
|
40
40
|
steps:
|
|
41
41
|
- uses: actions/checkout@v4
|
|
42
|
-
- uses: actions/setup-python@
|
|
42
|
+
- uses: actions/setup-python@v5
|
|
43
43
|
with:
|
|
44
|
-
python-version:
|
|
44
|
+
python-version: "3.11"
|
|
45
45
|
architecture: ${{ matrix.target }}
|
|
46
46
|
- name: Build wheels
|
|
47
47
|
uses: PyO3/maturin-action@v1
|
|
48
48
|
with:
|
|
49
49
|
target: ${{ matrix.target }}
|
|
50
50
|
args: --release --out dist --find-interpreter
|
|
51
|
-
sccache:
|
|
51
|
+
sccache: "true"
|
|
52
52
|
- name: Upload wheels
|
|
53
|
-
uses: actions/upload-artifact@
|
|
53
|
+
uses: actions/upload-artifact@v4
|
|
54
54
|
with:
|
|
55
|
-
name: wheels
|
|
55
|
+
name: wheels-windows-${{ matrix.target }}
|
|
56
56
|
path: dist
|
|
57
57
|
|
|
58
58
|
macos:
|
|
@@ -62,19 +62,19 @@ jobs:
|
|
|
62
62
|
target: [x86_64, aarch64]
|
|
63
63
|
steps:
|
|
64
64
|
- uses: actions/checkout@v4
|
|
65
|
-
- uses: actions/setup-python@
|
|
65
|
+
- uses: actions/setup-python@v5
|
|
66
66
|
with:
|
|
67
|
-
python-version:
|
|
67
|
+
python-version: "3.11"
|
|
68
68
|
- name: Build wheels
|
|
69
69
|
uses: PyO3/maturin-action@v1
|
|
70
70
|
with:
|
|
71
71
|
target: ${{ matrix.target }}
|
|
72
72
|
args: --release --out dist --find-interpreter
|
|
73
|
-
sccache:
|
|
73
|
+
sccache: "true"
|
|
74
74
|
- name: Upload wheels
|
|
75
|
-
uses: actions/upload-artifact@
|
|
75
|
+
uses: actions/upload-artifact@v4
|
|
76
76
|
with:
|
|
77
|
-
name: wheels
|
|
77
|
+
name: wheels-macos-${{ matrix.target }}
|
|
78
78
|
path: dist
|
|
79
79
|
|
|
80
80
|
sdist:
|
|
@@ -87,23 +87,22 @@ jobs:
|
|
|
87
87
|
command: sdist
|
|
88
88
|
args: --out dist
|
|
89
89
|
- name: Upload sdist
|
|
90
|
-
uses: actions/upload-artifact@
|
|
90
|
+
uses: actions/upload-artifact@v4
|
|
91
91
|
with:
|
|
92
|
-
name: wheels
|
|
92
|
+
name: wheels-sdist
|
|
93
93
|
path: dist
|
|
94
94
|
|
|
95
95
|
release:
|
|
96
96
|
name: Release
|
|
97
97
|
runs-on: ubuntu-latest
|
|
98
|
+
if: "startsWith(github.ref, 'refs/tags/')"
|
|
98
99
|
needs: [linux, windows, macos, sdist]
|
|
99
100
|
steps:
|
|
100
|
-
- uses: actions/download-artifact@
|
|
101
|
-
with:
|
|
102
|
-
name: wheels
|
|
101
|
+
- uses: actions/download-artifact@v4
|
|
103
102
|
- name: Publish to PyPI
|
|
104
103
|
uses: PyO3/maturin-action@v1
|
|
105
104
|
env:
|
|
106
105
|
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
|
|
107
106
|
with:
|
|
108
107
|
command: upload
|
|
109
|
-
args: --skip-existing
|
|
108
|
+
args: --non-interactive --skip-existing wheels-*/*
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
name: Testing
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
pull_request:
|
|
7
|
+
env:
|
|
8
|
+
CARGO_TERM_COLOR: always
|
|
9
|
+
RUST_BACKTRACE: 1
|
|
10
|
+
RUSTFLAGS: "-D warnings"
|
|
11
|
+
jobs:
|
|
12
|
+
clippy:
|
|
13
|
+
name: Clippy
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- name: Install Rust
|
|
18
|
+
run: |
|
|
19
|
+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
20
|
+
- name: Cache dependencies
|
|
21
|
+
uses: Swatinem/rust-cache@v2.7.3
|
|
22
|
+
- name: Run cargo clippy
|
|
23
|
+
run: cargo clippy --all-targets -- --deny warnings
|
|
24
|
+
fmt:
|
|
25
|
+
name: Rustfmt
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
- name: Install Rust
|
|
30
|
+
run: |
|
|
31
|
+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
32
|
+
- name: Cache dependencies
|
|
33
|
+
uses: Swatinem/rust-cache@v2.7.3
|
|
34
|
+
- name: Run cargo fmt
|
|
35
|
+
run: cargo fmt --all -- --check
|
|
36
|
+
test:
|
|
37
|
+
strategy:
|
|
38
|
+
fail-fast: false
|
|
39
|
+
matrix:
|
|
40
|
+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
|
41
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
42
|
+
runs-on: ${{ matrix.os }}
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/checkout@v4
|
|
45
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
46
|
+
uses: actions/setup-python@v5
|
|
47
|
+
with:
|
|
48
|
+
python-version: ${{ matrix.python-version }}
|
|
49
|
+
cache: "pip"
|
|
50
|
+
- name: Install dependencies
|
|
51
|
+
run: |
|
|
52
|
+
pip install -U pip
|
|
53
|
+
pip install -r requirements-dev.txt
|
|
54
|
+
pip install -e .[all]
|
|
55
|
+
maturin build --out dist
|
|
56
|
+
pip install --no-index --find-links=dist/ prelude-parser
|
|
57
|
+
- name: Run tests
|
|
58
|
+
run: pytest --cov=prelude_parser --cov-report=xml
|
|
59
|
+
- name: Upload coverage
|
|
60
|
+
uses: codecov/codecov-action@v4
|
|
61
|
+
with:
|
|
62
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
63
|
+
fail_ci_if_error: true
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v4.5.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: check-added-large-files
|
|
6
|
+
- id: check-toml
|
|
7
|
+
- id: check-yaml
|
|
8
|
+
- id: debug-statements
|
|
9
|
+
- id: end-of-file-fixer
|
|
10
|
+
- id: trailing-whitespace
|
|
11
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
12
|
+
rev: v1.9.0
|
|
13
|
+
hooks:
|
|
14
|
+
- id: mypy
|
|
15
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
16
|
+
rev: v0.3.3
|
|
17
|
+
hooks:
|
|
18
|
+
- id: ruff
|
|
19
|
+
args: [--fix, --exit-non-zero-on-fix]
|
|
20
|
+
- id: ruff-format
|
|
@@ -17,6 +17,12 @@ dependencies = [
|
|
|
17
17
|
"libc",
|
|
18
18
|
]
|
|
19
19
|
|
|
20
|
+
[[package]]
|
|
21
|
+
name = "anyhow"
|
|
22
|
+
version = "1.0.81"
|
|
23
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
24
|
+
checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247"
|
|
25
|
+
|
|
20
26
|
[[package]]
|
|
21
27
|
name = "autocfg"
|
|
22
28
|
version = "1.1.0"
|
|
@@ -52,16 +58,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|
|
52
58
|
|
|
53
59
|
[[package]]
|
|
54
60
|
name = "chrono"
|
|
55
|
-
version = "0.4.
|
|
61
|
+
version = "0.4.35"
|
|
56
62
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
57
|
-
checksum = "
|
|
63
|
+
checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a"
|
|
58
64
|
dependencies = [
|
|
59
65
|
"android-tzdata",
|
|
60
66
|
"iana-time-zone",
|
|
61
67
|
"js-sys",
|
|
62
68
|
"num-traits",
|
|
63
69
|
"wasm-bindgen",
|
|
64
|
-
"windows-targets",
|
|
70
|
+
"windows-targets 0.52.0",
|
|
65
71
|
]
|
|
66
72
|
|
|
67
73
|
[[package]]
|
|
@@ -70,6 +76,12 @@ version = "0.8.4"
|
|
|
70
76
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
71
77
|
checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
|
|
72
78
|
|
|
79
|
+
[[package]]
|
|
80
|
+
name = "heck"
|
|
81
|
+
version = "0.4.1"
|
|
82
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
83
|
+
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
|
84
|
+
|
|
73
85
|
[[package]]
|
|
74
86
|
name = "iana-time-zone"
|
|
75
87
|
version = "0.1.57"
|
|
@@ -95,9 +107,9 @@ dependencies = [
|
|
|
95
107
|
|
|
96
108
|
[[package]]
|
|
97
109
|
name = "indoc"
|
|
98
|
-
version = "
|
|
110
|
+
version = "2.0.4"
|
|
99
111
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
100
|
-
checksum = "
|
|
112
|
+
checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8"
|
|
101
113
|
|
|
102
114
|
[[package]]
|
|
103
115
|
name = "js-sys"
|
|
@@ -174,38 +186,49 @@ dependencies = [
|
|
|
174
186
|
"libc",
|
|
175
187
|
"redox_syscall",
|
|
176
188
|
"smallvec",
|
|
177
|
-
"windows-targets",
|
|
189
|
+
"windows-targets 0.48.5",
|
|
178
190
|
]
|
|
179
191
|
|
|
192
|
+
[[package]]
|
|
193
|
+
name = "portable-atomic"
|
|
194
|
+
version = "1.6.0"
|
|
195
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
196
|
+
checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0"
|
|
197
|
+
|
|
180
198
|
[[package]]
|
|
181
199
|
name = "prelude-parser"
|
|
182
|
-
version = "0.
|
|
200
|
+
version = "0.4.0"
|
|
183
201
|
dependencies = [
|
|
202
|
+
"anyhow",
|
|
184
203
|
"chrono",
|
|
185
204
|
"pyo3",
|
|
186
205
|
"roxmltree",
|
|
206
|
+
"serde",
|
|
207
|
+
"serde-xml-rs",
|
|
208
|
+
"thiserror",
|
|
187
209
|
]
|
|
188
210
|
|
|
189
211
|
[[package]]
|
|
190
212
|
name = "proc-macro2"
|
|
191
|
-
version = "1.0.
|
|
213
|
+
version = "1.0.74"
|
|
192
214
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
193
|
-
checksum = "
|
|
215
|
+
checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db"
|
|
194
216
|
dependencies = [
|
|
195
217
|
"unicode-ident",
|
|
196
218
|
]
|
|
197
219
|
|
|
198
220
|
[[package]]
|
|
199
221
|
name = "pyo3"
|
|
200
|
-
version = "0.
|
|
222
|
+
version = "0.20.3"
|
|
201
223
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
202
|
-
checksum = "
|
|
224
|
+
checksum = "53bdbb96d49157e65d45cc287af5f32ffadd5f4761438b527b055fb0d4bb8233"
|
|
203
225
|
dependencies = [
|
|
204
226
|
"cfg-if",
|
|
205
227
|
"indoc",
|
|
206
228
|
"libc",
|
|
207
229
|
"memoffset",
|
|
208
230
|
"parking_lot",
|
|
231
|
+
"portable-atomic",
|
|
209
232
|
"pyo3-build-config",
|
|
210
233
|
"pyo3-ffi",
|
|
211
234
|
"pyo3-macros",
|
|
@@ -214,9 +237,9 @@ dependencies = [
|
|
|
214
237
|
|
|
215
238
|
[[package]]
|
|
216
239
|
name = "pyo3-build-config"
|
|
217
|
-
version = "0.
|
|
240
|
+
version = "0.20.3"
|
|
218
241
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
219
|
-
checksum = "
|
|
242
|
+
checksum = "deaa5745de3f5231ce10517a1f5dd97d53e5a2fd77aa6b5842292085831d48d7"
|
|
220
243
|
dependencies = [
|
|
221
244
|
"once_cell",
|
|
222
245
|
"target-lexicon",
|
|
@@ -224,9 +247,9 @@ dependencies = [
|
|
|
224
247
|
|
|
225
248
|
[[package]]
|
|
226
249
|
name = "pyo3-ffi"
|
|
227
|
-
version = "0.
|
|
250
|
+
version = "0.20.3"
|
|
228
251
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
229
|
-
checksum = "
|
|
252
|
+
checksum = "62b42531d03e08d4ef1f6e85a2ed422eb678b8cd62b762e53891c05faf0d4afa"
|
|
230
253
|
dependencies = [
|
|
231
254
|
"libc",
|
|
232
255
|
"pyo3-build-config",
|
|
@@ -234,32 +257,34 @@ dependencies = [
|
|
|
234
257
|
|
|
235
258
|
[[package]]
|
|
236
259
|
name = "pyo3-macros"
|
|
237
|
-
version = "0.
|
|
260
|
+
version = "0.20.3"
|
|
238
261
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
239
|
-
checksum = "
|
|
262
|
+
checksum = "7305c720fa01b8055ec95e484a6eca7a83c841267f0dd5280f0c8b8551d2c158"
|
|
240
263
|
dependencies = [
|
|
241
264
|
"proc-macro2",
|
|
242
265
|
"pyo3-macros-backend",
|
|
243
266
|
"quote",
|
|
244
|
-
"syn
|
|
267
|
+
"syn",
|
|
245
268
|
]
|
|
246
269
|
|
|
247
270
|
[[package]]
|
|
248
271
|
name = "pyo3-macros-backend"
|
|
249
|
-
version = "0.
|
|
272
|
+
version = "0.20.3"
|
|
250
273
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
251
|
-
checksum = "
|
|
274
|
+
checksum = "7c7e9b68bb9c3149c5b0cade5d07f953d6d125eb4337723c4ccdb665f1f96185"
|
|
252
275
|
dependencies = [
|
|
276
|
+
"heck",
|
|
253
277
|
"proc-macro2",
|
|
278
|
+
"pyo3-build-config",
|
|
254
279
|
"quote",
|
|
255
|
-
"syn
|
|
280
|
+
"syn",
|
|
256
281
|
]
|
|
257
282
|
|
|
258
283
|
[[package]]
|
|
259
284
|
name = "quote"
|
|
260
|
-
version = "1.0.
|
|
285
|
+
version = "1.0.35"
|
|
261
286
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
262
|
-
checksum = "
|
|
287
|
+
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
|
263
288
|
dependencies = [
|
|
264
289
|
"proc-macro2",
|
|
265
290
|
]
|
|
@@ -275,12 +300,9 @@ dependencies = [
|
|
|
275
300
|
|
|
276
301
|
[[package]]
|
|
277
302
|
name = "roxmltree"
|
|
278
|
-
version = "0.
|
|
303
|
+
version = "0.19.0"
|
|
279
304
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
280
|
-
checksum = "
|
|
281
|
-
dependencies = [
|
|
282
|
-
"xmlparser",
|
|
283
|
-
]
|
|
305
|
+
checksum = "3cd14fd5e3b777a7422cca79358c57a8f6e3a703d9ac187448d0daf220c2407f"
|
|
284
306
|
|
|
285
307
|
[[package]]
|
|
286
308
|
name = "scopeguard"
|
|
@@ -289,27 +311,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
|
289
311
|
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
|
290
312
|
|
|
291
313
|
[[package]]
|
|
292
|
-
name = "
|
|
293
|
-
version = "1.
|
|
314
|
+
name = "serde"
|
|
315
|
+
version = "1.0.197"
|
|
294
316
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
295
|
-
checksum = "
|
|
317
|
+
checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"
|
|
318
|
+
dependencies = [
|
|
319
|
+
"serde_derive",
|
|
320
|
+
]
|
|
296
321
|
|
|
297
322
|
[[package]]
|
|
298
|
-
name = "
|
|
299
|
-
version = "
|
|
323
|
+
name = "serde-xml-rs"
|
|
324
|
+
version = "0.6.0"
|
|
300
325
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
301
|
-
checksum = "
|
|
326
|
+
checksum = "fb3aa78ecda1ebc9ec9847d5d3aba7d618823446a049ba2491940506da6e2782"
|
|
327
|
+
dependencies = [
|
|
328
|
+
"log",
|
|
329
|
+
"serde",
|
|
330
|
+
"thiserror",
|
|
331
|
+
"xml-rs",
|
|
332
|
+
]
|
|
333
|
+
|
|
334
|
+
[[package]]
|
|
335
|
+
name = "serde_derive"
|
|
336
|
+
version = "1.0.197"
|
|
337
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
338
|
+
checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
|
|
302
339
|
dependencies = [
|
|
303
340
|
"proc-macro2",
|
|
304
341
|
"quote",
|
|
305
|
-
"
|
|
342
|
+
"syn",
|
|
306
343
|
]
|
|
307
344
|
|
|
345
|
+
[[package]]
|
|
346
|
+
name = "smallvec"
|
|
347
|
+
version = "1.11.1"
|
|
348
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
349
|
+
checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
|
|
350
|
+
|
|
308
351
|
[[package]]
|
|
309
352
|
name = "syn"
|
|
310
|
-
version = "2.0.
|
|
353
|
+
version = "2.0.46"
|
|
311
354
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
312
|
-
checksum = "
|
|
355
|
+
checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e"
|
|
313
356
|
dependencies = [
|
|
314
357
|
"proc-macro2",
|
|
315
358
|
"quote",
|
|
@@ -322,6 +365,26 @@ version = "0.12.11"
|
|
|
322
365
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
323
366
|
checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a"
|
|
324
367
|
|
|
368
|
+
[[package]]
|
|
369
|
+
name = "thiserror"
|
|
370
|
+
version = "1.0.58"
|
|
371
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
372
|
+
checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297"
|
|
373
|
+
dependencies = [
|
|
374
|
+
"thiserror-impl",
|
|
375
|
+
]
|
|
376
|
+
|
|
377
|
+
[[package]]
|
|
378
|
+
name = "thiserror-impl"
|
|
379
|
+
version = "1.0.58"
|
|
380
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
381
|
+
checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7"
|
|
382
|
+
dependencies = [
|
|
383
|
+
"proc-macro2",
|
|
384
|
+
"quote",
|
|
385
|
+
"syn",
|
|
386
|
+
]
|
|
387
|
+
|
|
325
388
|
[[package]]
|
|
326
389
|
name = "unicode-ident"
|
|
327
390
|
version = "1.0.12"
|
|
@@ -330,9 +393,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
|
|
330
393
|
|
|
331
394
|
[[package]]
|
|
332
395
|
name = "unindent"
|
|
333
|
-
version = "0.
|
|
396
|
+
version = "0.2.3"
|
|
334
397
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
335
|
-
checksum = "
|
|
398
|
+
checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce"
|
|
336
399
|
|
|
337
400
|
[[package]]
|
|
338
401
|
name = "wasm-bindgen"
|
|
@@ -355,7 +418,7 @@ dependencies = [
|
|
|
355
418
|
"once_cell",
|
|
356
419
|
"proc-macro2",
|
|
357
420
|
"quote",
|
|
358
|
-
"syn
|
|
421
|
+
"syn",
|
|
359
422
|
"wasm-bindgen-shared",
|
|
360
423
|
]
|
|
361
424
|
|
|
@@ -377,7 +440,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
|
|
|
377
440
|
dependencies = [
|
|
378
441
|
"proc-macro2",
|
|
379
442
|
"quote",
|
|
380
|
-
"syn
|
|
443
|
+
"syn",
|
|
381
444
|
"wasm-bindgen-backend",
|
|
382
445
|
"wasm-bindgen-shared",
|
|
383
446
|
]
|
|
@@ -394,7 +457,7 @@ version = "0.48.0"
|
|
|
394
457
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
395
458
|
checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
|
|
396
459
|
dependencies = [
|
|
397
|
-
"windows-targets",
|
|
460
|
+
"windows-targets 0.48.5",
|
|
398
461
|
]
|
|
399
462
|
|
|
400
463
|
[[package]]
|
|
@@ -403,13 +466,28 @@ version = "0.48.5"
|
|
|
403
466
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
404
467
|
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
|
405
468
|
dependencies = [
|
|
406
|
-
"windows_aarch64_gnullvm",
|
|
407
|
-
"windows_aarch64_msvc",
|
|
408
|
-
"windows_i686_gnu",
|
|
409
|
-
"windows_i686_msvc",
|
|
410
|
-
"windows_x86_64_gnu",
|
|
411
|
-
"windows_x86_64_gnullvm",
|
|
412
|
-
"windows_x86_64_msvc",
|
|
469
|
+
"windows_aarch64_gnullvm 0.48.5",
|
|
470
|
+
"windows_aarch64_msvc 0.48.5",
|
|
471
|
+
"windows_i686_gnu 0.48.5",
|
|
472
|
+
"windows_i686_msvc 0.48.5",
|
|
473
|
+
"windows_x86_64_gnu 0.48.5",
|
|
474
|
+
"windows_x86_64_gnullvm 0.48.5",
|
|
475
|
+
"windows_x86_64_msvc 0.48.5",
|
|
476
|
+
]
|
|
477
|
+
|
|
478
|
+
[[package]]
|
|
479
|
+
name = "windows-targets"
|
|
480
|
+
version = "0.52.0"
|
|
481
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
482
|
+
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
|
|
483
|
+
dependencies = [
|
|
484
|
+
"windows_aarch64_gnullvm 0.52.0",
|
|
485
|
+
"windows_aarch64_msvc 0.52.0",
|
|
486
|
+
"windows_i686_gnu 0.52.0",
|
|
487
|
+
"windows_i686_msvc 0.52.0",
|
|
488
|
+
"windows_x86_64_gnu 0.52.0",
|
|
489
|
+
"windows_x86_64_gnullvm 0.52.0",
|
|
490
|
+
"windows_x86_64_msvc 0.52.0",
|
|
413
491
|
]
|
|
414
492
|
|
|
415
493
|
[[package]]
|
|
@@ -418,36 +496,72 @@ version = "0.48.5"
|
|
|
418
496
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
419
497
|
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
|
420
498
|
|
|
499
|
+
[[package]]
|
|
500
|
+
name = "windows_aarch64_gnullvm"
|
|
501
|
+
version = "0.52.0"
|
|
502
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
503
|
+
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
|
|
504
|
+
|
|
421
505
|
[[package]]
|
|
422
506
|
name = "windows_aarch64_msvc"
|
|
423
507
|
version = "0.48.5"
|
|
424
508
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
425
509
|
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
|
426
510
|
|
|
511
|
+
[[package]]
|
|
512
|
+
name = "windows_aarch64_msvc"
|
|
513
|
+
version = "0.52.0"
|
|
514
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
515
|
+
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
|
|
516
|
+
|
|
427
517
|
[[package]]
|
|
428
518
|
name = "windows_i686_gnu"
|
|
429
519
|
version = "0.48.5"
|
|
430
520
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
431
521
|
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
|
432
522
|
|
|
523
|
+
[[package]]
|
|
524
|
+
name = "windows_i686_gnu"
|
|
525
|
+
version = "0.52.0"
|
|
526
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
527
|
+
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
|
|
528
|
+
|
|
433
529
|
[[package]]
|
|
434
530
|
name = "windows_i686_msvc"
|
|
435
531
|
version = "0.48.5"
|
|
436
532
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
437
533
|
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
|
438
534
|
|
|
535
|
+
[[package]]
|
|
536
|
+
name = "windows_i686_msvc"
|
|
537
|
+
version = "0.52.0"
|
|
538
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
539
|
+
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
|
|
540
|
+
|
|
439
541
|
[[package]]
|
|
440
542
|
name = "windows_x86_64_gnu"
|
|
441
543
|
version = "0.48.5"
|
|
442
544
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
443
545
|
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
|
444
546
|
|
|
547
|
+
[[package]]
|
|
548
|
+
name = "windows_x86_64_gnu"
|
|
549
|
+
version = "0.52.0"
|
|
550
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
551
|
+
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
|
|
552
|
+
|
|
445
553
|
[[package]]
|
|
446
554
|
name = "windows_x86_64_gnullvm"
|
|
447
555
|
version = "0.48.5"
|
|
448
556
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
449
557
|
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
|
450
558
|
|
|
559
|
+
[[package]]
|
|
560
|
+
name = "windows_x86_64_gnullvm"
|
|
561
|
+
version = "0.52.0"
|
|
562
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
563
|
+
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
|
|
564
|
+
|
|
451
565
|
[[package]]
|
|
452
566
|
name = "windows_x86_64_msvc"
|
|
453
567
|
version = "0.48.5"
|
|
@@ -455,7 +569,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
|
455
569
|
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
|
456
570
|
|
|
457
571
|
[[package]]
|
|
458
|
-
name = "
|
|
459
|
-
version = "0.
|
|
572
|
+
name = "windows_x86_64_msvc"
|
|
573
|
+
version = "0.52.0"
|
|
574
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
575
|
+
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
|
|
576
|
+
|
|
577
|
+
[[package]]
|
|
578
|
+
name = "xml-rs"
|
|
579
|
+
version = "0.8.19"
|
|
460
580
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
461
|
-
checksum = "
|
|
581
|
+
checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "prelude-parser"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.0"
|
|
4
4
|
description = "Parses XML files exported from Prelude EDC into formats usable by Python."
|
|
5
5
|
edition = "2021"
|
|
6
6
|
license = "MIT"
|
|
@@ -14,6 +14,10 @@ name = "_prelude_parser"
|
|
|
14
14
|
crate-type = ["cdylib"]
|
|
15
15
|
|
|
16
16
|
[dependencies]
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
anyhow = "1.0.81"
|
|
18
|
+
chrono = "0.4.35"
|
|
19
|
+
pyo3 = { version = "0.20.3", features = ["extension-module", "abi3-py38"] }
|
|
20
|
+
roxmltree = "0.19.0"
|
|
21
|
+
serde = { version = "1.0.197", features = ["derive"] }
|
|
22
|
+
serde-xml-rs = "0.6.0"
|
|
23
|
+
thiserror = "1.0.58"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: prelude-parser
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: 3.8
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
from prelude_parser.types import FlatFormInfo
|
|
5
6
|
|
|
6
7
|
def _parse_flat_file_to_dict(
|
|
7
8
|
xml_file: str | Path, short_names: bool
|
|
8
|
-
) -> dict[str,
|
|
9
|
+
) -> dict[str, FlatFormInfo]: ...
|
|
9
10
|
def _parse_flat_file_to_pandas_dict(
|
|
10
11
|
xml_file: str | Path, short_names: bool
|
|
11
|
-
) -> dict[str,
|
|
12
|
+
) -> dict[str, FlatFormInfo]: ...
|
|
12
13
|
|
|
13
14
|
class FileNotFoundError(Exception):
|
|
14
15
|
pass
|
|
@@ -6,18 +6,17 @@ from typing import Any
|
|
|
6
6
|
from camel_converter import to_pascal
|
|
7
7
|
|
|
8
8
|
from prelude_parser._prelude_parser import _parse_flat_file_to_dict
|
|
9
|
+
from prelude_parser.types import FieldInfo, FlatFormInfo
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class _MetaCls(type):
|
|
12
13
|
def __new__(
|
|
13
|
-
cls, clsname: str, superclasses: tuple[type, ...], attributedict: dict[str,
|
|
14
|
+
cls, clsname: str, superclasses: tuple[type, ...], attributedict: dict[str, FieldInfo]
|
|
14
15
|
) -> _MetaCls:
|
|
15
16
|
return super().__new__(cls, clsname, superclasses, attributedict)
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
def parse_to_dict(
|
|
19
|
-
xml_file: str | Path, *, short_names: bool = False
|
|
20
|
-
) -> dict[str, list[dict[str, Any]]]:
|
|
19
|
+
def parse_to_dict(xml_file: str | Path, *, short_names: bool = False) -> dict[str, FlatFormInfo]:
|
|
21
20
|
"""Parse a Prelude flat XML file into a dict.
|
|
22
21
|
|
|
23
22
|
Args:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["maturin>=1.
|
|
2
|
+
requires = ["maturin>=1.5,<2.0"]
|
|
3
3
|
build-backend = "maturin"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
@@ -36,27 +36,6 @@ module-name = "prelude_parser._prelude_parser"
|
|
|
36
36
|
binding = "pyo3"
|
|
37
37
|
features = ["pyo3/extension-module"]
|
|
38
38
|
|
|
39
|
-
[tool.black]
|
|
40
|
-
line-length = 100
|
|
41
|
-
include = '\.pyi?$'
|
|
42
|
-
exclude = '''
|
|
43
|
-
/(
|
|
44
|
-
\.egg
|
|
45
|
-
| \.git
|
|
46
|
-
| \.hg
|
|
47
|
-
| \.mypy_cache
|
|
48
|
-
| \.nox
|
|
49
|
-
| \.tox
|
|
50
|
-
| \.venv
|
|
51
|
-
| \venv
|
|
52
|
-
| _build
|
|
53
|
-
| buck-out
|
|
54
|
-
| build
|
|
55
|
-
| dist
|
|
56
|
-
| setup.py
|
|
57
|
-
)/
|
|
58
|
-
'''
|
|
59
|
-
|
|
60
39
|
[tool.pytest.ini_options]
|
|
61
40
|
minversion = "6.0"
|
|
62
41
|
addopts = "--cov=prelude_parser --cov-report term-missing --no-cov-on-fail"
|
|
@@ -71,7 +50,24 @@ disallow_untyped_defs = false
|
|
|
71
50
|
|
|
72
51
|
[tool.ruff]
|
|
73
52
|
select=["E", "F", "UP", "I001", "T201", "T203"]
|
|
74
|
-
ignore=[
|
|
53
|
+
ignore=[
|
|
54
|
+
# Recommened ignores by ruff when using formatter
|
|
55
|
+
"E501",
|
|
56
|
+
"W191",
|
|
57
|
+
"E111",
|
|
58
|
+
"E114",
|
|
59
|
+
"E117",
|
|
60
|
+
"D206",
|
|
61
|
+
"D300",
|
|
62
|
+
"Q000",
|
|
63
|
+
"Q001",
|
|
64
|
+
"Q002",
|
|
65
|
+
"Q003",
|
|
66
|
+
"COM812",
|
|
67
|
+
"COM819",
|
|
68
|
+
"ISC001",
|
|
69
|
+
"ISC002",
|
|
70
|
+
]
|
|
75
71
|
line-length = 100
|
|
76
72
|
target-version = "py38"
|
|
77
73
|
fix = true
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
use std::path::PathBuf;
|
|
2
|
+
|
|
3
|
+
use pyo3::create_exception;
|
|
4
|
+
use pyo3::exceptions::PyException;
|
|
5
|
+
use thiserror::Error;
|
|
6
|
+
|
|
7
|
+
#[derive(Error, Debug)]
|
|
8
|
+
pub enum XmlFileValidationError {
|
|
9
|
+
#[error("File not found: {0:?}")]
|
|
10
|
+
FileNotFound(PathBuf),
|
|
11
|
+
|
|
12
|
+
#[error("{0:?} is not an xml file")]
|
|
13
|
+
InvalidFileType(PathBuf),
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
create_exception!(_prelude_parser, FileNotFoundError, PyException);
|
|
17
|
+
create_exception!(_prelude_parser, InvalidFileTypeError, PyException);
|
|
18
|
+
create_exception!(_prelude_parser, ParsingError, PyException);
|
|
@@ -1,34 +1,39 @@
|
|
|
1
|
+
mod errors;
|
|
2
|
+
mod utils;
|
|
3
|
+
|
|
1
4
|
use std::collections::HashMap;
|
|
2
5
|
use std::fs::read_to_string;
|
|
3
6
|
use std::path::PathBuf;
|
|
4
7
|
|
|
5
8
|
use chrono::{Datelike, NaiveDate};
|
|
6
|
-
use pyo3::create_exception;
|
|
7
|
-
use pyo3::exceptions::PyException;
|
|
8
9
|
use pyo3::prelude::*;
|
|
9
10
|
use pyo3::types::{IntoPyDict, PyDict, PyList};
|
|
10
11
|
use roxmltree::Document;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if next.is_uppercase() && c != '_' {
|
|
26
|
-
snake_string.push('_');
|
|
13
|
+
use crate::errors::{
|
|
14
|
+
FileNotFoundError, InvalidFileTypeError, ParsingError, XmlFileValidationError,
|
|
15
|
+
};
|
|
16
|
+
use crate::utils::{to_snake, validate_file};
|
|
17
|
+
|
|
18
|
+
fn check_valid_file(xml_file: &PathBuf) -> PyResult<()> {
|
|
19
|
+
if let Err(e) = validate_file(xml_file) {
|
|
20
|
+
match e {
|
|
21
|
+
XmlFileValidationError::FileNotFound(_) => {
|
|
22
|
+
return Err(FileNotFoundError::new_err(format!(
|
|
23
|
+
"File not found: {:?}",
|
|
24
|
+
xml_file
|
|
25
|
+
)))
|
|
27
26
|
}
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
XmlFileValidationError::InvalidFileType(_) => {
|
|
28
|
+
return Err(InvalidFileTypeError::new_err(format!(
|
|
29
|
+
"{:?} is not an xml file",
|
|
30
|
+
xml_file
|
|
31
|
+
)))
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
};
|
|
30
35
|
|
|
31
|
-
|
|
36
|
+
Ok(())
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
fn py_list_append<'py>(
|
|
@@ -169,7 +174,7 @@ fn parse_xml_pandas<'py>(
|
|
|
169
174
|
} else {
|
|
170
175
|
to_snake(child.tag_name().name())
|
|
171
176
|
};
|
|
172
|
-
if let Some(c) = data.get_item(column
|
|
177
|
+
if let Ok(Some(c)) = data.get_item(&column) {
|
|
173
178
|
py_list_append(py, child.text(), c.extract()?)?;
|
|
174
179
|
data.set_item(column, c)?;
|
|
175
180
|
} else {
|
|
@@ -194,25 +199,9 @@ fn parse_xml_pandas<'py>(
|
|
|
194
199
|
}
|
|
195
200
|
}
|
|
196
201
|
|
|
197
|
-
fn validate_file(xml_file: &PathBuf) -> PyResult<()> {
|
|
198
|
-
if !xml_file.is_file() {
|
|
199
|
-
return Err(FileNotFoundError::new_err(format!(
|
|
200
|
-
"File not found: {:?}",
|
|
201
|
-
xml_file
|
|
202
|
-
)));
|
|
203
|
-
} else if xml_file.extension().unwrap() != "xml" {
|
|
204
|
-
return Err(InvalidFileTypeError::new_err(format!(
|
|
205
|
-
"{:?} is not an xml file",
|
|
206
|
-
xml_file
|
|
207
|
-
)));
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
Ok(())
|
|
211
|
-
}
|
|
212
|
-
|
|
213
202
|
#[pyfunction]
|
|
214
203
|
fn _parse_flat_file_to_dict(py: Python, xml_file: PathBuf, short_names: bool) -> PyResult<&PyDict> {
|
|
215
|
-
|
|
204
|
+
check_valid_file(&xml_file)?;
|
|
216
205
|
let data = parse_xml(py, &xml_file, short_names)?;
|
|
217
206
|
|
|
218
207
|
Ok(data)
|
|
@@ -224,7 +213,7 @@ fn _parse_flat_file_to_pandas_dict(
|
|
|
224
213
|
xml_file: PathBuf,
|
|
225
214
|
short_names: bool,
|
|
226
215
|
) -> PyResult<&PyDict> {
|
|
227
|
-
|
|
216
|
+
check_valid_file(&xml_file)?;
|
|
228
217
|
let data = parse_xml_pandas(py, &xml_file, short_names)?;
|
|
229
218
|
|
|
230
219
|
Ok(data)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
use std::path::PathBuf;
|
|
2
|
+
|
|
3
|
+
use crate::errors::XmlFileValidationError;
|
|
4
|
+
|
|
5
|
+
pub fn to_snake(camel_string: &str) -> String {
|
|
6
|
+
let mut snake_string = String::with_capacity(
|
|
7
|
+
camel_string.len() + camel_string.chars().filter(|c| c.is_uppercase()).count(),
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
let mut chars = camel_string.chars().peekable();
|
|
11
|
+
while let Some(c) = chars.next() {
|
|
12
|
+
snake_string.push(c);
|
|
13
|
+
if let Some(next) = chars.peek() {
|
|
14
|
+
if next.is_uppercase() && c != '_' {
|
|
15
|
+
snake_string.push('_');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
snake_string.to_lowercase()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
pub fn validate_file(xml_file: &PathBuf) -> Result<(), XmlFileValidationError> {
|
|
24
|
+
if !xml_file.is_file() {
|
|
25
|
+
return Err(XmlFileValidationError::FileNotFound(xml_file.to_owned()));
|
|
26
|
+
} else if xml_file.extension().unwrap() != "xml" {
|
|
27
|
+
return Err(XmlFileValidationError::InvalidFileType(xml_file.to_owned()));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
Ok(())
|
|
31
|
+
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
name: Testing
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches:
|
|
5
|
-
- main
|
|
6
|
-
pull_request:
|
|
7
|
-
env:
|
|
8
|
-
CARGO_TERM_COLOR: always
|
|
9
|
-
RUST_BACKTRACE: 1
|
|
10
|
-
RUSTFLAGS: "-D warnings"
|
|
11
|
-
jobs:
|
|
12
|
-
clippy:
|
|
13
|
-
name: Clippy
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v4
|
|
17
|
-
- name: Install Rust
|
|
18
|
-
run: |
|
|
19
|
-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
20
|
-
- name: Cache dependencies
|
|
21
|
-
uses: Swatinem/rust-cache@v2.7.0
|
|
22
|
-
- name: Run cargo clippy
|
|
23
|
-
run: cargo clippy --all-targets -- --deny warnings
|
|
24
|
-
fmt:
|
|
25
|
-
name: Rustfmt
|
|
26
|
-
runs-on: ubuntu-latest
|
|
27
|
-
steps:
|
|
28
|
-
- uses: actions/checkout@v4
|
|
29
|
-
- name: Install Rust
|
|
30
|
-
run: |
|
|
31
|
-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
32
|
-
- name: Cache dependencies
|
|
33
|
-
uses: Swatinem/rust-cache@v2.7.0
|
|
34
|
-
- name: Run cargo fmt
|
|
35
|
-
run: cargo fmt --all -- --check
|
|
36
|
-
test:
|
|
37
|
-
strategy:
|
|
38
|
-
fail-fast: false
|
|
39
|
-
matrix:
|
|
40
|
-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
|
41
|
-
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
42
|
-
runs-on: ${{ matrix.os }}
|
|
43
|
-
steps:
|
|
44
|
-
- uses: actions/checkout@v4
|
|
45
|
-
- name: Set up Python ${{ matrix.python-version }}
|
|
46
|
-
uses: actions/setup-python@v4
|
|
47
|
-
with:
|
|
48
|
-
python-version: ${{ matrix.python-version }}
|
|
49
|
-
cache: "pip"
|
|
50
|
-
- name: Install dependencies
|
|
51
|
-
run: |
|
|
52
|
-
pip install -U pip
|
|
53
|
-
pip install -r requirements-dev.txt
|
|
54
|
-
pip install -e .[all]
|
|
55
|
-
maturin build --out dist
|
|
56
|
-
pip install --no-index --find-links=dist/ prelude-parser
|
|
57
|
-
- name: Run tests
|
|
58
|
-
run: pytest --cov=prelude_parser --cov-report=xml
|
|
59
|
-
- name: Upload coverage
|
|
60
|
-
uses: codecov/codecov-action@v3
|
|
61
|
-
with:
|
|
62
|
-
token: ${{ secrets.CODECOV_TOKEN }}
|
|
63
|
-
fail_ci_if_error: true
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
repos:
|
|
2
|
-
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
-
rev: v4.4.0
|
|
4
|
-
hooks:
|
|
5
|
-
- id: check-added-large-files
|
|
6
|
-
- id: check-toml
|
|
7
|
-
- id: check-yaml
|
|
8
|
-
- id: debug-statements
|
|
9
|
-
- id: end-of-file-fixer
|
|
10
|
-
- id: trailing-whitespace
|
|
11
|
-
- repo: https://github.com/psf/black
|
|
12
|
-
rev: 23.9.1
|
|
13
|
-
hooks:
|
|
14
|
-
- id: black
|
|
15
|
-
language_version: python3
|
|
16
|
-
args: [--line-length=100]
|
|
17
|
-
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
18
|
-
rev: v1.5.1
|
|
19
|
-
hooks:
|
|
20
|
-
- id: mypy
|
|
21
|
-
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
22
|
-
rev: v0.0.292
|
|
23
|
-
hooks:
|
|
24
|
-
- id: ruff
|
|
25
|
-
args: [--fix, --exit-non-zero-on-fix]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|