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
f95b7068
Commit
f95b7068
authored
1 year ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
MNT: change to f-strings
parent
6e8de485
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/utils/imcp.py
+7
-7
7 additions, 7 deletions
fsl/utils/imcp.py
with
7 additions
and
7 deletions
fsl/utils/imcp.py
+
7
−
7
View file @
f95b7068
...
@@ -57,7 +57,7 @@ def imcp(src,
...
@@ -57,7 +57,7 @@ def imcp(src,
# special case - non-existent directory
# special case - non-existent directory
if
dest
.
endswith
(
'
/
'
)
and
not
op
.
isdir
(
dest
):
if
dest
.
endswith
(
'
/
'
)
and
not
op
.
isdir
(
dest
):
raise
fslpath
.
PathError
(
'
Directory does not exist: {
}
'
.
format
(
dest
)
)
raise
fslpath
.
PathError
(
f
'
Directory does not exist:
{
dest
}
'
)
if
op
.
isdir
(
dest
):
if
op
.
isdir
(
dest
):
dest
=
op
.
join
(
dest
,
op
.
basename
(
src
))
dest
=
op
.
join
(
dest
,
op
.
basename
(
src
))
...
@@ -87,7 +87,7 @@ def imcp(src,
...
@@ -87,7 +87,7 @@ def imcp(src,
if
not
op
.
exists
(
src
):
if
not
op
.
exists
(
src
):
raise
fslpath
.
PathError
(
'
imcp error - source path
'
raise
fslpath
.
PathError
(
'
imcp error - source path
'
'
does not exist: {
}
'
.
format
(
src
)
)
f
'
does not exist:
{
src
}
'
)
# Figure out the destination file
# Figure out the destination file
# extension/type. If useDefaultExt
# extension/type. If useDefaultExt
...
@@ -116,10 +116,10 @@ def imcp(src,
...
@@ -116,10 +116,10 @@ def imcp(src,
# Give up if we don't have permission.
# Give up if we don't have permission.
if
not
os
.
access
(
op
.
dirname
(
dest
),
os
.
W_OK
|
os
.
X_OK
):
if
not
os
.
access
(
op
.
dirname
(
dest
),
os
.
W_OK
|
os
.
X_OK
):
raise
fslpath
.
PathError
(
'
imcp error - cannot write to {
}
'
.
format
(
dest
)
)
raise
fslpath
.
PathError
(
f
'
imcp error - cannot write to
{
dest
}
'
)
if
move
and
not
os
.
access
(
op
.
dirname
(
src
),
os
.
W_OK
|
os
.
X_OK
):
if
move
and
not
os
.
access
(
op
.
dirname
(
src
),
os
.
W_OK
|
os
.
X_OK
):
raise
fslpath
.
PathError
(
'
imcp error - cannot move from {
}
'
.
format
(
src
)
)
raise
fslpath
.
PathError
(
f
'
imcp error - cannot move from
{
src
}
'
)
# If the source file type does not
# If the source file type does not
# match the destination file type,
# match the destination file type,
...
@@ -132,8 +132,8 @@ def imcp(src,
...
@@ -132,8 +132,8 @@ def imcp(src,
if
srcExt
!=
destExt
:
if
srcExt
!=
destExt
:
if
not
overwrite
and
op
.
exists
(
dest
):
if
not
overwrite
and
op
.
exists
(
dest
):
raise
fslpath
.
PathError
(
'
imcp error - destination
already
'
raise
fslpath
.
PathError
(
'
imcp error - destination
'
'
exists ({})
'
.
format
(
dest
)
)
f
'
already exists (
{
dest
}
)
'
)
img
=
nib
.
load
(
src
)
img
=
nib
.
load
(
src
)
nib
.
save
(
img
,
dest
)
nib
.
save
(
img
,
dest
)
...
@@ -193,7 +193,7 @@ def imcp(src,
...
@@ -193,7 +193,7 @@ def imcp(src,
# paths already exist
# paths already exist
if
not
overwrite
and
any
([
op
.
exists
(
d
)
for
d
in
copyDests
]):
if
not
overwrite
and
any
([
op
.
exists
(
d
)
for
d
in
copyDests
]):
raise
fslpath
.
PathError
(
'
imcp error - a destination path already
'
raise
fslpath
.
PathError
(
'
imcp error - a destination path already
'
'
exists ({
})
'
.
format
(
'
,
'
.
join
(
copyDests
)
)
)
f
'
exists (
{
'
,
'
.
join
(
copyDests
)
}
)
'
)
# Do the copy/move
# Do the copy/move
for
src
,
dest
in
zip
(
copySrcs
,
copyDests
):
for
src
,
dest
in
zip
(
copySrcs
,
copyDests
):
...
...
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