<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def files_generator(path, recursive):
 """Yield files found in a given path. Walk over a given path finding and yielding all files found on it. This can be done only on the root directory or recursively. Args: path: Path to the directory. recursive: Whether to find files recursively or not. Yields: A tuple for each file in the given path containing the path and the name of the file. """

    if recursive:
        for (path, _, files) in os.walk(path):
            for file in files:
                if not file.endswith(BATCH_EXTENSION):
                    yield (path, file)
    else:
        for file in os.listdir(path):
            if (os.path.isfile(os.path.join(path, file)) and
                    not file.endswith(BATCH_EXTENSION)):
                yield (path, file)