Save all modified XML files to disk and copy to destination directory. This persists all changes made via add_comment() and reply_to_comment(). Args: destination: Optional path to save to. If None, saves back to original directory. validate: If True
(self, destination=None, validate=True)
| 857 | raise ValueError("Redlining validation failed") |
| 858 | |
| 859 | def save(self, destination=None, validate=True) -> None: |
| 860 | """ |
| 861 | Save all modified XML files to disk and copy to destination directory. |
| 862 | |
| 863 | This persists all changes made via add_comment() and reply_to_comment(). |
| 864 | |
| 865 | Args: |
| 866 | destination: Optional path to save to. If None, saves back to original directory. |
| 867 | validate: If True, validates document before saving (default: True). |
| 868 | """ |
| 869 | # Only ensure comment relationships and content types if comment files exist |
| 870 | if self.comments_path.exists(): |
| 871 | self._ensure_comment_relationships() |
| 872 | self._ensure_comment_content_types() |
| 873 | |
| 874 | # Save all modified XML files in temp directory |
| 875 | for editor in self._editors.values(): |
| 876 | editor.save() |
| 877 | |
| 878 | # Validate by default |
| 879 | if validate: |
| 880 | self.validate() |
| 881 | |
| 882 | # Copy contents from temp directory to destination (or original directory) |
| 883 | target_path = Path(destination) if destination else self.original_path |
| 884 | shutil.copytree(self.unpacked_path, target_path, dirs_exist_ok=True) |
| 885 | |
| 886 | # ==================== Private: Initialization ==================== |
| 887 |
no test coverage detected