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
6d72c1d1
Commit
6d72c1d1
authored
Oct 18, 2010
by
Betoule Marc
Browse files
Merge branch 'master' of gitorious.org:pipelet/pipelet
parents
e17024b2
c0b57f5b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
0 deletions
+94
-0
pipelet/planckenv.py
pipelet/planckenv.py
+94
-0
No files found.
pipelet/planckenv.py
0 → 100644
View file @
6d72c1d1
from
pipelet.environment
import
*
import
os
class
PlanckEnvironment
(
Environment
):
def
my_function
(
self
):
""" My function do nothing
"""
return
def
get_data_fn
(
self
,
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
)
x
=
path
.
join
(
piolib
.
GetDataDB
(),
x
)
locname
=
self
.
_get_data_fn
(
x
.
replace
(
"/"
,
":"
))
os
.
system
(
"touch %s"
%
locname
)
return
x
## 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
(
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.
"""
f
=
self
.
glob_default
(
x
,
y
)
import
piolib
if
not
f
:
self
.
logger
.
info
(
"No file matching the extension, looking for DMC object"
)
z
=
y
.
split
(
"."
)[
0
]
z
=
"*:"
+
z
self
.
logger
.
info
(
"New regexp is %s"
%
z
)
f
=
self
.
glob_default
(
x
,
z
)
lst
=
[]
for
fi
in
f
:
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