From eb3c789fadf59c0e25cb45f1a593b94d62fd32c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Sun, 19 Jun 2022 21:46:14 +0200 Subject: [PATCH] Raise caution errors as NonReproducibleDocument. --- org_rw/org_rw.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/org_rw/org_rw.py b/org_rw/org_rw.py index 987bf37..e616f05 100644 --- a/org_rw/org_rw.py +++ b/org_rw/org_rw.py @@ -102,6 +102,14 @@ NON_FINISHED_GROUPS = (type(None), dom.ListGroupNode, dom.ResultsDrawerNode, dom FREE_GROUPS = (dom.CodeBlock,) +class NonReproducibleDocument(Exception): + """ + Exception thrown when a document would be saved as different contents + from what it's loaded from. + """ + pass + + def get_tokens(value): if isinstance(value, Text): return value.contents @@ -2008,7 +2016,7 @@ def loads(s, environment=BASE_ENVIRONMENT, extra_cautious=True): context_last_line = None # print("---\n" + after_dump + "\n---") - raise Exception("Difference found between existing version and dumped") + raise NonReproducibleDocument("Difference found between existing version and dumped") return doc