s=self.conn.execute('select seg_id from segments where tag like ?',("%"+tag+"%",)).fetchone()
else:
s=self.conn.execute('select seg_id from segments where curr_dir like ?',("%"+self.path+"%",)).fetchone()
lstseg=[s[0]]
lstseg+=self._get_fathers(s[0])
self.lstseg=lstseg
delself.cache
def_get_fathers(self,segid):
""" Append upstream pipeline instance paths to the current path.
Return a list which contains all upstream segment instances
id for a given segment instance. This is used to print a pipeline
tree view with all dependencies.
Parameters
----------
segid: id of the leaf segment.
Returns
-------
list of segid, for the upstream segment instances.
"""
lstid=[int(segid)]
fids=self.conn.execute(
'select father_id from segment_relations where child_id = ?'
,(segid,)).fetchall()
iffids:
forlinfids:
lstid+=self._get_fathers(l[0])
returnlstid
defget_seg_par(self,seg):
l=self.conn.execute('select curr_dir from segments where (seg glob ?) and seg_id IN ('+','.join('?'*len(self.lstseg))+')',(seg,)+tuple(self.lstseg)).fetchall()