| 152 | self.diffs.append(diff) |
| 153 | |
| 154 | def compare( |
| 155 | self, |
| 156 | a_path: Union[ScanLocation, URIHandler, List[ScanLocation]], |
| 157 | b_path: Union[ScanLocation, URIHandler, List[ScanLocation]], |
| 158 | ): |
| 159 | # TODO: add a check if one is URIHandler and the other one is Path or ScanLocation |
| 160 | if isinstance(a_path, URIHandler) and isinstance(b_path, URIHandler): |
| 161 | try: |
| 162 | for item in a_path.get_diff_paths(b_path): |
| 163 | if isinstance(item, Table): |
| 164 | self.tables.append(item) |
| 165 | continue |
| 166 | |
| 167 | loc1, loc2 = item |
| 168 | self.compare(loc1, loc2) |
| 169 | |
| 170 | except UnsupportedDiffLocation: |
| 171 | for item in b_path.get_diff_paths(a_path): |
| 172 | if isinstance(item, Table): |
| 173 | self.tables.append(item) |
| 174 | continue |
| 175 | |
| 176 | loc2, loc1 = item |
| 177 | self.compare(loc1, loc2) |
| 178 | |
| 179 | return |
| 180 | elif type(a_path) == list and type(b_path) == list: |
| 181 | self._diff_files(a_path, b_path) |
| 182 | elif a_path.location.is_file() and b_path.location.is_file(): |
| 183 | self._diff_files([a_path], [b_path]) |
| 184 | elif b_path.location.is_dir() and a_path.location.is_dir(): |
| 185 | self._diff_dirs(a_path, b_path) |
| 186 | else: |
| 187 | # TODO: be able to compare an archive and a directory |
| 188 | raise ValueError(f"FS type mismatch: {str(a_path)}, {str(b_path)}") |
| 189 | |
| 190 | def analyze_changes(self): |
| 191 | locations = {} |