Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
a4dc1959
Commit
a4dc1959
authored
6 years ago
by
Peterson, Peter
Browse files
Options
Downloads
Patches
Plain Diff
Add method to see if key exists
parent
505cf0b4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
qt/applications/workbench/workbench/config/test/test_user.py
+6
-0
6 additions, 0 deletions
qt/applications/workbench/workbench/config/test/test_user.py
qt/applications/workbench/workbench/config/user.py
+8
-0
8 additions, 0 deletions
qt/applications/workbench/workbench/config/user.py
with
14 additions
and
0 deletions
qt/applications/workbench/workbench/config/test/test_user.py
+
6
−
0
View file @
a4dc1959
...
@@ -62,6 +62,12 @@ class ConfigUserTest(TestCase):
...
@@ -62,6 +62,12 @@ class ConfigUserTest(TestCase):
self
.
assertEqual
(
True
,
self
.
cfg
.
get
(
'
main/bool_option2
'
))
self
.
assertEqual
(
True
,
self
.
cfg
.
get
(
'
main/bool_option2
'
))
def
test_has_keys
(
self
):
self
.
assertTrue
(
self
.
cfg
.
has
(
'
main
'
,
'
a_default_key
'
))
self
.
assertTrue
(
self
.
cfg
.
has
(
'
main/a_default_key
'
))
self
.
assertFalse
(
self
.
cfg
.
has
(
'
main
'
,
'
missing-key
'
))
self
.
assertFalse
(
self
.
cfg
.
has
(
'
main/missing-key
'
))
# ----------------------------------------------
# ----------------------------------------------
# Failure tests
# Failure tests
# ----------------------------------------------
# ----------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
qt/applications/workbench/workbench/config/user.py
+
8
−
0
View file @
a4dc1959
...
@@ -91,6 +91,14 @@ class UserConfig(object):
...
@@ -91,6 +91,14 @@ class UserConfig(object):
else
:
else
:
return
value
return
value
def
has
(
self
,
option
,
second
=
None
):
"""
Return a True if the key exists in the
settings. ``config.get(
'
main
'
,
'
window/size
'
)`` and
``config.get(
'
main/window/size
'
)`` are equivalent.
"""
option
=
self
.
_check_section_option_is_valid
(
option
,
second
)
return
option
in
self
.
all_keys
()
def
set
(
self
,
option
,
value
,
extra
=
None
):
def
set
(
self
,
option
,
value
,
extra
=
None
):
"""
Set a value for an option in a given section. Can either supply
"""
Set a value for an option in a given section. Can either supply
the fully qualified option or add the section as an additional
the fully qualified option or add the section as an additional
...
...
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