Commit 6d72c1d1 authored by Betoule Marc's avatar Betoule Marc
Browse files

Merge branch 'master' of gitorious.org:pipelet/pipelet

parents e17024b2 c0b57f5b
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment