Skip to content

Commit ee690ef

Browse files
committed
Run black.
Update parser.py to pass mypy pipeline step.
1 parent 733a945 commit ee690ef

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

src/kof_parser/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from enum import Enum
2-
from typing import Optional, List
2+
from typing import Optional
33

44
from pydantic import BaseModel, Field
55

66

77
class Location(BaseModel):
88
name: str = ""
9-
methods: Optional[List[str]] = []
9+
methods: list[str] = []
1010
point_easting: Optional[float]
1111
point_northing: Optional[float]
1212
point_z: Optional[float] = Field(None, ge=-10000, le=10000)

src/kof_parser/parser.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,24 @@ def __init__(self):
7070
self.file_srid: Optional[int] = None
7171

7272
def tema_code_to_method(self, code: str) -> Optional[str]:
73-
7473
if not code or code not in self.tema_codes_mapping.keys():
7574
return None
7675

7776
return self.tema_codes_mapping[code].name
7877

7978
def map_line_to_coordinate_block(self, line: str, result_srid: int, file_srid: Optional[int]) -> Location:
80-
resolved_location = Location()
8179
template_coordinate_block: str = "-05 PPPPPPPPPP KKKKKKKK XXXXXXXX.XXX YYYYYYY.YYY ZZZZ.ZZZ Bk MMMMMMM"
8280
parsed_line = line[0 : len(template_coordinate_block)]
8381

84-
resolved_location.name = parsed_line[4:15].strip()
85-
resolved_location.srid = result_srid
86-
resolved_location.point_easting = float(parsed_line[24:37].strip())
87-
resolved_location.point_northing = float(parsed_line[37:49].strip())
88-
resolved_location.point_z = float(parsed_line[49:58].strip()) if parsed_line[49:58].strip() else None
89-
new_method = self.tema_code_to_method(parsed_line[15:24].strip())
90-
if resolved_location.methods is not None:
91-
resolved_location.methods += [new_method] if new_method is not None else []
82+
resolved_location = Location(
83+
name=parsed_line[4:15].strip(),
84+
srid=result_srid,
85+
point_easting=float(parsed_line[24:37].strip()),
86+
point_northing=float(parsed_line[37:49].strip()),
87+
point_z=float(parsed_line[49:58].strip()) if parsed_line[49:58].strip() else None,
88+
)
89+
if new_method := self.tema_code_to_method(parsed_line[15:24].strip()):
90+
resolved_location.methods.append(new_method)
9291

9392
return resolved_location
9493

src/kof_parser/writer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010

1111
class KOFWriter(Kof):
12-
1312
method_type_to_temakode = {
1413
MethodType.RO.name: "2251",
1514
MethodType.RWS.name: "2401",

tests/test_write.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
class TestWrite:
1010
def test_write(self):
11-
1211
# ETRS89/NTM10:
1312
srid = 5110
1413
locations = KOFParser().parse("tests/data/test.kof", srid)

0 commit comments

Comments
 (0)