Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-29 committed Nov 21, 2022
1 parent 807bdb8 commit 9fb64bd
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@
start_point = namedtuple("start_point", "lat lon")
run_map = namedtuple("polyline", "summary_polyline")

try:
with open("config.yaml") as f:
_config = yaml.safe_load(f)
except:
_config = {}


def config(*keys):
def safeget(dct, *keys):
for key in keys:
try:
dct = dct[key]
except KeyError:
return None
return dct

return safeget(_config, *keys)


# add more type here
TYPE_DICT = {
"running": "Run",
"RUN": "Run",
Expand All @@ -48,27 +68,6 @@

MAPPING_TYPE = ["Hike", "Ride", "VirtualRide", "Rowing", "Run", "Swim", "RoadTrip"]


try:
with open("config.yaml") as f:
_config = yaml.safe_load(f)
except:
_config = {}


def config(*keys):
def safeget(dct, *keys):
for key in keys:
try:
dct = dct[key]
except KeyError:
return None
return dct

return safeget(_config, *keys)


# add more type here
STRAVA_GARMIN_TYPE_DICT = {
"Hike": "hiking",
"Run": "running",
Expand Down

0 comments on commit 9fb64bd

Please sign in to comment.