| 33 | def _create_parser(base_dir): |
| 34 | # create a simple parser that pulls the export_version from the directory. |
| 35 | def parser(path): |
| 36 | # Modify the path object for RegEx match for Windows Paths |
| 37 | if os.name == "nt": |
| 38 | match = re.match( |
| 39 | r"^" + compat.as_str_any(base_dir).replace("\\", "/") + r"/(\d+)$", |
| 40 | compat.as_str_any(path.path).replace("\\", "/")) |
| 41 | else: |
| 42 | match = re.match(r"^" + compat.as_str_any(base_dir) + r"/(\d+)$", |
| 43 | compat.as_str_any(path.path)) |
| 44 | if not match: |
| 45 | return None |
| 46 | return path._replace(export_version=int(match.group(1))) |
| 47 | |
| 48 | return parser |
| 49 | |