org-rw/org_rw/dom.py

81 lines
1.6 KiB
Python
Raw Normal View History

2021-08-26 22:22:15 +00:00
class PropertyDrawerNode:
def __init__(self):
self.children = []
def append(self, child):
self.children.append(child)
def __repr__(self):
return "<Properties: {}>".format(len(self.children))
class LogbookDrawerNode:
def __init__(self):
self.children = []
def append(self, child):
self.children.append(child)
def __repr__(self):
return "<LogBook: {}>".format(len(self.children))
class ResultsDrawerNode:
def __init__(self):
self.children = []
def append(self, child):
self.children.append(child)
def __repr__(self):
return "<Results: {}>".format(len(self.children))
2021-08-26 22:22:15 +00:00
class PropertyNode:
def __init__(self, key, value):
self.key = key
self.value = value
def __repr__(self):
return "{{{}: {}}".format(self.key, self.value)
class ListGroupNode:
def __init__(self):
self.children = []
def append(self, child):
self.children.append(child)
def __repr__(self):
return "<List: {}>".format(len(self.children))
class Text:
def __init__(self, content):
self.content = content
class ListItem:
2022-05-06 18:18:44 +00:00
def __init__(self, tag, content, orig=None):
self.tag = tag
2021-08-26 22:22:15 +00:00
self.content = content
2022-05-06 18:18:44 +00:00
self.orig = orig
2021-08-26 22:22:15 +00:00
class BlockNode:
def append(self, child):
raise NotImplementedError()
class CodeBlock(BlockNode):
def __init__(self, header):
self.header = header
2022-05-07 21:33:32 +00:00
self.lines = None
2021-08-26 22:22:15 +00:00
2022-05-07 21:33:32 +00:00
def set_lines(self, lines):
self.lines = lines
2021-08-26 22:22:15 +00:00
def __repr__(self):
return "<Code: {}>".format(len(self.lines))