Python library for OSW validation
Project description
TDEI python lib OSW validation package
This package validates the OSW geojson file. Package requires a OSW zip file path
System requirements
| Software | Version |
|---|---|
| Python | 3.10.x |
What this package does?
- It unzip the provided zip files
- Check for the required nodes and edges geojson files inside the unzipped folder
- Validate each file (edges, lines, nodes, points, polygons and zones) against the matching schema (0.3 defaults live in
src/python_osw_validation/schema) - Return true or false according to validation
- you can check the error if it returned false.
Starting a new project with template
- Add
python-osw-validationpackage as dependency in yourrequirements.txt - or
pip install python-osw-validation - Start using the packages in your code.
Initialize and Configuration
from python_osw_validation import OSWValidation
validator = OSWValidation(zipfile_path='<Zip file path>')
result = validator.validate()
print(result.is_valid)
print(result.errors) # will return first 20 errors by default if there are errors
result = validator.validate(max_errors=10)
print(result.is_valid)
print(result.errors) # will return first 10 errors depending on the max_errors parameter
Testing
The project is configured with python to figure out the coverage of the unit tests. All the tests are in tests
folder.
-
To execute the tests, please follow the commands:
pip install -r requirements.txtpython -m unittest discover -v tests/unit_tests -
To execute the code coverage, please follow the commands:
coverage run --source=src/python_osw_validation -m unittest discover -v tests/unit_testscoverage html// Can be run after 1st commandcoverage report// Can be run after 1st command -
After the commands are run, you can check the coverage report in
htmlcov/index.html. Open the file in any browser, and it shows complete coverage details -
The terminal will show the output of coverage like this
> coverage run --source=src/python_osw_validation -m unittest discover -v tests/unit_tests
test_duplicate_files (test_extracted_data_validator.TestExtractedDataValidator) ... ok
test_empty_directory (test_extracted_data_validator.TestExtractedDataValidator) ... ok
test_invalid_directory (test_extracted_data_validator.TestExtractedDataValidator) ... ok
test_missing_optional_file (test_extracted_data_validator.TestExtractedDataValidator) ... ok
test_no_geojson_files (test_extracted_data_validator.TestExtractedDataValidator) ... ok
test_valid_data_at_root (test_extracted_data_validator.TestExtractedDataValidator) ... ok
test_valid_data_inside_folder (test_extracted_data_validator.TestExtractedDataValidator) ... ok
test_edges_invalid_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_edges_invalid_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
test_edges_invalid_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
test_external_extension_file_inside_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_external_extension_file_inside_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
test_external_extension_file_inside_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
test_extra_field_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_id_missing_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_invalid_geometry_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_invalid_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_invalid_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
test_invalid_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
test_minimal_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_minimal_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
test_minimal_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
test_missing_identifier_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_no_entity_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_nodes_invalid_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_nodes_invalid_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
test_nodes_invalid_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
test_points_invalid_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_points_invalid_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
test_points_invalid_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
test_valid_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_valid_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
test_valid_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
test_wrong_datatypes_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_extract_invalid_zip (test_zipfile_handler.TestZipFileHandler) ... ok
test_extract_valid_zip (test_zipfile_handler.TestZipFileHandler) ... ok
test_remove_extracted_files (test_zipfile_handler.TestZipFileHandler) ... ok
----------------------------------------------------------------------
Ran 37 tests in 1284.068s
OK
Use locally:
To use the library locally, use the example.py code
Deployment:
Deploy to TestPy
- On every push to
devbranch, a workflow is triggered which publishes the updated version to TestPy
Deploy to PyPI
- This happens whenever a tag/release is created with
*.*.*notation (eg. 0.0.8) - To change the version, change the version at version.py
- To release a new version:
- Go to Github link of this repository
- Under releases, click on
Draft a new release - Under
choose a new tag, add a new tagv*.*.*, Generate Release notes - Choose
mainbranch for release - Publish the release.
- This release triggers a workflow to generate the new version of the Package.
- The new package will be available at https://pypi.org/project/python-osw-validation/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_osw_validation-0.3.4-py3-none-any.whl.
File metadata
- Download URL: python_osw_validation-0.3.4-py3-none-any.whl
- Upload date:
- Size: 41.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fa73eedd88d0f6ece76c4e8c605ed995ca9e9232607ef49f835ddaad6c5c351
|
|
| MD5 |
cc7a00a540d3f510220c6f82c758c83d
|
|
| BLAKE2b-256 |
7c8318f0589b3c625d77bb2e160e895302b4e8a53bfea5068f3da29da8fd1aac
|