Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-pipeline
csst_common
Commits
86d62717
Commit
86d62717
authored
1 year ago
by
BO ZHANG
Browse files
Options
Download
Email Patches
Plain Diff
refactor File.replace_ext
parent
13df314a
Pipeline
#2297
failed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
csst_common/file.py
+1
-1
csst_common/file.py
tests/test_file.py
+2
-2
tests/test_file.py
with
3 additions
and
3 deletions
+3
-3
csst_common/file.py
+
1
-
1
View file @
86d62717
...
...
@@ -6,7 +6,7 @@ class File:
self
.
file_path
=
file_path
self
.
file_path_prefix
,
self
.
file_path_ext
=
os
.
path
.
splitext
(
file_path
)
def
switch_extension
(
self
,
ext
=
"wht.fits"
)
->
str
:
def
replace_ext
(
self
,
ext
=
"wht.fits"
)
->
str
:
if
ext
.
startswith
(
"."
):
return
self
.
file_path_prefix
+
ext
else
:
...
...
This diff is collapsed.
Click to expand it.
tests/test_file.py
+
2
-
2
View file @
86d62717
...
...
@@ -5,5 +5,5 @@ from csst_common import File
class
TestFile
(
unittest
.
TestCase
):
def
test_parameterized_module_decorator
(
self
):
f
=
File
(
"/path/to/file.fits"
)
self
.
assertEqual
(
f
.
switch_extension
(
".cat"
),
"/path/to/file.cat"
)
self
.
assertEqual
(
f
.
switch_extension
(
"img.cat"
),
"/path/to/file_img.cat"
)
self
.
assertEqual
(
f
.
replace_ext
(
".cat"
),
"/path/to/file.cat"
)
self
.
assertEqual
(
f
.
replace_ext
(
"img.cat"
),
"/path/to/file_img.cat"
)
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets