Skip to content
GitLab
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
920aa478
Commit
920aa478
authored
Dec 16, 2023
by
BO ZHANG
🏀
Browse files
fix bugs in File
parent
aedd4608
Pipeline
#2434
failed with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
csst_common/file.py
View file @
920aa478
...
...
@@ -55,26 +55,44 @@ class File:
r
"(?P<ext>[a-z.]+)"
)
self
.
mo
=
re
.
fullmatch
(
pattern
,
self
.
file_name
)
assert
self
.
mo
is
not
None
,
f
"Pattern does not match
for file
:
{
self
.
file_name
}
"
assert
self
.
mo
is
not
None
,
f
"Pattern does not match:
{
self
.
file_name
}
"
# set attributes
for
k
,
v
in
self
.
mo
.
groupdict
().
items
():
self
.
__setattr__
(
k
,
v
)
# for k, v in self.mo.groupdict().items():
# self.__setattr__(k, v)
self
.
telescope
=
self
.
mo
.
groupdict
()[
"telescope"
]
self
.
instrument
=
self
.
mo
.
groupdict
()[
"instrument"
]
self
.
project
=
self
.
mo
.
groupdict
()[
"project"
]
self
.
obs_type
=
self
.
mo
.
groupdict
()[
"obs_type"
]
self
.
exp_start
=
self
.
mo
.
groupdict
()[
"exp_start"
]
self
.
exp_stop
=
self
.
mo
.
groupdict
()[
"exp_stop"
]
self
.
obs_id
=
self
.
mo
.
groupdict
()[
"obs_id"
]
self
.
detector
=
self
.
mo
.
groupdict
()[
"detector"
]
self
.
level
=
self
.
mo
.
groupdict
()[
"level"
]
self
.
version
=
self
.
mo
.
groupdict
()[
"version"
]
self
.
ext
=
self
.
mo
.
groupdict
()[
"ext"
]
def
derive
(
self
,
new_dir
=
None
,
telescope
=
None
,
instrument
=
None
,
project
=
None
,
obs_type
=
None
,
exp_start
=
None
,
exp_st
op
=
None
,
obs_id
=
None
,
detector
=
None
,
level
=
None
,
version
=
None
,
ext
=
None
,
ext
:
Optional
[
str
]
=
None
,
new_dir
:
Optional
[
str
]
=
None
,
telescope
:
Optional
[
str
]
=
None
,
instrument
:
Optional
[
str
]
=
None
,
project
:
Optional
[
str
]
=
None
,
obs_type
:
Optional
[
str
]
=
None
,
exp_st
art
:
Optional
[
str
|
int
]
=
None
,
exp_stop
:
Optional
[
str
|
int
]
=
None
,
obs_id
:
Optional
[
str
|
int
]
=
None
,
detector
:
Optional
[
str
|
int
]
=
None
,
level
:
Optional
[
str
|
int
]
=
None
,
version
:
Optional
[
str
|
int
]
=
None
,
):
if
ext
is
None
:
ext
=
self
.
ext
else
:
assert
isinstance
(
ext
,
str
)
if
not
ext
.
startswith
(
"."
):
ext
=
"_"
+
str
(
ext
)
return
os
.
path
.
join
(
new_dir
if
new_dir
is
not
None
else
self
.
new_dir
,
f
"
{
self
.
telescope
if
telescope
is
None
else
str
(
telescope
)
}
_"
...
...
@@ -87,7 +105,7 @@ class File:
f
"
{
self
.
detector
if
detector
is
None
else
str
(
detector
)
}
_"
f
"L
{
self
.
level
if
level
is
None
else
str
(
level
)
}
_"
f
"V
{
self
.
version
if
version
is
None
else
str
(
version
).
zfill
(
2
)
}
"
f
"
{
self
.
ext
if
ext
is
None
else
str
(
ext
)
}
"
,
f
"
{
ext
}
"
,
)
def
derive0
(
self
,
*
args
,
**
kwargs
):
...
...
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