python-osw-validation 0.0.3__py3-none-any.whl → 0.0.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.
@@ -9,26 +9,39 @@ class ExtractedDataValidator:
9
9
  self.error = None
10
10
 
11
11
  def is_valid(self) -> bool:
12
- if not os.path.exists(self.extracted_dir) or not os.listdir(self.extracted_dir):
13
- self.error = 'Folder is empty or does not exist.'
12
+ # Check if the directory exists
13
+ if not os.path.exists(self.extracted_dir):
14
+ self.error = 'Directory does not exist.'
14
15
  return False
15
16
 
17
+ # Look for required files at the root level
16
18
  geojson_files = glob.glob(os.path.join(self.extracted_dir, '*.geojson'))
17
- if len(geojson_files) < 3:
18
- self.error = 'There are not enough .geojson files in the folder.'
19
+
20
+ # If not found at the root, check inside folders
21
+ if not geojson_files:
22
+ geojson_files = glob.glob(os.path.join(self.extracted_dir, '*', '*.geojson'))
23
+
24
+ if not geojson_files:
25
+ self.error = 'No .geojson files found in the specified directory or its subdirectories.'
19
26
  return False
20
27
 
28
+ required_files = {'nodes', 'edges'}
29
+ optional_files = {'points'}
21
30
  for filename in geojson_files:
22
31
  base_name = os.path.basename(filename)
23
- if 'edges' in base_name and base_name.endswith('.geojson'):
24
- self.files.append(filename)
25
- elif 'nodes' in base_name and base_name.endswith('.geojson'):
26
- self.files.append(filename)
27
- elif 'points' in base_name and base_name.endswith('.geojson'):
28
- self.files.append(filename)
29
-
30
- if len(self.files) != 3:
31
- self.error = 'Missing one or more required .geojson files.'
32
+ for required_file in required_files:
33
+ if required_file in base_name and base_name.endswith('.geojson'):
34
+ self.files.append(filename)
35
+ required_files.remove(required_file)
36
+ break
37
+ for optional_file in optional_files:
38
+ if optional_file in base_name and base_name.endswith('.geojson'):
39
+ self.files.append(filename)
40
+ optional_files.remove(optional_file)
41
+ break
42
+
43
+ if required_files:
44
+ self.error = f'Missing required .geojson files: {", ".join(required_files)}.'
32
45
  return False
33
46
 
34
47
  return True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-osw-validation
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: Python library for OSW validation
5
5
  Home-page: https://github.com/TaskarCenterAtUW/TDEI-python-lib-osw-validation
6
6
  Author: Sujata Misra
@@ -31,8 +31,8 @@ This package validates the OSW geojson file. Package requires a OSW zip file pat
31
31
  ## What this package does?
32
32
 
33
33
  - It unzip the provided zip files
34
- - Check for nodes, edges and points geojson files inside the unzipped folder
35
- - Validate each file against schema, schema can be found here
34
+ - Check for the required nodes and edges geojson files inside the unzipped folder
35
+ - Validate each file (nodes, edges and points) against schema, schema can be found here
36
36
  - Return true or false according to validation
37
37
  - you can check the error if it returned false.
38
38
 
@@ -93,6 +93,9 @@ test_invalid_geometry_zipfile (test_osw_validation.TestOSWValidation) ... ok
93
93
  test_invalid_zipfile (test_osw_validation.TestOSWValidation) ... ok
94
94
  test_invalid_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
95
95
  test_invalid_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
96
+ test_minimal_zipfile (test_osw_validation.TestOSWValidation) ... ok
97
+ test_minimal_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
98
+ test_minimal_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
96
99
  test_missing_files_inside_zipfile (test_osw_validation.TestOSWValidation) ... ok
97
100
  test_missing_files_inside_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
98
101
  test_missing_files_inside_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
@@ -113,7 +116,7 @@ test_extract_valid_zip (test_zipfile_handler.TestZipFileHandler) ... ok
113
116
  test_remove_extracted_files (test_zipfile_handler.TestZipFileHandler) ... ok
114
117
 
115
118
  ----------------------------------------------------------------------
116
- Ran 31 tests in 193.358s
119
+ Ran 34 tests in 121.220s
117
120
 
118
121
  OK
119
122
  ```
@@ -0,0 +1,9 @@
1
+ python_osw_validation/__init__.py,sha256=wbfrPcBdOZsBOgwTYq2QByJ5RzXqVMGqZ62H85CNXkY,3046
2
+ python_osw_validation/extracted_data_validator.py,sha256=Quqf_db3h3s20R2eC6ExIDdKvJLl7q3Kj6h_yLvt7lQ,1721
3
+ python_osw_validation/zipfile_handler.py,sha256=fv3GwxUIrtsB8qlMCYjz7GsMBvo7Mf8n7g5WZqcPaoY,1123
4
+ python_osw_validation/schema/opensidewalks.schema.json,sha256=qd-AJBfcMNA3Qr1EoL9u1fR662Qd9Qu3oNNkahzGNpE,103828
5
+ python_osw_validation-0.0.5.dist-info/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
6
+ python_osw_validation-0.0.5.dist-info/METADATA,sha256=eBlqlo1OgLwO1HjnOmRtyvHgtRk_JQ2rwuqiCEeAtzs,5663
7
+ python_osw_validation-0.0.5.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
8
+ python_osw_validation-0.0.5.dist-info/top_level.txt,sha256=GE81UPcDHEffJCxYu3M_iPz3Dt-O3axB73R5SLm_Veo,22
9
+ python_osw_validation-0.0.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.3)
2
+ Generator: bdist_wheel (0.42.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,9 +0,0 @@
1
- python_osw_validation/__init__.py,sha256=wbfrPcBdOZsBOgwTYq2QByJ5RzXqVMGqZ62H85CNXkY,3046
2
- python_osw_validation/extracted_data_validator.py,sha256=Nv_WQy7TOOMZWz0v6HEuwHrqPqseh2pn3yLhm1Tbjq8,1216
3
- python_osw_validation/zipfile_handler.py,sha256=fv3GwxUIrtsB8qlMCYjz7GsMBvo7Mf8n7g5WZqcPaoY,1123
4
- python_osw_validation/schema/opensidewalks.schema.json,sha256=qd-AJBfcMNA3Qr1EoL9u1fR662Qd9Qu3oNNkahzGNpE,103828
5
- python_osw_validation-0.0.3.dist-info/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
6
- python_osw_validation-0.0.3.dist-info/METADATA,sha256=F9O9WElt4VFSfc2gNDlOsQS11fWiLEt7vBdVUSFEuSQ,5396
7
- python_osw_validation-0.0.3.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
8
- python_osw_validation-0.0.3.dist-info/top_level.txt,sha256=GE81UPcDHEffJCxYu3M_iPz3Dt-O3axB73R5SLm_Veo,22
9
- python_osw_validation-0.0.3.dist-info/RECORD,,