Act as 'rm -rf' in the shell

def rm_rf(path):
    """
    Act as 'rm -rf' in the shell
    """
    if os.path.isfile(path):
        os.unlink(path)
    elif os.path.isdir(path):
        for root, dirs, files in os.walk(path, topdown=False):
            for filename in files:
                filepath = os.path.join(root, filename)
                logger.info("Deleting file %s" % filepath)
                os.unlink(filepath)
            for dirname in dirs:
                dirpath = os.path.join(root, dirname)
                if os.path.islink(dirpath):
                    logger.info("Deleting link %s" % dirpath)
                    os.unlink(dirpath)
                else:
                    logger.info("Deleting dir %s" % dirpath)
                    os.rmdir(dirpath)
        logger.info("Deleting dir %s", path)
        os.rmdir(path)