Populate this codebase with Resource objects. The actual subclass of Resource objects used in this codebase will be created as a side effect. Population is done by walking its `location` topdown, breadth-first, first creating first file then directory Resou
(self)
| 462 | |
| 463 | # TODO: add populate progress manager!!! |
| 464 | def _populate(self): |
| 465 | """ |
| 466 | Populate this codebase with Resource objects. |
| 467 | |
| 468 | The actual subclass of Resource objects used in this codebase will be |
| 469 | created as a side effect. |
| 470 | |
| 471 | Population is done by walking its `location` topdown, breadth-first, |
| 472 | first creating first file then directory Resources both sorted in case- |
| 473 | insensitive name order. |
| 474 | |
| 475 | Special files, links and VCS files are ignored. |
| 476 | """ |
| 477 | # Collect headers |
| 478 | ########################################################## |
| 479 | self.headers = [] |
| 480 | |
| 481 | # Collect codebase-level attributes and build a class, then load |
| 482 | ########################################################## |
| 483 | # Codebase attributes to use. Configured with plugin attributes if |
| 484 | # present. |
| 485 | self.codebase_attributes = self._collect_codebase_attributes() |
| 486 | cbac = _CodebaseAttributes.from_attributes(attributes=self.codebase_attributes) |
| 487 | self.attributes = cbac() |
| 488 | |
| 489 | # Resource sub-class to use. Configured with plugin attributes if present |
| 490 | ########################################################## |
| 491 | self.resource_class = self._build_resource_class() |
| 492 | |
| 493 | ########################################################## |
| 494 | # walk and create resources proper |
| 495 | |
| 496 | # Create root first |
| 497 | ########################################################## |
| 498 | root = self._create_root_resource() |
| 499 | if TRACE: |
| 500 | logger_debug("Codebase.populate: root:", root) |
| 501 | |
| 502 | if self.has_single_resource: |
| 503 | # there is nothing else to do for a single file or a single |
| 504 | # childless directory |
| 505 | return |
| 506 | |
| 507 | if self.paths: |
| 508 | # In case of a list of full paths, we create resources without walking |
| 509 | return self._create_resources_from_full_paths(root=root, paths=self.paths) |
| 510 | # In case we have multiple |
| 511 | else: |
| 512 | return self._create_resources_from_root( |
| 513 | root=root, |
| 514 | includes=self.includes, |
| 515 | ignores=self.ignores, |
| 516 | ) |
| 517 | |
| 518 | def _create_resources_from_full_paths(self, root, paths): |
| 519 | # without paths we iterate the provided paths. We report an error |
no test coverage detected