Return a Resource that is the lowest common parent (aka. lowest common ancestor) of all the files of this codebase, skipping root directory segments that are "empty" e.g. with a single child. Return None is this codebase contains a single resource.
(self)
| 1116 | delete(self.cache_dir) |
| 1117 | |
| 1118 | def lowest_common_parent(self): |
| 1119 | """ |
| 1120 | Return a Resource that is the lowest common parent (aka. lowest common |
| 1121 | ancestor) of all the files of this codebase, skipping root directory |
| 1122 | segments that are "empty" e.g. with a single child. Return None is this |
| 1123 | codebase contains a single resource. |
| 1124 | """ |
| 1125 | if self.has_single_resource: |
| 1126 | return self.root |
| 1127 | |
| 1128 | for res in self.walk(topdown=True): |
| 1129 | if not res.is_file: |
| 1130 | kids = res.children(self) |
| 1131 | if len(kids) == 1 and not kids[0].is_file: |
| 1132 | # this is an empty dir with a single dir child, therefore |
| 1133 | # we shall continue the descent walk |
| 1134 | continue |
| 1135 | else: |
| 1136 | # the dir starts to branch: we have our lowest common parent |
| 1137 | # root |
| 1138 | break |
| 1139 | else: |
| 1140 | # we are in a case that should never happen |
| 1141 | return self.root |
| 1142 | return res |
| 1143 | |
| 1144 | def to_list( |
| 1145 | self, |