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
Model registry
Operate
Environments
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
FSL
fslpy
Commits
772700d7
Commit
772700d7
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
New settings function filePath, to get absolute file path
parent
20f88560
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
+16
-8
16 additions, 8 deletions
fsl/utils/settings.py
with
16 additions
and
8 deletions
fsl/utils/settings.py
+
16
−
8
View file @
772700d7
...
...
@@ -19,8 +19,9 @@ the following functions can be called at the module-level:
Settings.readFile
Settings.writeFile
Settings.deleteFile
Settings.
listFiles
Settings.
filePath
Settings.readAll
Settings.listFiles
Settings.clear
...
...
@@ -81,6 +82,7 @@ def initialise(*args, **kwargs):
mod
.
readFile
=
settings
.
readFile
mod
.
writeFile
=
settings
.
writeFile
mod
.
deleteFile
=
settings
.
deleteFile
mod
.
filePath
=
settings
.
filePath
mod
.
readAll
=
settings
.
readAll
mod
.
listFiles
=
settings
.
listFiles
mod
.
clear
=
settings
.
clear
...
...
@@ -100,6 +102,8 @@ def writeFile(*args, **kwargs):
pass
def
deleteFile
(
*
args
,
**
kwargs
):
pass
def
filePath
(
*
args
,
**
kwargs
):
pass
def
readAll
(
*
args
,
**
kwarg
):
return
{}
def
listFiles
(
*
args
,
**
kwarg
):
...
...
@@ -180,8 +184,7 @@ class Settings(object):
"""
mode
=
'
r
'
+
mode
path
=
self
.
__fixPath
(
path
)
path
=
op
.
join
(
self
.
__configDir
,
path
)
path
=
self
.
filePath
(
path
)
if
op
.
exists
(
path
):
with
open
(
path
,
mode
)
as
f
:
...
...
@@ -194,8 +197,7 @@ class Settings(object):
"""
Writes the given ``value`` to the given file ``path``.
"""
mode
=
'
w
'
+
mode
path
=
self
.
__fixPath
(
path
)
path
=
op
.
join
(
self
.
__configDir
,
path
)
path
=
self
.
filePath
(
path
)
pathdir
=
op
.
dirname
(
path
)
if
not
op
.
exists
(
pathdir
):
...
...
@@ -208,13 +210,19 @@ class Settings(object):
def
deleteFile
(
self
,
path
):
"""
Deletes the given file ``path``.
"""
path
=
self
.
__fixPath
(
path
)
path
=
op
.
join
(
self
.
__configDir
,
path
)
path
=
self
.
filePath
(
path
)
if
op
.
exists
(
path
):
os
.
remove
(
path
)
def
filePath
(
self
,
path
):
"""
Converts the given ``path`` to an absolute path.
"""
path
=
self
.
__fixPath
(
path
)
path
=
op
.
join
(
self
.
__configDir
,
path
)
return
path
def
readAll
(
self
,
pattern
=
None
):
"""
Returns all settings with names that match the given glob-style
pattern.
...
...
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