Compare commits
2 Commits
6b8b4de21e
...
434fb8ab0e
Author | SHA1 | Date | |
---|---|---|---|
|
434fb8ab0e | ||
|
eb3c789fad |
@ -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
|
||||
@ -1665,7 +1673,7 @@ class OrgDoc:
|
||||
yield from headline.get_code_snippets()
|
||||
|
||||
# Writing
|
||||
def dump_headline(self, headline):
|
||||
def dump_headline(self, headline, recursive=True):
|
||||
|
||||
tags = ""
|
||||
if len(headline.shallow_tags) > 0:
|
||||
@ -1738,8 +1746,9 @@ class OrgDoc:
|
||||
content = content[:-1]
|
||||
yield content
|
||||
|
||||
for child in headline.children:
|
||||
yield from self.dump_headline(child)
|
||||
if recursive:
|
||||
for child in headline.children:
|
||||
yield from self.dump_headline(child, recursive=recursive)
|
||||
|
||||
def dump(self):
|
||||
lines = []
|
||||
@ -2008,7 +2017,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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user