(base_dir, relative_dir, new_dir)
| 257 | |
| 258 | |
| 259 | def perform_copy_recursively(base_dir, relative_dir, new_dir): |
| 260 | real_dir = os.path.join(base_dir, relative_dir) |
| 261 | assert os.path.exists(real_dir) and os.path.isdir(real_dir) |
| 262 | assert os.path.exists(new_dir) and os.path.isdir(new_dir) |
| 263 | |
| 264 | # Create subdirectory |
| 265 | new_subdir = os.path.join(new_dir, relative_dir) |
| 266 | if not os.path.exists(new_subdir): |
| 267 | print("[make_installer.py] Create: {dir}" |
| 268 | .format(dir=short_dst_path(new_subdir))) |
| 269 | os.makedirs(new_subdir) |
| 270 | |
| 271 | # List directory |
| 272 | paths = os.listdir(real_dir) |
| 273 | for path in paths: |
| 274 | # "path" variable contains relative path |
| 275 | real_path = os.path.join(real_dir, path) |
| 276 | path = os.path.join(relative_dir, path) |
| 277 | if os.path.isdir(real_path): |
| 278 | if is_ignored_path(real_path): |
| 279 | continue |
| 280 | perform_copy_recursively(base_dir, path, new_dir) |
| 281 | elif os.path.isfile(real_path): |
| 282 | if is_ignored_path(real_path): |
| 283 | continue |
| 284 | new_file = os.path.join(new_dir, path) |
| 285 | new_subdir = os.path.dirname(new_file) |
| 286 | if os.path.exists(new_file): |
| 287 | raise Exception("Path aready exists: {new_file}" |
| 288 | .format(new_file=short_dst_path(new_file))) |
| 289 | print("[make_installer.py] Copy: {file} ==> {dir}" |
| 290 | .format(file=short_src_path(real_path), |
| 291 | dir=short_dst_path(new_subdir))) |
| 292 | shutil.copy(real_path, new_subdir) |
| 293 | else: |
| 294 | raise Exception("Unknown path: {path}".format(path=real_path)) |
| 295 | |
| 296 | |
| 297 | def is_ignored_path(path): |
no test coverage detected