sgf-parser 0.0.1__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Norwegian Geotechnical Institute (NGI)
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.
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.1
2
+ Name: sgf-parser
3
+ Version: 0.0.1
4
+ Summary: Parser for the Swedish Geotechnical Society / Svenska Geotekniska Föreningen (SGF) data format
5
+ Home-page: https://github.com/norwegian-geotechnical-institute/sgf-parser
6
+ License: MIT
7
+ Author: Jostein Leira
8
+ Author-email: jostein@leira.net
9
+ Maintainer: Jostein Leira
10
+ Maintainer-email: jostein@leira.net
11
+ Requires-Python: >=3.11,<4
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: GIS
19
+ Requires-Dist: pydantic (>=2.8.2,<3.0.0)
20
+ Requires-Dist: python-dateutil (>=2.9.0.post0,<3.0.0)
21
+ Requires-Dist: types-python-dateutil (>=2.9,<3.0)
22
+ Project-URL: Repository, https://github.com/norwegian-geotechnical-institute/sgf-parser
23
+ Description-Content-Type: text/markdown
24
+
25
+ # sgf-parser
26
+
27
+ Parser for data from geotechnical field investigations in the data format
28
+ specified in Report 3:2012E from the Swedish Geotechnical Society /
29
+ [Svenska Geotekniska Föreningen](http://sgf.net/) (SGF).
30
+
31
+ This package is inspired by the [libsgfdata](https://github.com/emerald-geomodelling/libsgfdata)
32
+ package by [EMerald Geomodelling](https://www.emerald-geomodelling.com/).
33
+
34
+ Latest releases see [CHANGES.md](CHANGES.md)
35
+
36
+ # Installation (end user)
37
+
38
+ ```bash
39
+ pip install sgf-parser
40
+ ```
41
+
42
+ ## Basic usage
43
+
44
+ ```python
45
+ from sgf_parser import Parser
46
+
47
+ with open("tests/data/cpt-test-3.cpt", "rt") as file:
48
+ # The test file only contains one method
49
+ [method] = Parser().parse(file)
50
+
51
+ print(repr(method))
52
+ # <MethodCPT CPT method_data=[<MethodCPTData 1.000>, <MethodCPTData 1.020>, <MethodCPTData 1.040>,
53
+ # <MethodCPTData 1.060>, <MethodCPTData 1.080>, <MethodCPTData 1.100>, <MethodCPTData 1.120>, ...,
54
+ # <MethodCPTData 24.940>, <MethodCPTData 24.960>, <MethodCPTData 24.980>]>
55
+
56
+
57
+ method.model_dump(exclude={'method_data'}, exclude_defaults=True)
58
+ # {'location_name': 'Test', 'project_number': '1234', 'method_type_string': '107A',
59
+ # 'conducted_at': datetime.datetime(2019, 9, 5, 11, 5), 'predrilling_depth': Decimal('1.00'),
60
+ # 'cone_reference': '5349', 'cone_area_ratio': Decimal('0.844'), 'sleeve_area_ratio': Decimal('0'),
61
+ # 'application_class_depth': <ApplicationClass.ONE: 1>, 'application_class_resistance': <ApplicationClass.ONE: 1>,
62
+ # 'application_class_friction': <ApplicationClass.ONE: 1>, 'application_class_pressure': <ApplicationClass.ONE: 1>,
63
+ # 'depth_top': Decimal('1.000'), 'depth_base': Decimal('24.980'), 'stopcode': 90}
64
+
65
+ method.stopcode
66
+ # 90
67
+
68
+ len(method.method_data)
69
+ # 1200
70
+
71
+ ```
72
+
73
+ # Getting Started developing
74
+
75
+ 1. Software dependencies
76
+
77
+ - Python 3.11 or higher
78
+ - Poetry
79
+ - ruff code formatter
80
+
81
+ 2. Clone this repository
82
+
83
+ 3. Install
84
+
85
+ `poetry install`
86
+
87
+
88
+ # Build and Test
89
+
90
+ Run in the project root folder:
91
+
92
+ poetry shell pytest
93
+
94
+ Build the package wheel:
95
+
96
+ poetry build
97
+
98
+ # Publish
99
+
100
+ # TODOs
101
+
102
+ - [ ] Implement everything
103
+ - [ ] Do the rest
104
+
105
+
106
+ # Contribute
107
+
108
+ Please start by adding an issue before submitting any pull requests.
109
+
110
+
@@ -0,0 +1,85 @@
1
+ # sgf-parser
2
+
3
+ Parser for data from geotechnical field investigations in the data format
4
+ specified in Report 3:2012E from the Swedish Geotechnical Society /
5
+ [Svenska Geotekniska Föreningen](http://sgf.net/) (SGF).
6
+
7
+ This package is inspired by the [libsgfdata](https://github.com/emerald-geomodelling/libsgfdata)
8
+ package by [EMerald Geomodelling](https://www.emerald-geomodelling.com/).
9
+
10
+ Latest releases see [CHANGES.md](CHANGES.md)
11
+
12
+ # Installation (end user)
13
+
14
+ ```bash
15
+ pip install sgf-parser
16
+ ```
17
+
18
+ ## Basic usage
19
+
20
+ ```python
21
+ from sgf_parser import Parser
22
+
23
+ with open("tests/data/cpt-test-3.cpt", "rt") as file:
24
+ # The test file only contains one method
25
+ [method] = Parser().parse(file)
26
+
27
+ print(repr(method))
28
+ # <MethodCPT CPT method_data=[<MethodCPTData 1.000>, <MethodCPTData 1.020>, <MethodCPTData 1.040>,
29
+ # <MethodCPTData 1.060>, <MethodCPTData 1.080>, <MethodCPTData 1.100>, <MethodCPTData 1.120>, ...,
30
+ # <MethodCPTData 24.940>, <MethodCPTData 24.960>, <MethodCPTData 24.980>]>
31
+
32
+
33
+ method.model_dump(exclude={'method_data'}, exclude_defaults=True)
34
+ # {'location_name': 'Test', 'project_number': '1234', 'method_type_string': '107A',
35
+ # 'conducted_at': datetime.datetime(2019, 9, 5, 11, 5), 'predrilling_depth': Decimal('1.00'),
36
+ # 'cone_reference': '5349', 'cone_area_ratio': Decimal('0.844'), 'sleeve_area_ratio': Decimal('0'),
37
+ # 'application_class_depth': <ApplicationClass.ONE: 1>, 'application_class_resistance': <ApplicationClass.ONE: 1>,
38
+ # 'application_class_friction': <ApplicationClass.ONE: 1>, 'application_class_pressure': <ApplicationClass.ONE: 1>,
39
+ # 'depth_top': Decimal('1.000'), 'depth_base': Decimal('24.980'), 'stopcode': 90}
40
+
41
+ method.stopcode
42
+ # 90
43
+
44
+ len(method.method_data)
45
+ # 1200
46
+
47
+ ```
48
+
49
+ # Getting Started developing
50
+
51
+ 1. Software dependencies
52
+
53
+ - Python 3.11 or higher
54
+ - Poetry
55
+ - ruff code formatter
56
+
57
+ 2. Clone this repository
58
+
59
+ 3. Install
60
+
61
+ `poetry install`
62
+
63
+
64
+ # Build and Test
65
+
66
+ Run in the project root folder:
67
+
68
+ poetry shell pytest
69
+
70
+ Build the package wheel:
71
+
72
+ poetry build
73
+
74
+ # Publish
75
+
76
+ # TODOs
77
+
78
+ - [ ] Implement everything
79
+ - [ ] Do the rest
80
+
81
+
82
+ # Contribute
83
+
84
+ Please start by adding an issue before submitting any pull requests.
85
+
@@ -0,0 +1,79 @@
1
+ [tool.black]
2
+ line-length = 120
3
+ exclude = '''
4
+ /(
5
+ \.git
6
+ | venv
7
+ | \.venv
8
+ | env
9
+ | \.env
10
+ | _build
11
+ | build
12
+ | dist
13
+ )/
14
+ '''
15
+
16
+ [tool.poetry]
17
+ name = "sgf-parser"
18
+ version = "0.0.1"
19
+ 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>"]
23
+ readme = "README.md"
24
+ homepage = "https://github.com/norwegian-geotechnical-institute/sgf-parser"
25
+ repository = "https://github.com/norwegian-geotechnical-institute/sgf-parser"
26
+ classifiers = [
27
+ # "Development Status :: 5 - Production/Stable",
28
+ # "Development Status :: 4 - Beta",
29
+ "Development Status :: 3 - Alpha",
30
+ "Operating System :: OS Independent",
31
+ "Programming Language :: Python :: 3",
32
+ "Topic :: Scientific/Engineering :: GIS",
33
+ ]
34
+ packages = [
35
+ { include = "sgf_parser", from="src" },
36
+ ]
37
+
38
+
39
+ [tool.ruff]
40
+ line-length = 120
41
+ src = ["src", "tests"]
42
+
43
+ [tool.ruff.lint.per-file-ignores]
44
+ "__init__.py" = ["F401"]
45
+
46
+ [tool.mypy]
47
+ plugins = [
48
+ "pydantic.mypy"
49
+ ]
50
+
51
+ follow_imports = "skip"
52
+ warn_redundant_casts = true
53
+ warn_unused_ignores = true
54
+ disallow_any_generics = true
55
+ check_untyped_defs = true
56
+ no_implicit_reexport = false
57
+
58
+
59
+ [tool.poetry.dependencies]
60
+ python = ">=3.11,<4"
61
+ pydantic = "^2.8.2"
62
+ python-dateutil = "^2.9.0.post0"
63
+ types-python-dateutil = "^2.9"
64
+
65
+
66
+ [tool.poetry.group.dev.dependencies]
67
+ pytest = "*"
68
+ pytest-cov = "*"
69
+ mypy = "*"
70
+ bandit = "*"
71
+ safety = "*"
72
+ pip-licenses = "*"
73
+ ruff = "*"
74
+ # Pinned due to problem with unpinned ruamel-yaml subdependency ruamel-yaml-clib not able to install on windows
75
+ ruamel-yaml-clib={platform = "win32", version = "<0.2.6"}
76
+
77
+ [build-system]
78
+ requires = ["poetry-core>=1.0.0"]
79
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1 @@
1
+ from sgf_parser.parser import Parser
@@ -0,0 +1,44 @@
1
+ """
2
+ Datetime utilities for converting to and from datetime.datetime, json, naive and time zone aware
3
+ """
4
+
5
+ from datetime import datetime, time
6
+
7
+ import dateutil.parser
8
+
9
+
10
+ def convert_str_to_datetime(date_string: str | None) -> datetime | None:
11
+ """
12
+ Guess what datetime is in the string
13
+ """
14
+ if not date_string or not isinstance(date_string, str):
15
+ return None
16
+
17
+ try:
18
+ # The ISO 8601 format specifies that the time portion is separated from the date portion by a `T` character.
19
+ if len(date_string) > 8 and "T" in date_string or len(date_string) == 8:
20
+ return dateutil.parser.isoparse(date_string)
21
+ except ValueError:
22
+ pass
23
+
24
+ try:
25
+ return dateutil.parser.parse(date_string, parserinfo=dateutil.parser.parserinfo(yearfirst=True, dayfirst=True))
26
+ except ValueError:
27
+ pass
28
+
29
+ return None
30
+
31
+
32
+ def convert_str_to_time(time_string: str | None) -> time | None:
33
+ """
34
+ Guess what time is in the string
35
+ """
36
+ if not time_string:
37
+ return None
38
+
39
+ try:
40
+ return dateutil.parser.parse(f"1970-01-01 {time_string}").time()
41
+ except ValueError:
42
+ pass
43
+
44
+ return None
@@ -0,0 +1,12 @@
1
+ from sgf_parser.models.method_type import MethodType
2
+
3
+ from sgf_parser.models.types import StopCode, ParseState
4
+ from sgf_parser.models.method import Method, MethodData
5
+ from sgf_parser.models.method_cpt import MethodCPT, MethodCPTData
6
+ from sgf_parser.models.method_dp import MethodDP, MethodDPData
7
+ from sgf_parser.models.method_dt import MethodDT, MethodDTData
8
+ from sgf_parser.models.method_rp import MethodRP, MethodRPData
9
+ from sgf_parser.models.method_srs import MethodSRS, MethodSRSData
10
+ from sgf_parser.models.method_svt import MethodSVT, MethodSVTData
11
+ from sgf_parser.models.method_tot import MethodTOT, MethodTOTData
12
+ from sgf_parser.models.method_wst import MethodWST, MethodWSTData