| 302 | if exports_to_keep: |
| 303 | # create a simple parser that pulls the export_version from the directory. |
| 304 | def parser(path): |
| 305 | if os.name == "nt": |
| 306 | match = re.match( |
| 307 | r"^" + export_dir_base.replace("\\", "/") + r"/(\d{8})$", |
| 308 | path.path.replace("\\", "/")) |
| 309 | else: |
| 310 | match = re.match(r"^" + export_dir_base + r"/(\d{8})$", path.path) |
| 311 | if not match: |
| 312 | return None |
| 313 | return path._replace(export_version=int(match.group(1))) |
| 314 | |
| 315 | paths_to_delete = gc.negation(exports_to_keep) |
| 316 | for p in paths_to_delete(gc.get_paths(export_dir_base, parser=parser)): |