Skip to content

Commit 4c22208

Browse files
[READY] apuse.csv add map coordinate checks (#1068)
2 parents 4663078 + c3275ac commit 4c22208

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

facts/datasource.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,23 @@ def isvalidtype(val):
225225
return False
226226

227227

228+
def is_valid_map_coordinate(val: int | float | str) -> bool:
229+
"""
230+
test for valid map coordinate:
231+
must be 0-100 and limited to 2 decimal places.
232+
"""
233+
if isinstance(val, str):
234+
try:
235+
val = float(val)
236+
except ValueError:
237+
return False
238+
239+
if not isinstance(val, (int, float)):
240+
return False
241+
242+
return 0 <= val <= 100 and round(val, 2) == val
243+
244+
228245
# =============================================================================
229246
# Line Preprocessing (matches Perl read_config_file behavior)
230247
# =============================================================================

facts/test_datasources.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def test_apuse_csv():
2121
ds.isvalidwifi5chan,
2222
ds.isint,
2323
ds.isintorempty,
24-
ds.isintorempty,
25-
ds.isintorempty,
24+
ds.is_valid_map_coordinate,
25+
ds.is_valid_map_coordinate,
2626
],
2727
}
2828
result, err = ds.test_csvfile(meta)

0 commit comments

Comments
 (0)