python-osw-validation 0.3.3__py3-none-any.whl → 0.3.5__py3-none-any.whl
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.
- python_osw_validation/__init__.py +12 -12
- python_osw_validation/extracted_data_validator.py +17 -3
- python_osw_validation/schema/opensidewalks.lines.schema-0.3.json +2 -6
- python_osw_validation/schema/opensidewalks.points.schema-0.3.json +2 -8
- python_osw_validation/schema/opensidewalks.polygons.schema-0.3.json +2 -6
- python_osw_validation/schema/opensidewalks.schema-0.3.json +6509 -6134
- python_osw_validation/version.py +1 -1
- python_osw_validation-0.3.5.dist-info/METADATA +165 -0
- {python_osw_validation-0.3.3.dist-info → python_osw_validation-0.3.5.dist-info}/RECORD +12 -12
- python_osw_validation-0.3.3.dist-info/METADATA +0 -161
- {python_osw_validation-0.3.3.dist-info → python_osw_validation-0.3.5.dist-info}/WHEEL +0 -0
- {python_osw_validation-0.3.3.dist-info → python_osw_validation-0.3.5.dist-info}/licenses/LICENSE +0 -0
- {python_osw_validation-0.3.3.dist-info → python_osw_validation-0.3.5.dist-info}/top_level.txt +0 -0
|
@@ -112,21 +112,21 @@ class OSWValidation:
|
|
|
112
112
|
return set()
|
|
113
113
|
|
|
114
114
|
def _schema_key_from_text(self, text: Optional[str]) -> Optional[str]:
|
|
115
|
-
"""Return dataset key
|
|
115
|
+
"""Return dataset key from exact filename suffixes only."""
|
|
116
116
|
if not text:
|
|
117
117
|
return None
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if any(alias in lower for alias in variants):
|
|
118
|
+
|
|
119
|
+
basename = os.path.basename(text).lower()
|
|
120
|
+
stem, _ = os.path.splitext(basename)
|
|
121
|
+
for key in self.dataset_schema_paths:
|
|
122
|
+
if (
|
|
123
|
+
stem == key
|
|
124
|
+
or stem == f"{key}.osw"
|
|
125
|
+
or stem.endswith(f".{key}")
|
|
126
|
+
or stem.endswith(f".{key}.osw")
|
|
127
|
+
):
|
|
129
128
|
return key
|
|
129
|
+
|
|
130
130
|
return None
|
|
131
131
|
|
|
132
132
|
def _contains_disallowed_features_for_02(self, geojson_data: Dict[str, Any]) -> set:
|
|
@@ -48,6 +48,20 @@ _FILENAME_TO_KEY = {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
|
|
51
|
+
def _matches_dataset_filename(basename: str, dataset_key: str) -> bool:
|
|
52
|
+
lower_name = basename.lower()
|
|
53
|
+
if not lower_name.endswith(".geojson"):
|
|
54
|
+
return False
|
|
55
|
+
|
|
56
|
+
stem = lower_name[:-len(".geojson")]
|
|
57
|
+
return (
|
|
58
|
+
stem == dataset_key
|
|
59
|
+
or stem == f"{dataset_key}.osw"
|
|
60
|
+
or stem.endswith(f".{dataset_key}")
|
|
61
|
+
or stem.endswith(f".{dataset_key}.osw")
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
51
65
|
class ExtractedDataValidator:
|
|
52
66
|
def __init__(self, extracted_dir: str):
|
|
53
67
|
self.extracted_dir = extracted_dir
|
|
@@ -100,7 +114,7 @@ class ExtractedDataValidator:
|
|
|
100
114
|
|
|
101
115
|
allowed_keys = tuple(OSW_DATASET_FILES.keys())
|
|
102
116
|
unsupported_files = sorted(
|
|
103
|
-
{bn for bn in basenames if not any(key
|
|
117
|
+
{bn for bn in basenames if not any(_matches_dataset_filename(bn, key) for key in allowed_keys)}
|
|
104
118
|
)
|
|
105
119
|
if unsupported_files:
|
|
106
120
|
allowed_fmt = ", ".join(allowed_keys)
|
|
@@ -121,7 +135,7 @@ class ExtractedDataValidator:
|
|
|
121
135
|
file_count = 0
|
|
122
136
|
for filename in geojson_files:
|
|
123
137
|
base_name = os.path.basename(filename)
|
|
124
|
-
if
|
|
138
|
+
if _matches_dataset_filename(base_name, required_file):
|
|
125
139
|
file_count += 1
|
|
126
140
|
save_filename = filename
|
|
127
141
|
if file_count == 0:
|
|
@@ -138,7 +152,7 @@ class ExtractedDataValidator:
|
|
|
138
152
|
file_count = 0
|
|
139
153
|
for filename in geojson_files:
|
|
140
154
|
base_name = os.path.basename(filename)
|
|
141
|
-
if
|
|
155
|
+
if _matches_dataset_filename(base_name, optional_file):
|
|
142
156
|
file_count += 1
|
|
143
157
|
save_filename = filename
|
|
144
158
|
if file_count == 1:
|
|
@@ -185,9 +185,7 @@
|
|
|
185
185
|
"enum": [
|
|
186
186
|
"deciduous",
|
|
187
187
|
"evergreen",
|
|
188
|
-
"mixed"
|
|
189
|
-
"semi_deciduous",
|
|
190
|
-
"semi_evergreen"
|
|
188
|
+
"mixed"
|
|
191
189
|
],
|
|
192
190
|
"type": "string"
|
|
193
191
|
},
|
|
@@ -282,9 +280,7 @@
|
|
|
282
280
|
"enum": [
|
|
283
281
|
"deciduous",
|
|
284
282
|
"evergreen",
|
|
285
|
-
"mixed"
|
|
286
|
-
"semi_deciduous",
|
|
287
|
-
"semi_evergreen"
|
|
283
|
+
"mixed"
|
|
288
284
|
],
|
|
289
285
|
"type": "string"
|
|
290
286
|
},
|
|
@@ -204,10 +204,7 @@
|
|
|
204
204
|
"description": "A field that describes the phenology of leaves, for instance evergreen or deciduous.",
|
|
205
205
|
"enum": [
|
|
206
206
|
"deciduous",
|
|
207
|
-
"evergreen"
|
|
208
|
-
"mixed",
|
|
209
|
-
"semi_deciduous",
|
|
210
|
-
"semi_evergreen"
|
|
207
|
+
"evergreen"
|
|
211
208
|
],
|
|
212
209
|
"type": "string"
|
|
213
210
|
},
|
|
@@ -409,10 +406,7 @@
|
|
|
409
406
|
"description": "A field that describes the phenology of leaves, for instance evergreen or deciduous.",
|
|
410
407
|
"enum": [
|
|
411
408
|
"deciduous",
|
|
412
|
-
"evergreen"
|
|
413
|
-
"mixed",
|
|
414
|
-
"semi_deciduous",
|
|
415
|
-
"semi_evergreen"
|
|
409
|
+
"evergreen"
|
|
416
410
|
],
|
|
417
411
|
"type": "string"
|
|
418
412
|
},
|
|
@@ -289,9 +289,7 @@
|
|
|
289
289
|
"enum": [
|
|
290
290
|
"deciduous",
|
|
291
291
|
"evergreen",
|
|
292
|
-
"mixed"
|
|
293
|
-
"semi_deciduous",
|
|
294
|
-
"semi_evergreen"
|
|
292
|
+
"mixed"
|
|
295
293
|
],
|
|
296
294
|
"type": "string"
|
|
297
295
|
},
|
|
@@ -481,9 +479,7 @@
|
|
|
481
479
|
"enum": [
|
|
482
480
|
"deciduous",
|
|
483
481
|
"evergreen",
|
|
484
|
-
"mixed"
|
|
485
|
-
"semi_deciduous",
|
|
486
|
-
"semi_evergreen"
|
|
482
|
+
"mixed"
|
|
487
483
|
],
|
|
488
484
|
"type": "string"
|
|
489
485
|
},
|