Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Michiel Cottaar
fslpy
Commits
80ae30c4
Commit
80ae30c4
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
New Settings.readAll method
parent
39eff181
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
+20
-11
20 additions, 11 deletions
fsl/utils/settings.py
with
20 additions
and
11 deletions
fsl/utils/settings.py
+
20
−
11
View file @
80ae30c4
...
...
@@ -19,8 +19,10 @@ the following functions can be called at the module-level:
Settings.readFile
Settings.writeFile
Settings.deleteFile
Settings.readAll
Settings.clear
These functions will have no effect before :func:`initialise` is called.
Two types of configuration data are available:
...
...
@@ -43,10 +45,12 @@ from __future__ import absolute_import
import
os
import
os.path
as
op
import
sys
import
copy
import
atexit
import
shutil
import
pickle
import
logging
import
fnmatch
import
tempfile
import
platform
...
...
@@ -76,6 +80,7 @@ def initialise(*args, **kwargs):
mod
.
readFile
=
settings
.
readFile
mod
.
writeFile
=
settings
.
writeFile
mod
.
deleteFile
=
settings
.
deleteFile
mod
.
readAll
=
settings
.
readAll
mod
.
clear
=
settings
.
clear
...
...
@@ -93,6 +98,8 @@ def writeFile(*args, **kwargs):
pass
def
deleteFile
(
*
args
,
**
kwargs
):
pass
def
readAll
(
*
args
,
**
kwarg
):
return
{}
def
clear
(
*
args
,
**
kwarg
):
pass
...
...
@@ -101,17 +108,6 @@ class Settings(object):
"""
The ``Settings`` class contains all of the logic provided by the
``settings`` module. It is not meant to be instantiated directly
(although you may do so if you wish).
.. autosummary::
:nosignatures:
read
write
delete
readFile
writeFile
deleteFile
clear
"""
...
...
@@ -215,6 +211,19 @@ class Settings(object):
os
.
remove
(
path
)
def
readAll
(
self
,
pattern
=
None
):
"""
Returns all settings with names that match the given glob-style
pattern.
"""
if
pattern
is
None
:
return
copy
.
deepcopy
(
self
.
__config
)
keys
=
fnmatch
.
filter
(
self
.
__config
.
keys
(),
pattern
)
vals
=
[
copy
.
deepcopy
(
self
.
__config
[
k
])
for
k
in
keys
]
return
dict
(
zip
(
keys
,
vals
))
def
clear
(
self
):
"""
Delete all configuration settings and files.
"""
...
...
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