parameters: (directory, file_pattern, file_extension,
                              start_number, action, **kwargs)
return_statement: return successful
docstring: Function that performs a given action on all files matching a pattern.
  
    It is assumed that the files are named file_patternxxxx.file_extension, where
    xxxx are digits starting from start_number.
  
    Args:
      directory(string): The directory where the files live.
      file_pattern(string): The name pattern of the files.
      file_extension(string): The files' extension.
      start_number(int): From where to start to count frames.
      action(function): The action to be performed over the files. Must return
          False if the action failed, True otherwise. It should take a file name
          as the first argument and **kwargs as arguments. The function must be
          possible to pickle, so it cannot be a bound function (for instance).
  
    Return:
      (bool): Whether performing the action over all files was successful or not.
docstring_summary: Function that performs a given action on all files matching a pattern.
docstring_tokens: Function that performs a given action on all files matching a pattern .
function: def PerformActionOnAllFiles(directory, file_pattern, file_extension,
                              start_number, action, **kwargs):
    """Function that performs a given action on all files matching a pattern.
  
    It is assumed that the files are named file_patternxxxx.file_extension, where
    xxxx are digits starting from start_number.
  
    Args:
      directory(string): The directory where the files live.
      file_pattern(string): The name pattern of the files.
      file_extension(string): The files' extension.
      start_number(int): From where to start to count frames.
      action(function): The action to be performed over the files. Must return
          False if the action failed, True otherwise. It should take a file name
          as the first argument and **kwargs as arguments. The function must be
          possible to pickle, so it cannot be a bound function (for instance).
  
    Return:
      (bool): Whether performing the action over all files was successful or not.
    """
    file_prefix = os.path.join(directory, file_pattern)
    file_number = start_number
  
    process_pool = multiprocessing.Pool(processes=multiprocessing.cpu_count())
    results = []
    while True:
      zero_padded_file_number = ZeroPad(file_number)
      file_name = file_prefix + zero_padded_file_number + '.' + file_extension
      if not os.path.isfile(file_name):
        break
      future = process_pool.apply_async(action, args=(file_name,), kwds=kwargs)
      results.append(future)
      file_number += 1
  
    successful = True
    for result in results:
      if not result.get():
        print "At least one action %s failed for files %sxxxx.%s." % (
            action, file_pattern, file_extension)
        successful = False
  
    process_pool.close()
    return successful
function_tokens: def PerformActionOnAllFiles ( directory , file_pattern , file_extension , start_number , action , * * kwargs ) : file_prefix = os . path . join ( directory , file_pattern ) file_number = start_number process_pool = multiprocessing . Pool ( processes = multiprocessing . cpu_count ( ) ) results = [ ] while True : zero_padded_file_number = ZeroPad ( file_number ) file_name = file_prefix + zero_padded_file_number + '.' + file_extension if not os . path . isfile ( file_name ) : break future = process_pool . apply_async ( action , args = ( file_name , ) , kwds = kwargs ) results . append ( future ) file_number += 1 successful = True for result in results : if not result . get ( ) : print "At least one action %s failed for files %sxxxx.%s." % ( action , file_pattern , file_extension ) successful = False process_pool . close ( ) return successful