Create and return the root Resource of this codebase.
(self)
| 683 | yield dir_resource |
| 684 | |
| 685 | def _create_root_resource(self): |
| 686 | """ |
| 687 | Create and return the root Resource of this codebase. |
| 688 | """ |
| 689 | # we cannot recreate a root if it exists!! |
| 690 | if self.root: |
| 691 | raise TypeError("Root resource already exists and cannot be recreated") |
| 692 | |
| 693 | location = self.location |
| 694 | name = file_name(location) |
| 695 | |
| 696 | # do not strip root for codebase with a single Resource. |
| 697 | path = Resource.build_path(root_location=location, location=location) |
| 698 | |
| 699 | if TRACE: |
| 700 | logger_debug(f" Codebase._create_root_resource: {path} is_file: {self.is_file}") |
| 701 | logger_debug() |
| 702 | |
| 703 | root = self.resource_class( |
| 704 | name=name, |
| 705 | location=location, |
| 706 | # never cached |
| 707 | cache_location=None, |
| 708 | path=path, |
| 709 | is_root=True, |
| 710 | is_file=self.is_file, |
| 711 | ) |
| 712 | |
| 713 | self.resources_by_path[path] = root |
| 714 | self.resources_count += 1 |
| 715 | self.root = root |
| 716 | return root |
| 717 | |
| 718 | def _get_or_create_resource( |
| 719 | self, |
no test coverage detected