Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Poulpe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
octobus
Poulpe
Commits
e5db5ad5
Commit
e5db5ad5
authored
2 years ago
by
Pierre-Yves David
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python-libs/poulpe/basics.py
+3
-1
3 additions, 1 deletion
python-libs/poulpe/basics.py
python-libs/poulpe/benchmarks.py
+2
-2
2 additions, 2 deletions
python-libs/poulpe/benchmarks.py
with
5 additions
and
3 deletions
python-libs/poulpe/basics.py
+
3
−
1
View file @
e5db5ad5
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
python-libs/poulpe/benchmarks.py
+
2
−
2
View file @
e5db5ad5
...
...
@@ -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
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment