Skip to content

Commit

Permalink
start experimenting with generating yaml from route db
Browse files Browse the repository at this point in the history
  • Loading branch information
ztatlock committed Apr 4, 2024
1 parent bc3dd71 commit 27b8315
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions _data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
route-db.yaml
17 changes: 16 additions & 1 deletion _data/route-db-invariants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import csv
import os

FIELDS = ['id', 'name', 'dist', 'elev', 'start', 'end', 'type', 'map']
FIELDS = ['id', 'name', 'start', 'dist', 'elev', 'end', 'type', 'map']
TYPES = ['Loop', 'P2P', 'OB']
LOCS = [
'Beacon',
Expand All @@ -21,6 +21,7 @@
# route-db.csv lives in the same directory as this script
data_dir = os.path.dirname(os.path.realpath(__file__))
csv_path = os.path.join(data_dir, 'route-db.csv')
yaml_path = os.path.join(data_dir, 'route-db.yaml')
gpx_dir = os.path.join(data_dir, 'gpx')

warnings = False
Expand Down Expand Up @@ -94,3 +95,17 @@ def check_route(route):
writer.writeheader()
for route in routes:
writer.writerow(route)

# output yaml version as well
with open(yaml_path, 'w') as f:
f.write('# AUTOGENERATED - DO NOT EDIT\n\n')
for route in routes:
f.write(f"- id: {route['id']}\n")
f.write(f" name: \"{route['name']}\"\n")
f.write(f" start: \"{route['start']}\"\n")
f.write(f" dist: {route['dist']}\n")
f.write(f" elev: {route['elev']}\n")
f.write(f" end: \"{route['end']}\"\n")
f.write(f" type: \"{route['type']}\"\n")
f.write(f" map: \"{route['map']}\"\n")
f.write('\n')

0 comments on commit 27b8315

Please sign in to comment.