Skip to content

Commit

Permalink
Checks for lookup.csv existing and entity min/max
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosCoelhoSL committed Dec 13, 2023
1 parent 5416de4 commit 8d2f468
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion digital_land/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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()
Expand Down

0 comments on commit 8d2f468

Please sign in to comment.