Skip to content

Commit 6549514

Browse files
authored
Add support for WST with old method code '2'. (#22)
* Add support for old WST code (2) Add test file old wim format. Update CHANGES.md Update packages Bump version to 0.0.5 * Rename Dynamic Probing type from `type` to `dynamic_probing_type`. Update CHANGES.md Update packages * Move the license to the project.classifiers section.
1 parent 50b01c8 commit 6549514

9 files changed

Lines changed: 121 additions & 85 deletions

File tree

.github/workflows/branch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ jobs:
5151
- name: Run bandit
5252
run: poetry run bandit .
5353
- name: Run safety
54-
run: poetry run safety check -i 70612
54+
run: poetry run safety check
5555
- name: Check for acceptable licenses
5656
run: poetry run pip-licenses --allow-only="MIT License;BSD License;Python Software Foundation License;Apache Software License;Mozilla Public License 2.0 (MPL 2.0);ISC License (ISCL);The Unlicense (Unlicense)"

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# NGI Python SGF Parser Package
22

3+
_2025-03-10_
4+
5+
Version 0.0.5
6+
7+
- Add support for old WST code (2).
8+
- Rename Dynamic Probing (DP) type from `type` to `dynamic_probing_type`.
9+
310
_2025-02-27_
411

512
Version 0.0.4

poetry.lock

Lines changed: 72 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,31 @@ exclude = '''
1313
)/
1414
'''
1515

16-
[tool.poetry]
16+
[project]
1717
name = "sgf-parser"
18-
version = "0.0.4"
18+
version = "0.0.5"
1919
description = "Parser for the Swedish Geotechnical Society / Svenska Geotekniska Föreningen (SGF) data format"
20-
license = "MIT"
21-
authors = ["Jostein Leira <jostein@leira.net>"]
22-
maintainers = ["Jostein Leira <jostein@leira.net>"]
20+
authors = [
21+
{ name = "Jostein Leira", email = "jostein@leira.net" }
22+
]
23+
maintainers = [
24+
{ name = "Jostein Leira", email = "jostein@leira.net" }
25+
]
2326
readme = "README.md"
2427
homepage = "https://github.com/norwegian-geotechnical-institute/sgf-parser"
2528
repository = "https://github.com/norwegian-geotechnical-institute/sgf-parser"
2629
classifiers = [
2730
"Development Status :: 5 - Production/Stable",
28-
# "Development Status :: 4 - Beta",
29-
# "Development Status :: 3 - Alpha",
3031
"Operating System :: OS Independent",
3132
"Programming Language :: Python :: 3",
3233
"Topic :: Scientific/Engineering :: GIS",
34+
"License :: OSI Approved :: MIT License",
35+
]
36+
requires-python = ">=3.11,<4"
37+
dependencies=[
38+
"pydantic>=2.10",
39+
"python-dateutil>=2.9.0.post0",
40+
"types-python-dateutil>=2.9"
3341
]
3442
packages = [
3543
{ include = "sgf_parser", from="src" },
@@ -56,11 +64,6 @@ check_untyped_defs = true
5664
no_implicit_reexport = false
5765

5866

59-
[tool.poetry.dependencies]
60-
python = ">=3.11,<4"
61-
pydantic = "^2.10"
62-
python-dateutil = "^2.9.0.post0"
63-
types-python-dateutil = "^2.9"
6467

6568

6669
[tool.poetry.group.dev.dependencies]

src/sgf_parser/models/method_dp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, **kwargs):
5151
method_type: Literal[MethodType.DP] = MethodType.DP
5252
method_data_type: type[MethodDPData] = MethodDPData
5353

54-
type: DPType
54+
dynamic_probing_type: DPType
5555

5656
predrilling_depth: Decimal = Field(Decimal("0"), alias="HO")
5757

@@ -68,7 +68,7 @@ def __init__(self, **kwargs):
6868
def set_operation(cls, data: Any) -> Any:
6969
if isinstance(data, dict):
7070
if "HM" in data and data["HM"] is not None:
71-
data["type"] = {
71+
data["dynamic_probing_type"] = {
7272
"8": DPType.DPSHA,
7373
"108A": DPType.DPSHA,
7474
"108B": DPType.DPL,

src/sgf_parser/models/method_wst.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from decimal import Decimal
22
from typing import Literal, Any
33

4-
from pydantic import Field, model_validator
4+
from pydantic import Field, model_validator, AliasChoices
55

66
from sgf_parser.models import MethodData, Method, MethodType
77
from sgf_parser.models.types import Operation
@@ -17,7 +17,7 @@ def __init__(self, **kwargs):
1717

1818
depth: Decimal = Field(..., alias="D", description="Depth (m)")
1919
turning: Decimal = Field(..., alias="H", description="Turning (half revolution/0.2 m)")
20-
load: Decimal = Field(..., alias="W", description="Load (kN)")
20+
load: Decimal | None = Field(None, description="Load (kN)", validation_alias=AliasChoices("W", "A"))
2121
penetration_rate: Decimal | None = Field(None, alias="B", description="Penetration rate (mm/s)")
2222

2323
hammering: bool | None = Field(None, alias="AP")
@@ -47,6 +47,7 @@ def set_operation(cls, data: Any) -> Any:
4747
if "HM" in data and data["HM"] is not None:
4848
data["operation"] = {
4949
"101": Operation.MANUAL,
50+
"2": Operation.MECHANICAL,
5051
"102": Operation.MECHANICAL,
5152
}[data["HM"]]
5253

src/sgf_parser/parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Parser:
2020
"""
2121

2222
method_code_class_mapping = {
23+
"2": models.MethodWST,
2324
"07": models.MethodCPT,
2425
"10": models.MethodSLB,
2526
"101": models.MethodWST,

tests/data/wst-test-2.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
$
2+
HA=1,HC=826617,HB=1287,HD=20181120,HI=105021,HO=3.6,HM=2,IS=XPL110324,IK=1.0,HK=1234,HQ=Jost
3+
#
4+
D=3.625,A=1.020,H=152,B=154.208,C=1.30
5+
D=3.650,A=1.875,H=80,B=3.979,C=50.27
6+
D=3.675,A=1.020,H=24,B=3.656,C=54.70
7+
D=3.700,A=1.020,H=24,B=10.287,C=19.44
8+
D=3.725,A=2.999,H=64,B=4.715,C=42.42
9+
D=3.750,A=8.259,H=144,B=1.033,C=193.61
10+
D=3.775,A=5.681,H=24,B=1.506,C=132.82,K=91,T=Sond kan ej drivas normalt

tests/integration/test_parse.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,16 @@ def test_return_one_method_one_placeholder(
504504
Decimal("0.350"): {"penetration_rate": Decimal("2.2"), "hammering": False, "rotation_rate": Decimal("0"), "load": Decimal("-0.796"), "turning": Decimal("0")},
505505
Decimal("0.375"): {"penetration_rate": Decimal("0.2"), "hammering": False, "rotation_rate": Decimal("0"), "load": Decimal("1.02"), "turning": Decimal("1112")},
506506
},
507+
),
508+
(
509+
"tests/data/wst-test-2.vim", 7, Decimal("3.625"), Decimal("3.775"),
510+
datetime(2018, 11, 20, 10, 50,21),
511+
{
512+
# load=A, hammering=AP, load=W, turning=H, rotation_rate=R
513+
Decimal("3.625"): {"load":Decimal("1.020"), "turning":Decimal("152"), "penetration_rate": Decimal("154.208"), "comment_code": None, "remarks": None, "hammering": None},
514+
Decimal("3.700"): {"load": Decimal("1.020"), "turning": Decimal("24"), "penetration_rate": Decimal("10.287"), "hammering": None,},
515+
Decimal("3.775"): {"load": Decimal("5.681"), "turning": Decimal("24"), "penetration_rate": Decimal("1.506"), "hammering": None, "comment_code": 91, "remarks": "Sond kan ej drivas normalt"},
516+
},
507517
),
508518
),
509519
)

0 commit comments

Comments
 (0)