def rotree(path, ro=True, chmod_files=True):
    'To make tree read-only or writable\n\n    Parameters\n    ----------\n    path : string\n      Path to the tree/directory to chmod\n    ro : bool, optional\n      Whether to make it R/O (default) or RW\n    chmod_files : bool, optional\n      Whether to operate also on files (not just directories)\n    '
    if ro:
        chmod = (lambda f: os.chmod(f, (os.stat(f).st_mode & (~ stat.S_IWRITE))))
    else:
        chmod = (lambda f: os.chmod(f, ((os.stat(f).st_mode | stat.S_IWRITE) | stat.S_IREAD)))
    for (root, dirs, files) in os.walk(path, followlinks=False):
        if chmod_files:
            for f in files:
                fullf = op.join(root, f)
                if exists(fullf):
                    chmod(fullf)
        chmod(root)
To make tree read-only or writable

Parameters
----------
path : string
  Path to the tree/directory to chmod
ro : bool, optional
  Whether to make it R/O (default) or RW
chmod_files : bool, optional
  Whether to operate also on files (not just directories)
def rotree(path, ro=True, chmod_files=True):
    'To make tree read-only or writable\n\n    Parameters\n    ----------\n    path : string\n      Path to the tree/directory to chmod\n    ro : bool, optional\n      Whether to make it R/O (default) or RW\n    chmod_files : bool, optional\n      Whether to operate also on files (not just directories)\n    '
    if ro:
        chmod = (lambda f: os.chmod(f, (os.stat(f).st_mode & (~ stat.S_IWRITE))))
    else:
        chmod = (lambda f: os.chmod(f, ((os.stat(f).st_mode | stat.S_IWRITE) | stat.S_IREAD)))
    for (root, dirs, files) in os.walk(path, followlinks=False):
        if chmod_files:
            for f in files:
                fullf = op.join(root, f)
                if exists(fullf):
                    chmod(fullf)
        chmod(root)