From 8d2f46876a446af07aa91b98d2455bd1b6aedfc5 Mon Sep 17 00:00:00 2001 From: CarlosCoelhoSL Date: Wed, 13 Dec 2023 10:12:44 +0000 Subject: [PATCH] Checks for lookup.csv existing and entity min/max --- digital_land/commands.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/digital_land/commands.py b/digital_land/commands.py index c79f2417..0eb51b1f 100644 --- a/digital_land/commands.py +++ b/digital_land/commands.py @@ -509,6 +509,14 @@ def add_endpoints_and_lookups( # save new lookups to file lookups = Lookups(pipeline_dir) + # Check if the lookups file exists, create it if not + if not os.path.exists(lookups.lookups_path): + with open(lookups.lookups_path, "w", newline="") as f: + writer = csv.writer(f) + writer.writerow( + ["prefix", "resource", "organisation", "reference", "entity"] + ) + lookups.load_csv() for new_lookup in new_lookups: for idx, entry in enumerate(new_lookup): @@ -517,7 +525,12 @@ def add_endpoints_and_lookups( # save edited csvs max_entity_num = lookups.get_max_entity(pipeline_name) lookups.entity_num_gen.state["current"] = max_entity_num - lookups.entity_num_gen.state["range_max"] = max_entity_num + 9999 + lookups.entity_num_gen.state["range_max"] = specification.get_dataset_entity_max( + dataset + ) + lookups.entity_num_gen.state["range_min"] = specification.get_dataset_entity_min( + dataset + ) collection.save_csv() lookups.save_csv()