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
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:
...
@@ -19,8 +19,10 @@ the following functions can be called at the module-level:
Settings.readFile
Settings.readFile
Settings.writeFile
Settings.writeFile
Settings.deleteFile
Settings.deleteFile
Settings.readAll
Settings.clear
Settings.clear
These functions will have no effect before :func:`initialise` is called.
These functions will have no effect before :func:`initialise` is called.
Two types of configuration data are available:
Two types of configuration data are available:
...
@@ -43,10 +45,12 @@ from __future__ import absolute_import
...
@@ -43,10 +45,12 @@ from __future__ import absolute_import
import
os
import
os
import
os.path
as
op
import
os.path
as
op
import
sys
import
sys
import
copy
import
atexit
import
atexit
import
shutil
import
shutil
import
pickle
import
pickle
import
logging
import
logging
import
fnmatch
import
tempfile
import
tempfile
import
platform
import
platform
...
@@ -76,6 +80,7 @@ def initialise(*args, **kwargs):
...
@@ -76,6 +80,7 @@ def initialise(*args, **kwargs):
mod
.
readFile
=
settings
.
readFile
mod
.
readFile
=
settings
.
readFile
mod
.
writeFile
=
settings
.
writeFile
mod
.
writeFile
=
settings
.
writeFile
mod
.
deleteFile
=
settings
.
deleteFile
mod
.
deleteFile
=
settings
.
deleteFile
mod
.
readAll
=
settings
.
readAll
mod
.
clear
=
settings
.
clear
mod
.
clear
=
settings
.
clear
...
@@ -93,6 +98,8 @@ def writeFile(*args, **kwargs):
...
@@ -93,6 +98,8 @@ def writeFile(*args, **kwargs):
pass
pass
def
deleteFile
(
*
args
,
**
kwargs
):
def
deleteFile
(
*
args
,
**
kwargs
):
pass
pass
def
readAll
(
*
args
,
**
kwarg
):
return
{}
def
clear
(
*
args
,
**
kwarg
):
def
clear
(
*
args
,
**
kwarg
):
pass
pass
...
@@ -101,17 +108,6 @@ class Settings(object):
...
@@ -101,17 +108,6 @@ class Settings(object):
"""
The ``Settings`` class contains all of the logic provided by the
"""
The ``Settings`` class contains all of the logic provided by the
``settings`` module. It is not meant to be instantiated directly
``settings`` module. It is not meant to be instantiated directly
(although you may do so if you wish).
(although you may do so if you wish).
.. autosummary::
:nosignatures:
read
write
delete
readFile
writeFile
deleteFile
clear
"""
"""
...
@@ -215,6 +211,19 @@ class Settings(object):
...
@@ -215,6 +211,19 @@ class Settings(object):
os
.
remove
(
path
)
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
):
def
clear
(
self
):
"""
Delete all configuration settings and files.
"""
"""
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