Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
pipelet
Pipelet
Commits
3a7215ea
Commit
3a7215ea
authored
Oct 14, 2010
by
Maude Le Jeune
Browse files
No commit message
No commit message
parent
5601df0c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
0 deletions
+93
-0
pipelet/planckenv.py
pipelet/planckenv.py
+93
-0
No files found.
pipelet/planckenv.py
0 → 100644
View file @
3a7215ea
from
pipelet.environment
import
*
class
PlanckEnvironment
(
Environment
):
def
my_function
(
self
):
""" My function do nothing
"""
return
def
get_data_fn
(
x
,
dmc
=
False
,
grp
=
None
):
""" Complete the filename with the path to the working
directory.
If dmc is True a DMC object name is returned
using grp as group name and an empty file pointing to the DMC
object is made.
Parameters
----------
x: string, filename suffix
grp: string, DMC group name
Returns
-------
string, filename
"""
## dmc object
if
dmc
:
x
=
x
.
split
(
"."
)[
0
]
## remove extension
x
=
x
+
"_"
+
self
.
_worker
.
pipe
.
_hashes
[
self
.
_worker
.
task
.
seg
]
## add key
if
grp
is
None
:
logger
.
error
(
"groupname is None for DMC object %s"
%
x
)
import
piolib
x
=
path
.
join
(
grp
,
x
)
dmcname
=
path
.
join
(
piolib
.
GetDataDB
(),
x
)
locname
=
self
.
_get_data_fn
(
x
.
replace
(
"/"
,
":"
))
os
.
system
(
"touch %s"
%
locname
)
return
dmcname
## local file
else
:
return
self
.
_get_data_fn
(
x
)
def
glob_default
(
self
,
x
,
y
):
""" Return the list of filename matching y in the working
directory of segment x.
Parameters
----------
x: string, segment name
y: string, regexp of file to glob.
Returns
-------
list of filenames.
"""
segx
=
self
.
_worker
.
pipe
.
find_seg
(
self
.
_worker
.
task
.
seg
,
x
)
if
segx
is
None
:
self
.
logger
.
warning
(
"No parent segment matching %s found"
%
x
)
return
glob
(
path
.
join
(
self
.
_worker
.
pipe
.
get_data_dir
(
segx
),
y
))
\
+
glob
(
path
.
join
(
self
.
_worker
.
pipe
.
get_data_dir
(
segx
),
path
.
join
(
'*/'
,
y
)))
def
glob_seg
(
x
,
y
):
""" Return the list of filename matching y in the working
directory of segment x.
Parameters
----------
x: string, segment name
y: string, regexp of file to glob.
Returns
-------
list of filenames.
"""
f
=
self
.
glob_default
(
x
,
y
)
if
not
f
:
#z = y.replace(".fits", "")
z
=
"*:"
+
y
f
=
self
.
glob_default
(
x
,
z
)
if
f
:
lst
=
[]
for
fi
in
f
:
## if dmc object -> replace : with /
if
len
(
fi
.
split
(
"."
))
==
1
:
lst
.
append
(
os
.
path
.
basename
(
fi
).
replace
(
":"
,
"/"
))
f
=
lst
return
f
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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