def scan_cache_dirs(rootdir):
    ' Scan the top level directory of the cache.\n    Walks the path looking for directories that are not in vo_paths.\n    For each of these generate a cache summary\n    '
    results = {}
    try:
        root_components = _split_path(rootdir)
        for (dirpath, dirnames, filenames) in os.walk(rootdir, topdown=True):
            dirpath_components = _split_path(dirpath)[len(root_components):]
            for name in list(dirnames):
                path_components = (dirpath_components + [name])
                for p in [_split_path(p) for p in vo_paths]:
                    if _is_prefix(path_components, p):
                        break
                else:
                    vo_name = os.path.join('/', *path_components)
                    try:
                        results[vo_name] = scan_vo_dir(os.path.join(dirpath, name))
                    except (OSError, IOError) as ex:
                        results[vo_name] = {'scan_vo_dir_error': str(ex)}
                    dirnames.remove(name)
        return results
    except (OSError, IOError) as ex:
        return {'scan_cache_dirs_error': {'message': str(ex)}}
Scan the top level directory of the cache.
Walks the path looking for directories that are not in vo_paths.
For each of these generate a cache summary
def scan_cache_dirs(rootdir):
    ' Scan the top level directory of the cache.\n    Walks the path looking for directories that are not in vo_paths.\n    For each of these generate a cache summary\n    '
    results = {}
    try:
        root_components = _split_path(rootdir)
        for (dirpath, dirnames, filenames) in os.walk(rootdir, topdown=True):
            dirpath_components = _split_path(dirpath)[len(root_components):]
            for name in list(dirnames):
                path_components = (dirpath_components + [name])
                for p in [_split_path(p) for p in vo_paths]:
                    if _is_prefix(path_components, p):
                        break
                else:
                    vo_name = os.path.join('/', *path_components)
                    try:
                        results[vo_name] = scan_vo_dir(os.path.join(dirpath, name))
                    except (OSError, IOError) as ex:
                        results[vo_name] = {'scan_vo_dir_error': str(ex)}
                    dirnames.remove(name)
        return results
    except (OSError, IOError) as ex:
        return {'scan_cache_dirs_error': {'message': str(ex)}}