@gen.engine
def Grep(args, callback):
 assert (len(args) >= 2)
 pattern = re.compile(args[0])
 files = args[1:]
 bucket = store = None
 for f in files:
  resolved = store_utils.ParseFullPath(f)
  assert (resolved is not None), ('Cannot determine bucket from %s' % f)
  (b, path) = resolved
  assert ((bucket is None) or (bucket == b)), 'Input files must all be in the same bucket'
  if (store is None):
   bucket = b
   store = ObjectStore.GetInstance(bucket)
  contents = (yield gen.Task(store_utils.GetFileContents, store, path))
  for line in contents.split('\n'):
   if pattern.search(line):
    print ('%s:%s' % (f, line))
 callback()

@ gen . engine def Grep ( args , callback ) : assert ( len ( args ) >= 2 ) pattern = re . compile ( args [ 0 ] ) files = args [ 1 : ] bucket = store = None for f in files : resolved = store_utils . ParseFullPath ( f ) assert ( resolved is not None ) , ( 'Cannot determine bucket from %s' % f ) ( b , path ) = resolved assert ( ( bucket is None ) or ( bucket == b ) ) , 'Input files must all be in the same bucket' if ( store is None ) : bucket = b store = ObjectStore . GetInstance ( bucket ) contents = ( yield gen . Task ( store_utils . GetFileContents , store , path ) ) for line in contents . split ( '\n' ) : if pattern . search ( line ) : print ( '%s:%s' % ( f , line ) ) callback ( )
grep a set of files .