def _get_per_location_glob(tasks, outputs, regexes):
 paths = [o.path for o in outputs]
 matches = [r.search(p) for (r, p) in zip(regexes, paths)]
 for (m, p, t) in zip(matches, paths, tasks):
  if (m is None):
   raise NotImplementedError(("Couldn't deduce datehour representation in output path %r of task %s" % (p, t)))
 n_groups = len(matches[0].groups())
 positions = [most_common(((m.start(i), m.end(i)) for m in matches))[0] for i in range(1, (n_groups + 1))]
 glob = list(paths[0])
 for (start, end) in positions:
  glob = ((glob[:start] + (['[0-9]'] * (end - start))) + glob[end:])
 return ''.join(glob).rsplit('/', 1)[0]

def _get_per_location_glob ( tasks , outputs , regexes ) : paths = [ o . path for o in outputs ] matches = [ r . search ( p ) for ( r , p ) in zip ( regexes , paths ) ] for ( m , p , t ) in zip ( matches , paths , tasks ) : if ( m is None ) : raise NotImplementedError ( ( "Couldn't deduce datehour representation in output path %r of task %s" % ( p , t ) ) ) n_groups = len ( matches [ 0 ] . groups ( ) ) positions = [ most_common ( ( ( m . start ( i ) , m . end ( i ) ) for m in matches ) ) [ 0 ] for i in range ( 1 , ( n_groups + 1 ) ) ] glob = list ( paths [ 0 ] ) for ( start , end ) in positions : glob = ( ( glob [ : start ] + ( [ '[0-9]' ] * ( end - start ) ) ) + glob [ end : ] ) return '' . join ( glob ) . rsplit ( '/' , 1 ) [ 0 ]
builds a glob listing existing output paths .