searches for CONFIG_FILE_NAME in all subdirectories of directory and creates data handlers for all of them :param directory: scan directory :return: null
(directory)
| 124 | |
| 125 | |
| 126 | def load_projects(directory): |
| 127 | """ |
| 128 | searches for CONFIG_FILE_NAME in all subdirectories of directory |
| 129 | and creates data handlers for all of them |
| 130 | |
| 131 | :param directory: scan directory |
| 132 | :return: null |
| 133 | """ |
| 134 | project_dirs = [] |
| 135 | # Don't search more than 2 dirs deep. |
| 136 | search_depth = 2 + directory.count(os.path.sep) |
| 137 | for root, dirs, files in os.walk(directory): |
| 138 | if CONFIG_FILE_NAME in files: |
| 139 | project_dirs.append(root) |
| 140 | # Don't get subprojects under a project dir. |
| 141 | del dirs[:] |
| 142 | elif root.count(os.path.sep) >= search_depth: |
| 143 | del dirs[:] |
| 144 | for p_dir in project_dirs: |
| 145 | print('Loading %s' % os.path.join(p_dir, CONFIG_FILE_NAME)) |
| 146 | with open(os.path.join(p_dir, CONFIG_FILE_NAME), 'r') as jf: |
| 147 | config = EasyDict(json.load(jf)) |
| 148 | dh_id = os.path.split(p_dir)[1] |
| 149 | projects[dh_id] = DissectionProject( |
| 150 | config=config, |
| 151 | project_dir=p_dir, |
| 152 | path_url='data/' + os.path.relpath(p_dir, directory), |
| 153 | public_host=args.public_host) |
| 154 | |
| 155 | app.add_api('server.yaml') |
| 156 |
no test coverage detected