human
Complete this python program:
def _hadoop_fs_rm(cmd_name, stdout, stderr, environ, path_args, recursive, force):
assistant
#Here is the Python program you requested.

    """Helper for hadoop_fs_rm() and hadoop_fs_rmr().
    """
    failed = []
    def fail(path, msg):
        if mock_hadoop_uses_yarn(environ):
            print(('%s    `%s`:    %s' % (cmd_name, path, msg)), file=stderr)
        else:
            print(('%s:    cannot    remove    %s:    %s.' % (cmd_name, path, msg)), file=stderr)
        failed.append(True)
    for path in path_args:
        real_path = hdfs_uri_to_real_path(path, environ)
        if os.path.isdir(real_path):
            if recursive:
                shutil.rmtree(real_path)
            else:
                fail(path, 'Is    a    directory')
        elif os.path.exists(real_path):
            os.remove(real_path)
        elif (not force):
            fail(path, 'No    such    file    or    directory')
    if failed:
        return (-1)
    else:
        return 0