Skip to content
Snippets Groups Projects
Commit e5db5ad5 authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

benchmark: allow to return a default value when accessing var

This will be useful to define default behavior is less cubbersome way.
parent 3707fc80
No related branches found
No related tags found
No related merge requests found
......@@ -64,10 +64,10 @@
print(f"{indent}{k} = {v}")
def get_one_value(data, key):
def get_one_value(data, key, default=None):
key_path = key.split('.')
sub = data
for k in key_path:
sub = sub.get(k)
if sub is None:
break
......@@ -68,9 +68,11 @@
key_path = key.split('.')
sub = data
for k in key_path:
sub = sub.get(k)
if sub is None:
break
if sub is None:
sub = default
return sub
......
......@@ -66,8 +66,8 @@
def name(self):
return self._data['meta']['name']
def get_var(self, key):
return poulpe.get_one_value(self._data, key)
def get_var(self, key, default=None):
return poulpe.get_one_value(self._data, key, default=default)
@property
def selected_variants(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment