simparse 0.3.2__tar.gz → 0.3.3__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.
Potentially problematic release.
This version of simparse might be problematic. Click here for more details.
- {simparse-0.3.2 → simparse-0.3.3}/Cargo.lock +4 -4
- {simparse-0.3.2 → simparse-0.3.3}/Cargo.toml +1 -1
- {simparse-0.3.2 → simparse-0.3.3}/PKG-INFO +68 -68
- {simparse-0.3.2 → simparse-0.3.3}/README.md +67 -67
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-core/src/dispatch.rs +132 -132
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-core/src/lib.rs +18 -18
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-core/src/parsers/comsol.rs +55 -6
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-core/src/parsers/flotherm.rs +554 -554
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-core/src/parsers/hfss.rs +620 -620
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-core/src/parsers/icepak.rs +114 -114
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-core/src/parsers/mod.rs +21 -21
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-core/src/schema.rs +343 -343
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-core/src/summary.rs +782 -782
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-core/tests/synthetic.rs +554 -554
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-hdf5/src/lib.rs +564 -564
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-py/src/lib.rs +67 -67
- {simparse-0.3.2 → simparse-0.3.3}/pyproject.toml +20 -20
- {simparse-0.3.2 → simparse-0.3.3}/python/simparse/__init__.pyi +21 -21
- {simparse-0.3.2 → simparse-0.3.3}/LICENSE +0 -0
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-core/Cargo.toml +0 -0
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-core/src/error.rs +0 -0
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-core/src/parsers/abaqus.rs +0 -0
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-hdf5/Cargo.toml +0 -0
- {simparse-0.3.2 → simparse-0.3.3}/crates/simparse-py/Cargo.toml +0 -0
- {simparse-0.3.2 → simparse-0.3.3}/python/simparse/__init__.py +0 -0
- {simparse-0.3.2 → simparse-0.3.3}/python/simparse/py.typed +0 -0
|
@@ -826,7 +826,7 @@ checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214"
|
|
|
826
826
|
|
|
827
827
|
[[package]]
|
|
828
828
|
name = "simparse-cli"
|
|
829
|
-
version = "0.3.
|
|
829
|
+
version = "0.3.3"
|
|
830
830
|
dependencies = [
|
|
831
831
|
"anyhow",
|
|
832
832
|
"clap",
|
|
@@ -837,7 +837,7 @@ dependencies = [
|
|
|
837
837
|
|
|
838
838
|
[[package]]
|
|
839
839
|
name = "simparse-core"
|
|
840
|
-
version = "0.3.
|
|
840
|
+
version = "0.3.3"
|
|
841
841
|
dependencies = [
|
|
842
842
|
"flate2",
|
|
843
843
|
"quick-xml",
|
|
@@ -854,7 +854,7 @@ dependencies = [
|
|
|
854
854
|
|
|
855
855
|
[[package]]
|
|
856
856
|
name = "simparse-hdf5"
|
|
857
|
-
version = "0.3.
|
|
857
|
+
version = "0.3.3"
|
|
858
858
|
dependencies = [
|
|
859
859
|
"flate2",
|
|
860
860
|
"hdf5-pure",
|
|
@@ -867,7 +867,7 @@ dependencies = [
|
|
|
867
867
|
|
|
868
868
|
[[package]]
|
|
869
869
|
name = "simparse-py"
|
|
870
|
-
version = "0.3.
|
|
870
|
+
version = "0.3.3"
|
|
871
871
|
dependencies = [
|
|
872
872
|
"pyo3",
|
|
873
873
|
"serde",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: simparse
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Classifier: Development Status :: 3 - Alpha
|
|
5
5
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -13,75 +13,75 @@ License-Expression: Apache-2.0
|
|
|
13
13
|
Requires-Python: >=3.9
|
|
14
14
|
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
15
15
|
|
|
16
|
-
# simparse
|
|
17
|
-
|
|
18
|
-
`simparse` is a lightweight Rust and Python scanner for simulation project and
|
|
19
|
-
case metadata.
|
|
20
|
-
|
|
21
|
-
## Supported formats
|
|
22
|
-
|
|
23
|
-
| Format | Files |
|
|
24
|
-
|---|---|
|
|
25
|
-
| COMSOL | `.mph` |
|
|
26
|
-
| Abaqus | `.inp`, `.inc` |
|
|
27
|
-
| Fluent | `.cas.h5`, `.msh.h5` |
|
|
28
|
-
| Ansys Electronics Desktop (HFSS / Icepak) | `.aedt`, `.aedtz` |
|
|
29
|
-
| Ansys Mechanical | `.mechdb`, `.mechdat` |
|
|
30
|
-
| Icepak Classic | `.tzr` |
|
|
31
|
-
| Simcenter FloTHERM | `.pack`, `.xml`, `.floxml` |
|
|
32
|
-
|
|
33
|
-
## Design
|
|
34
|
-
|
|
35
|
-
`simparse` is meant to compose with existing simulation tools, not replace them.
|
|
36
|
-
It focuses on lightweight agent workflows: metadata, inventory, quick directory
|
|
37
|
-
scans, and deciding when a heavier vendor or Python tool should be called next.
|
|
38
|
-
See [tool design principles](docs/design-principles.md).
|
|
39
|
-
|
|
40
|
-
## CLI
|
|
41
|
-
|
|
42
|
-
```powershell
|
|
43
|
-
cargo run -p simparse-cli -- inspect /path/to/model.mph --json
|
|
44
|
-
cargo run -p simparse-cli -- inspect /path/to/thermal-model.xml --json --summary
|
|
45
|
-
cargo run -p simparse-cli -- inspect /path/to/model.mph --json --summary
|
|
46
|
-
cargo run -p simparse-cli -- scan /path/to/history --jsonl
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Use `--summary` for a deterministic, bounded preflight view. It reports total
|
|
50
|
-
counts with capped samples and explicit parser limitations. Omit it when the
|
|
51
|
-
full shallow inventory is needed.
|
|
52
|
-
|
|
53
|
-
FloXML files commonly use the generic `.xml` suffix. `simparse` checks their
|
|
54
|
-
root element, so directory scans include `<xml_case>` and `<sm_xml_case>` files
|
|
55
|
-
while skipping unrelated XML.
|
|
56
|
-
|
|
57
|
-
## Python
|
|
58
|
-
|
|
59
|
-
```powershell
|
|
16
|
+
# simparse
|
|
17
|
+
|
|
18
|
+
`simparse` is a lightweight Rust and Python scanner for simulation project and
|
|
19
|
+
case metadata.
|
|
20
|
+
|
|
21
|
+
## Supported formats
|
|
22
|
+
|
|
23
|
+
| Format | Files |
|
|
24
|
+
|---|---|
|
|
25
|
+
| COMSOL | `.mph` |
|
|
26
|
+
| Abaqus | `.inp`, `.inc` |
|
|
27
|
+
| Fluent | `.cas.h5`, `.msh.h5` |
|
|
28
|
+
| Ansys Electronics Desktop (HFSS / Icepak) | `.aedt`, `.aedtz` |
|
|
29
|
+
| Ansys Mechanical | `.mechdb`, `.mechdat` |
|
|
30
|
+
| Icepak Classic | `.tzr` |
|
|
31
|
+
| Simcenter FloTHERM | `.pack`, `.xml`, `.floxml` |
|
|
32
|
+
|
|
33
|
+
## Design
|
|
34
|
+
|
|
35
|
+
`simparse` is meant to compose with existing simulation tools, not replace them.
|
|
36
|
+
It focuses on lightweight agent workflows: metadata, inventory, quick directory
|
|
37
|
+
scans, and deciding when a heavier vendor or Python tool should be called next.
|
|
38
|
+
See [tool design principles](docs/design-principles.md).
|
|
39
|
+
|
|
40
|
+
## CLI
|
|
41
|
+
|
|
42
|
+
```powershell
|
|
43
|
+
cargo run -p simparse-cli -- inspect /path/to/model.mph --json
|
|
44
|
+
cargo run -p simparse-cli -- inspect /path/to/thermal-model.xml --json --summary
|
|
45
|
+
cargo run -p simparse-cli -- inspect /path/to/model.mph --json --summary
|
|
46
|
+
cargo run -p simparse-cli -- scan /path/to/history --jsonl
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Use `--summary` for a deterministic, bounded preflight view. It reports total
|
|
50
|
+
counts with capped samples and explicit parser limitations. Omit it when the
|
|
51
|
+
full shallow inventory is needed.
|
|
52
|
+
|
|
53
|
+
FloXML files commonly use the generic `.xml` suffix. `simparse` checks their
|
|
54
|
+
root element, so directory scans include `<xml_case>` and `<sm_xml_case>` files
|
|
55
|
+
while skipping unrelated XML.
|
|
56
|
+
|
|
57
|
+
## Python
|
|
58
|
+
|
|
59
|
+
```powershell
|
|
60
60
|
maturin develop
|
|
61
61
|
python -c "import simparse; print(simparse.inspect('/path/to/model.inp', summary=True))"
|
|
62
62
|
python -c "import simparse; print(simparse.scan(['/path/to/history'], summary=True))"
|
|
63
63
|
```
|
|
64
|
-
|
|
65
|
-
## Benchmark
|
|
66
|
-
|
|
67
|
-

|
|
68
|
-
|
|
69
|
-
```powershell
|
|
70
|
-
python benchmarks/compare.py
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
This benchmark models one practical agent path: call one external tool to scan a
|
|
74
|
-
group of public simulation artifacts. The bars include process startup and
|
|
75
|
-
library import cost. The JSON artifact also records an in-process Python
|
|
76
|
-
baseline for context; those numbers are useful for library-level comparison, but
|
|
77
|
-
are not the primary agent tool-call scenario.
|
|
78
|
-
|
|
79
|
-
The benchmark downloads public URLs listed in `benchmarks/public-artifacts.json`
|
|
80
|
-
into `target/` and writes `artifacts/public-benchmark.json` plus
|
|
81
|
-
`artifacts/public-benchmark.svg`. Vendor-native parser timings are not included
|
|
82
|
-
because they require locally licensed software or APIs.
|
|
83
|
-
|
|
84
|
-
## License
|
|
85
|
-
|
|
86
|
-
Apache-2.0
|
|
64
|
+
|
|
65
|
+
## Benchmark
|
|
66
|
+
|
|
67
|
+

|
|
68
|
+
|
|
69
|
+
```powershell
|
|
70
|
+
python benchmarks/compare.py
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
This benchmark models one practical agent path: call one external tool to scan a
|
|
74
|
+
group of public simulation artifacts. The bars include process startup and
|
|
75
|
+
library import cost. The JSON artifact also records an in-process Python
|
|
76
|
+
baseline for context; those numbers are useful for library-level comparison, but
|
|
77
|
+
are not the primary agent tool-call scenario.
|
|
78
|
+
|
|
79
|
+
The benchmark downloads public URLs listed in `benchmarks/public-artifacts.json`
|
|
80
|
+
into `target/` and writes `artifacts/public-benchmark.json` plus
|
|
81
|
+
`artifacts/public-benchmark.svg`. Vendor-native parser timings are not included
|
|
82
|
+
because they require locally licensed software or APIs.
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
Apache-2.0
|
|
87
87
|
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
# simparse
|
|
2
|
-
|
|
3
|
-
`simparse` is a lightweight Rust and Python scanner for simulation project and
|
|
4
|
-
case metadata.
|
|
5
|
-
|
|
6
|
-
## Supported formats
|
|
7
|
-
|
|
8
|
-
| Format | Files |
|
|
9
|
-
|---|---|
|
|
10
|
-
| COMSOL | `.mph` |
|
|
11
|
-
| Abaqus | `.inp`, `.inc` |
|
|
12
|
-
| Fluent | `.cas.h5`, `.msh.h5` |
|
|
13
|
-
| Ansys Electronics Desktop (HFSS / Icepak) | `.aedt`, `.aedtz` |
|
|
14
|
-
| Ansys Mechanical | `.mechdb`, `.mechdat` |
|
|
15
|
-
| Icepak Classic | `.tzr` |
|
|
16
|
-
| Simcenter FloTHERM | `.pack`, `.xml`, `.floxml` |
|
|
17
|
-
|
|
18
|
-
## Design
|
|
19
|
-
|
|
20
|
-
`simparse` is meant to compose with existing simulation tools, not replace them.
|
|
21
|
-
It focuses on lightweight agent workflows: metadata, inventory, quick directory
|
|
22
|
-
scans, and deciding when a heavier vendor or Python tool should be called next.
|
|
23
|
-
See [tool design principles](docs/design-principles.md).
|
|
24
|
-
|
|
25
|
-
## CLI
|
|
26
|
-
|
|
27
|
-
```powershell
|
|
28
|
-
cargo run -p simparse-cli -- inspect /path/to/model.mph --json
|
|
29
|
-
cargo run -p simparse-cli -- inspect /path/to/thermal-model.xml --json --summary
|
|
30
|
-
cargo run -p simparse-cli -- inspect /path/to/model.mph --json --summary
|
|
31
|
-
cargo run -p simparse-cli -- scan /path/to/history --jsonl
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Use `--summary` for a deterministic, bounded preflight view. It reports total
|
|
35
|
-
counts with capped samples and explicit parser limitations. Omit it when the
|
|
36
|
-
full shallow inventory is needed.
|
|
37
|
-
|
|
38
|
-
FloXML files commonly use the generic `.xml` suffix. `simparse` checks their
|
|
39
|
-
root element, so directory scans include `<xml_case>` and `<sm_xml_case>` files
|
|
40
|
-
while skipping unrelated XML.
|
|
41
|
-
|
|
42
|
-
## Python
|
|
43
|
-
|
|
44
|
-
```powershell
|
|
1
|
+
# simparse
|
|
2
|
+
|
|
3
|
+
`simparse` is a lightweight Rust and Python scanner for simulation project and
|
|
4
|
+
case metadata.
|
|
5
|
+
|
|
6
|
+
## Supported formats
|
|
7
|
+
|
|
8
|
+
| Format | Files |
|
|
9
|
+
|---|---|
|
|
10
|
+
| COMSOL | `.mph` |
|
|
11
|
+
| Abaqus | `.inp`, `.inc` |
|
|
12
|
+
| Fluent | `.cas.h5`, `.msh.h5` |
|
|
13
|
+
| Ansys Electronics Desktop (HFSS / Icepak) | `.aedt`, `.aedtz` |
|
|
14
|
+
| Ansys Mechanical | `.mechdb`, `.mechdat` |
|
|
15
|
+
| Icepak Classic | `.tzr` |
|
|
16
|
+
| Simcenter FloTHERM | `.pack`, `.xml`, `.floxml` |
|
|
17
|
+
|
|
18
|
+
## Design
|
|
19
|
+
|
|
20
|
+
`simparse` is meant to compose with existing simulation tools, not replace them.
|
|
21
|
+
It focuses on lightweight agent workflows: metadata, inventory, quick directory
|
|
22
|
+
scans, and deciding when a heavier vendor or Python tool should be called next.
|
|
23
|
+
See [tool design principles](docs/design-principles.md).
|
|
24
|
+
|
|
25
|
+
## CLI
|
|
26
|
+
|
|
27
|
+
```powershell
|
|
28
|
+
cargo run -p simparse-cli -- inspect /path/to/model.mph --json
|
|
29
|
+
cargo run -p simparse-cli -- inspect /path/to/thermal-model.xml --json --summary
|
|
30
|
+
cargo run -p simparse-cli -- inspect /path/to/model.mph --json --summary
|
|
31
|
+
cargo run -p simparse-cli -- scan /path/to/history --jsonl
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Use `--summary` for a deterministic, bounded preflight view. It reports total
|
|
35
|
+
counts with capped samples and explicit parser limitations. Omit it when the
|
|
36
|
+
full shallow inventory is needed.
|
|
37
|
+
|
|
38
|
+
FloXML files commonly use the generic `.xml` suffix. `simparse` checks their
|
|
39
|
+
root element, so directory scans include `<xml_case>` and `<sm_xml_case>` files
|
|
40
|
+
while skipping unrelated XML.
|
|
41
|
+
|
|
42
|
+
## Python
|
|
43
|
+
|
|
44
|
+
```powershell
|
|
45
45
|
maturin develop
|
|
46
46
|
python -c "import simparse; print(simparse.inspect('/path/to/model.inp', summary=True))"
|
|
47
47
|
python -c "import simparse; print(simparse.scan(['/path/to/history'], summary=True))"
|
|
48
48
|
```
|
|
49
|
-
|
|
50
|
-
## Benchmark
|
|
51
|
-
|
|
52
|
-

|
|
53
|
-
|
|
54
|
-
```powershell
|
|
55
|
-
python benchmarks/compare.py
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
This benchmark models one practical agent path: call one external tool to scan a
|
|
59
|
-
group of public simulation artifacts. The bars include process startup and
|
|
60
|
-
library import cost. The JSON artifact also records an in-process Python
|
|
61
|
-
baseline for context; those numbers are useful for library-level comparison, but
|
|
62
|
-
are not the primary agent tool-call scenario.
|
|
63
|
-
|
|
64
|
-
The benchmark downloads public URLs listed in `benchmarks/public-artifacts.json`
|
|
65
|
-
into `target/` and writes `artifacts/public-benchmark.json` plus
|
|
66
|
-
`artifacts/public-benchmark.svg`. Vendor-native parser timings are not included
|
|
67
|
-
because they require locally licensed software or APIs.
|
|
68
|
-
|
|
69
|
-
## License
|
|
70
|
-
|
|
71
|
-
Apache-2.0
|
|
49
|
+
|
|
50
|
+
## Benchmark
|
|
51
|
+
|
|
52
|
+

|
|
53
|
+
|
|
54
|
+
```powershell
|
|
55
|
+
python benchmarks/compare.py
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This benchmark models one practical agent path: call one external tool to scan a
|
|
59
|
+
group of public simulation artifacts. The bars include process startup and
|
|
60
|
+
library import cost. The JSON artifact also records an in-process Python
|
|
61
|
+
baseline for context; those numbers are useful for library-level comparison, but
|
|
62
|
+
are not the primary agent tool-call scenario.
|
|
63
|
+
|
|
64
|
+
The benchmark downloads public URLs listed in `benchmarks/public-artifacts.json`
|
|
65
|
+
into `target/` and writes `artifacts/public-benchmark.json` plus
|
|
66
|
+
`artifacts/public-benchmark.svg`. Vendor-native parser timings are not included
|
|
67
|
+
because they require locally licensed software or APIs.
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
Apache-2.0
|
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
use std::path::{Path, PathBuf};
|
|
2
|
-
|
|
3
|
-
use walkdir::WalkDir;
|
|
4
|
-
|
|
5
|
-
use crate::parsers::{
|
|
6
|
-
abaqus, comsol, flotherm, hfss, icepak, inspect_fluent_hdf5, inspect_mechanical_mechdb,
|
|
7
|
-
};
|
|
8
|
-
use crate::{
|
|
9
|
-
FormatSummary, InspectOptions, Result, ScanOptions, SimFormat, SimparseError, SimparseResult,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
pub fn detect_format(path: &Path) -> Option<SimFormat> {
|
|
13
|
-
let name = path.file_name()?.to_string_lossy().to_ascii_lowercase();
|
|
14
|
-
if name.ends_with(".mph") {
|
|
15
|
-
Some(SimFormat::ComsolMph)
|
|
16
|
-
} else if name.ends_with(".inp") || name.ends_with(".inc") {
|
|
17
|
-
Some(SimFormat::AbaqusInp)
|
|
18
|
-
} else if name.ends_with(".cas.h5") || name.ends_with(".msh.h5") {
|
|
19
|
-
Some(SimFormat::FluentHdf5)
|
|
20
|
-
} else if name.ends_with(".aedt") || name.ends_with(".aedtz") {
|
|
21
|
-
Some(SimFormat::HfssAedt)
|
|
22
|
-
} else if name.ends_with(".mechdb") || name.ends_with(".mechdat") {
|
|
23
|
-
Some(SimFormat::AnsysMechanical)
|
|
24
|
-
} else if name.ends_with(".tzr") {
|
|
25
|
-
Some(SimFormat::IcepakTzr)
|
|
26
|
-
} else if name.ends_with(".floxml")
|
|
27
|
-
|| (name.ends_with(".xml") && flotherm::has_flotherm_root(path))
|
|
28
|
-
{
|
|
29
|
-
Some(SimFormat::FlothermFloxml)
|
|
30
|
-
} else if name.ends_with(".pack") {
|
|
31
|
-
Some(SimFormat::FlothermPack)
|
|
32
|
-
} else {
|
|
33
|
-
None
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
pub fn inspect_path(path: impl AsRef<Path>, options: InspectOptions) -> Result<SimparseResult> {
|
|
38
|
-
let path = path.as_ref();
|
|
39
|
-
let format = options
|
|
40
|
-
.format
|
|
41
|
-
.or_else(|| detect_format(path))
|
|
42
|
-
.ok_or_else(|| SimparseError::UnsupportedFormat(path.display().to_string()))?;
|
|
43
|
-
|
|
44
|
-
let summary = match format {
|
|
45
|
-
SimFormat::ComsolMph => FormatSummary::ComsolMph(comsol::inspect_comsol_mph(path)?),
|
|
46
|
-
SimFormat::AbaqusInp => FormatSummary::AbaqusInp(abaqus::inspect_abaqus_inp(path)?),
|
|
47
|
-
SimFormat::FluentHdf5 => FormatSummary::FluentHdf5(inspect_fluent_hdf5(path)?),
|
|
48
|
-
SimFormat::HfssAedt => {
|
|
49
|
-
FormatSummary::HfssAedt(hfss::inspect_hfss_aedt(path, options.max_text_bytes)?)
|
|
50
|
-
}
|
|
51
|
-
SimFormat::AnsysMechanical => {
|
|
52
|
-
FormatSummary::AnsysMechanical(inspect_mechanical_mechdb(path, options.max_text_bytes)?)
|
|
53
|
-
}
|
|
54
|
-
SimFormat::IcepakTzr => {
|
|
55
|
-
FormatSummary::IcepakTzr(icepak::inspect_icepak_tzr(path, options.max_text_bytes)?)
|
|
56
|
-
}
|
|
57
|
-
SimFormat::FlothermFloxml => FormatSummary::FlothermFloxml(
|
|
58
|
-
flotherm::inspect_flotherm_floxml(path, options.max_text_bytes)?,
|
|
59
|
-
),
|
|
60
|
-
SimFormat::FlothermPack => FormatSummary::FlothermPack(flotherm::inspect_flotherm_pack(
|
|
61
|
-
path,
|
|
62
|
-
options.max_text_bytes,
|
|
63
|
-
)?),
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
Ok(SimparseResult {
|
|
67
|
-
path: options.include_paths.then(|| path.display().to_string()),
|
|
68
|
-
file_name: path
|
|
69
|
-
.file_name()
|
|
70
|
-
.map(|p| p.to_string_lossy().to_string())
|
|
71
|
-
.unwrap_or_else(|| path.display().to_string()),
|
|
72
|
-
format,
|
|
73
|
-
ok: true,
|
|
74
|
-
warnings: Vec::new(),
|
|
75
|
-
summary,
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
pub fn scan_paths(paths: &[PathBuf], options: ScanOptions) -> Result<Vec<SimparseResult>> {
|
|
80
|
-
let mut out = Vec::new();
|
|
81
|
-
for root in paths {
|
|
82
|
-
if root.is_file() {
|
|
83
|
-
if should_include(root, &options.includes) {
|
|
84
|
-
let mut inspect = options.inspect.clone();
|
|
85
|
-
inspect.include_paths = options.include_paths;
|
|
86
|
-
inspect.format = inspect.format.or_else(|| detect_format(root));
|
|
87
|
-
if inspect.format.is_some() {
|
|
88
|
-
out.push(inspect_path(root, inspect)?);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
let walker = if options.recursive {
|
|
95
|
-
WalkDir::new(root)
|
|
96
|
-
} else {
|
|
97
|
-
WalkDir::new(root).max_depth(1)
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
for entry in walker.into_iter().filter_map(std::result::Result::ok) {
|
|
101
|
-
let path = entry.path();
|
|
102
|
-
if path.is_file() && should_include(path, &options.includes) {
|
|
103
|
-
let mut inspect = options.inspect.clone();
|
|
104
|
-
inspect.include_paths = options.include_paths;
|
|
105
|
-
inspect.format = inspect.format.or_else(|| detect_format(path));
|
|
106
|
-
if inspect.format.is_some() {
|
|
107
|
-
out.push(inspect_path(path, inspect)?);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
Ok(out)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
fn should_include(path: &Path, patterns: &[String]) -> bool {
|
|
116
|
-
let name = match path.file_name() {
|
|
117
|
-
Some(name) => name.to_string_lossy().to_ascii_lowercase(),
|
|
118
|
-
None => return false,
|
|
119
|
-
};
|
|
120
|
-
patterns.iter().any(|pattern| {
|
|
121
|
-
let pattern = pattern.trim().to_ascii_lowercase();
|
|
122
|
-
if pattern == "*" {
|
|
123
|
-
true
|
|
124
|
-
} else if let Some(suffix) = pattern.strip_prefix("*.") {
|
|
125
|
-
name.ends_with(&format!(".{suffix}"))
|
|
126
|
-
} else if let Some(suffix) = pattern.strip_prefix('*') {
|
|
127
|
-
name.ends_with(suffix)
|
|
128
|
-
} else {
|
|
129
|
-
name == pattern
|
|
130
|
-
}
|
|
131
|
-
})
|
|
132
|
-
}
|
|
1
|
+
use std::path::{Path, PathBuf};
|
|
2
|
+
|
|
3
|
+
use walkdir::WalkDir;
|
|
4
|
+
|
|
5
|
+
use crate::parsers::{
|
|
6
|
+
abaqus, comsol, flotherm, hfss, icepak, inspect_fluent_hdf5, inspect_mechanical_mechdb,
|
|
7
|
+
};
|
|
8
|
+
use crate::{
|
|
9
|
+
FormatSummary, InspectOptions, Result, ScanOptions, SimFormat, SimparseError, SimparseResult,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
pub fn detect_format(path: &Path) -> Option<SimFormat> {
|
|
13
|
+
let name = path.file_name()?.to_string_lossy().to_ascii_lowercase();
|
|
14
|
+
if name.ends_with(".mph") {
|
|
15
|
+
Some(SimFormat::ComsolMph)
|
|
16
|
+
} else if name.ends_with(".inp") || name.ends_with(".inc") {
|
|
17
|
+
Some(SimFormat::AbaqusInp)
|
|
18
|
+
} else if name.ends_with(".cas.h5") || name.ends_with(".msh.h5") {
|
|
19
|
+
Some(SimFormat::FluentHdf5)
|
|
20
|
+
} else if name.ends_with(".aedt") || name.ends_with(".aedtz") {
|
|
21
|
+
Some(SimFormat::HfssAedt)
|
|
22
|
+
} else if name.ends_with(".mechdb") || name.ends_with(".mechdat") {
|
|
23
|
+
Some(SimFormat::AnsysMechanical)
|
|
24
|
+
} else if name.ends_with(".tzr") {
|
|
25
|
+
Some(SimFormat::IcepakTzr)
|
|
26
|
+
} else if name.ends_with(".floxml")
|
|
27
|
+
|| (name.ends_with(".xml") && flotherm::has_flotherm_root(path))
|
|
28
|
+
{
|
|
29
|
+
Some(SimFormat::FlothermFloxml)
|
|
30
|
+
} else if name.ends_with(".pack") {
|
|
31
|
+
Some(SimFormat::FlothermPack)
|
|
32
|
+
} else {
|
|
33
|
+
None
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
pub fn inspect_path(path: impl AsRef<Path>, options: InspectOptions) -> Result<SimparseResult> {
|
|
38
|
+
let path = path.as_ref();
|
|
39
|
+
let format = options
|
|
40
|
+
.format
|
|
41
|
+
.or_else(|| detect_format(path))
|
|
42
|
+
.ok_or_else(|| SimparseError::UnsupportedFormat(path.display().to_string()))?;
|
|
43
|
+
|
|
44
|
+
let summary = match format {
|
|
45
|
+
SimFormat::ComsolMph => FormatSummary::ComsolMph(comsol::inspect_comsol_mph(path)?),
|
|
46
|
+
SimFormat::AbaqusInp => FormatSummary::AbaqusInp(abaqus::inspect_abaqus_inp(path)?),
|
|
47
|
+
SimFormat::FluentHdf5 => FormatSummary::FluentHdf5(inspect_fluent_hdf5(path)?),
|
|
48
|
+
SimFormat::HfssAedt => {
|
|
49
|
+
FormatSummary::HfssAedt(hfss::inspect_hfss_aedt(path, options.max_text_bytes)?)
|
|
50
|
+
}
|
|
51
|
+
SimFormat::AnsysMechanical => {
|
|
52
|
+
FormatSummary::AnsysMechanical(inspect_mechanical_mechdb(path, options.max_text_bytes)?)
|
|
53
|
+
}
|
|
54
|
+
SimFormat::IcepakTzr => {
|
|
55
|
+
FormatSummary::IcepakTzr(icepak::inspect_icepak_tzr(path, options.max_text_bytes)?)
|
|
56
|
+
}
|
|
57
|
+
SimFormat::FlothermFloxml => FormatSummary::FlothermFloxml(
|
|
58
|
+
flotherm::inspect_flotherm_floxml(path, options.max_text_bytes)?,
|
|
59
|
+
),
|
|
60
|
+
SimFormat::FlothermPack => FormatSummary::FlothermPack(flotherm::inspect_flotherm_pack(
|
|
61
|
+
path,
|
|
62
|
+
options.max_text_bytes,
|
|
63
|
+
)?),
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
Ok(SimparseResult {
|
|
67
|
+
path: options.include_paths.then(|| path.display().to_string()),
|
|
68
|
+
file_name: path
|
|
69
|
+
.file_name()
|
|
70
|
+
.map(|p| p.to_string_lossy().to_string())
|
|
71
|
+
.unwrap_or_else(|| path.display().to_string()),
|
|
72
|
+
format,
|
|
73
|
+
ok: true,
|
|
74
|
+
warnings: Vec::new(),
|
|
75
|
+
summary,
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
pub fn scan_paths(paths: &[PathBuf], options: ScanOptions) -> Result<Vec<SimparseResult>> {
|
|
80
|
+
let mut out = Vec::new();
|
|
81
|
+
for root in paths {
|
|
82
|
+
if root.is_file() {
|
|
83
|
+
if should_include(root, &options.includes) {
|
|
84
|
+
let mut inspect = options.inspect.clone();
|
|
85
|
+
inspect.include_paths = options.include_paths;
|
|
86
|
+
inspect.format = inspect.format.or_else(|| detect_format(root));
|
|
87
|
+
if inspect.format.is_some() {
|
|
88
|
+
out.push(inspect_path(root, inspect)?);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let walker = if options.recursive {
|
|
95
|
+
WalkDir::new(root)
|
|
96
|
+
} else {
|
|
97
|
+
WalkDir::new(root).max_depth(1)
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
for entry in walker.into_iter().filter_map(std::result::Result::ok) {
|
|
101
|
+
let path = entry.path();
|
|
102
|
+
if path.is_file() && should_include(path, &options.includes) {
|
|
103
|
+
let mut inspect = options.inspect.clone();
|
|
104
|
+
inspect.include_paths = options.include_paths;
|
|
105
|
+
inspect.format = inspect.format.or_else(|| detect_format(path));
|
|
106
|
+
if inspect.format.is_some() {
|
|
107
|
+
out.push(inspect_path(path, inspect)?);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
Ok(out)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
fn should_include(path: &Path, patterns: &[String]) -> bool {
|
|
116
|
+
let name = match path.file_name() {
|
|
117
|
+
Some(name) => name.to_string_lossy().to_ascii_lowercase(),
|
|
118
|
+
None => return false,
|
|
119
|
+
};
|
|
120
|
+
patterns.iter().any(|pattern| {
|
|
121
|
+
let pattern = pattern.trim().to_ascii_lowercase();
|
|
122
|
+
if pattern == "*" {
|
|
123
|
+
true
|
|
124
|
+
} else if let Some(suffix) = pattern.strip_prefix("*.") {
|
|
125
|
+
name.ends_with(&format!(".{suffix}"))
|
|
126
|
+
} else if let Some(suffix) = pattern.strip_prefix('*') {
|
|
127
|
+
name.ends_with(suffix)
|
|
128
|
+
} else {
|
|
129
|
+
name == pattern
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
mod dispatch;
|
|
2
|
-
mod error;
|
|
3
|
-
pub mod parsers;
|
|
4
|
-
mod schema;
|
|
5
|
-
mod summary;
|
|
6
|
-
|
|
7
|
-
pub use dispatch::{detect_format, inspect_path, scan_paths};
|
|
8
|
-
pub use error::{Result, SimparseError};
|
|
9
|
-
pub use parsers::abaqus::inspect_abaqus_inp;
|
|
10
|
-
pub use parsers::comsol::inspect_comsol_mph;
|
|
11
|
-
pub use parsers::flotherm::inspect_flotherm_floxml;
|
|
12
|
-
pub use parsers::flotherm::inspect_flotherm_pack;
|
|
13
|
-
pub use parsers::hfss::inspect_hfss_aedt;
|
|
14
|
-
pub use parsers::icepak::inspect_icepak_tzr;
|
|
15
|
-
pub use parsers::inspect_fluent_hdf5;
|
|
16
|
-
pub use parsers::inspect_mechanical_mechdb;
|
|
17
|
-
pub use schema::*;
|
|
18
|
-
pub use summary::*;
|
|
1
|
+
mod dispatch;
|
|
2
|
+
mod error;
|
|
3
|
+
pub mod parsers;
|
|
4
|
+
mod schema;
|
|
5
|
+
mod summary;
|
|
6
|
+
|
|
7
|
+
pub use dispatch::{detect_format, inspect_path, scan_paths};
|
|
8
|
+
pub use error::{Result, SimparseError};
|
|
9
|
+
pub use parsers::abaqus::inspect_abaqus_inp;
|
|
10
|
+
pub use parsers::comsol::inspect_comsol_mph;
|
|
11
|
+
pub use parsers::flotherm::inspect_flotherm_floxml;
|
|
12
|
+
pub use parsers::flotherm::inspect_flotherm_pack;
|
|
13
|
+
pub use parsers::hfss::inspect_hfss_aedt;
|
|
14
|
+
pub use parsers::icepak::inspect_icepak_tzr;
|
|
15
|
+
pub use parsers::inspect_fluent_hdf5;
|
|
16
|
+
pub use parsers::inspect_mechanical_mechdb;
|
|
17
|
+
pub use schema::*;
|
|
18
|
+
pub use summary::*;
|