Skip to content

Commit

Permalink
Fix imports, error if validation has 0 files provided
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed May 9, 2024
1 parent b3fdcbb commit 7dd0b29
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `fiboa validate`:
- Is more robust against invalid collections and doesn't abort if not needed
- Check NULL values correctly in case of arrays
- Throw an error if no files were provided
- `fiboa create-geojson`:
- Handles GeoParquet bbox correctly
- Converts numpy arrays
- Doesn't export empty collections
- Fix recursive import

## [v0.3.10] - 2024-05-06

Expand Down
5 changes: 5 additions & 0 deletions fiboa_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ def validate(files, schema, ext_schema, fiboa_version, collection, data, timer):
"collection": collection,
"data": data,
}

if len(files) == 0:
log("No files to validate", "error")
sys.exit(1)

exit = 0
for file in files:
log(f"Validating {file}", "info")
Expand Down
11 changes: 6 additions & 5 deletions fiboa_cli/convert.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import importlib
import os
from . import datasets

IGNORED_DATASET_FILES = ["__init__.py", "template.py"]

def convert(dataset, output_file, cache_file = None, source_coop_url = None, collection = False, compression = None):
if dataset == "template":
raise Exception(f"Converter for dataset 'template' not available")
if dataset in IGNORED_DATASET_FILES:
raise Exception(f"'{dataset}' is not a converter")
try:
converter = read_converter(dataset)
except ImportError as e:
Expand All @@ -13,9 +14,9 @@ def convert(dataset, output_file, cache_file = None, source_coop_url = None, col
converter.convert(output_file, cache_file = cache_file, source_coop_url = source_coop_url, collection = collection, compression = compression)

def list_all_converter_ids():
datasets = importlib.import_module(".datasets", package="fiboa_cli")
files = os.listdir(datasets.__path__[0])
ignore = ["__init__.py", "template.py"]
return [f[:-3] for f in files if f.endswith(".py") and f not in ignore]
return [f[:-3] for f in files if f.endswith(".py") and f not in IGNORED_DATASET_FILES]

def list_all_converters(keys):
converters = {}
Expand Down
Empty file added fiboa_cli/datasets/__init__.py
Empty file.

0 comments on commit 7dd0b29

Please sign in to comment.