Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository 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
Evan Edmond
fslpy
Commits
632d8ced
Commit
632d8ced
authored
8 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Convenience function to convert string to bool (for saved boolean
settings).
parent
bd87e704
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/utils/settings.py
+18
-0
18 additions, 0 deletions
fsl/utils/settings.py
with
18 additions
and
0 deletions
fsl/utils/settings.py
+
18
−
0
View file @
632d8ced
...
@@ -32,6 +32,24 @@ should be the same as the identifier given to the OSX application bundle
...
@@ -32,6 +32,24 @@ should be the same as the identifier given to the OSX application bundle
"""
"""
def
strToBool
(
s
):
"""
Currently the ``settings`` module is not type aware, so boolean
values are saved as strings ``
'
True
'
`` or ``
'
False
'
``. This makes
conversion back to boolean a bit annoying, as ``
'
False
'
`` evaluates
to ``True``.
This function may be used for a more sensible `str` -> `bool`
conversion
.. note:: In the future, the ``settings`` module will hopefully be
type-aware, so use of this function will no longer be necessary.
"""
s
=
str
(
s
).
lower
()
if
s
==
'
true
'
:
return
True
elif
s
==
'
false
'
:
return
False
else
:
return
bool
(
s
)
def
read
(
name
,
default
=
None
):
def
read
(
name
,
default
=
None
):
"""
Reads a setting with the given ``name``, return ``default`` if
"""
Reads a setting with the given ``name``, return ``default`` if
there is no setting called ``name``.
there is no setting called ``name``.
...
...
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