def do_fix(repo_path, options):
    """ Check/fix permissions and remove generated directories. """
    directories = (
        'buildout/bin',
        'buildout/develop-eggs',
        'buildout/eggs',
        'buildout/html',
        'buildout/parts',
        'docs/_build',
    )
    files = (
        'examples/openmdao.examples.bar3simulation/openmdao/examples/bar3simulation/bar3-f2pywrappers.f',
        'examples/openmdao.examples.bar3simulation/openmdao/examples/bar3simulation/bar3module.c'
    )
    for relpath in directories:
        if sys.platform == 'win32':
            relpath.replace('/', '\\')
        directory = os.path.join(repo_path, relpath)
        if os.path.exists(directory):
            shutil.rmtree(directory)
    for relpath in files:
        if sys.platform == 'win32':
            relpath.replace('/', '\\')
        filename = os.path.join(repo_path, relpath)
        if os.path.exists(filename):
            os.remove(filename)

    for dirpath, dirnames, filenames in os.walk(repo_path):
        if options.verbose:
            print dirpath[len(repo_path):]

        names = dirnames
        names.extend(filenames)
        for name in names:
            path = os.path.join(dirpath, name)
            info = os.stat(path)
            mode = info.st_mode

            fixup = mode
            if (mode & stat.S_IRUSR) and not (mode & stat.S_IRGRP):
                fixup |= stat.S_IRGRP
            if (mode & stat.S_IWUSR) and not (mode & stat.S_IWGRP):
                fixup |= stat.S_IWGRP
            if (mode & stat.S_IXUSR) and not (mode & stat.S_IXGRP):
                fixup |= stat.S_IXGRP

            if options.verbose:
                if fixup != mode:
                    print '   fixing %s %s' % (permission_bits(mode), name)
                else:
                    print '   %s %s' % (permission_bits(mode), name)
            elif fixup != mode:
                print 'fixing %s %s' % (permission_bits(mode), path)

            if fixup != mode:
                try:
                    os.chmod(path, fixup)
                except __HOLE__, exc:
                    print '    %s' % exc
                    print '    (owner %s)' % get_username(info.st_uid)
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/scripts/repo.py/do_fix